两段序列帧动画播放,在ios机型上出现闪屏

使用场景:两段序列帧动画连接播放,先播放第一段播一次,再播放第二段,第二段循环播放,在ios机型上出现动画闪动,播放不正常。

错误的写法:把每一段序列帧动画单独写在了定义的动画里

css 复制代码
.gacha-bg {
  width: 750rpx;
  height: 1000rpx;
  animation: gacha 1.6s steps(22), xing 2s steps(27);
  animation-delay: 0.8s, 2.4s;
  animation-iteration-count: 1, infinite;
  animation-fill-mode: forwards, forwards;
}

@keyframes gacha {
  0% {
    background-image: url('1.jpg');
    background-size: 17250rpx;
    background-repeat: no-repeat;
    background-position: 0;
  }
  100% {
    background-image: url('1.jpg');
    background-size: 17250rpx;
    background-repeat: no-repeat;
    background-position: -16500rpx;
  }
}

@keyframes xing {
  0% {
    background-image: url('bg.jpg');
    background-size: 21000rpx;
    background-repeat: no-repeat;
    background-position: 0;
  }
  100% {
    background-image: url('bg.jpg');
    background-size: 21000rpx;
    background-repeat:no-repeat;
    background-position: -20250rpx 0;
  }
}

修改后:

背景图需要统一写一遍,由于第二段要循环播放,所以需要在定义的第二段动画里写上图片信息

css 复制代码
.gacha-bg {
  width: 750rpx;
  height: 1000rpx;
  animation: gacha 1.6s steps(22), xing 2s steps(27);
  animation-delay: 0.8s, 2.4s;
  animation-iteration-count: 1, infinite;
  animation-fill-mode: forwards, forwards;
  background-image: url('1.jpg'),url('bg.jpg');
  background-size: 17250rpx,21000rpx;
  background-repeat: no-repeat,no-repeat;
}

@keyframes gacha {
  0% {
    background-position: 0 0;
  }
  100% {
    background-position: -16500rpx 0;
  }
}

@keyframes xing {
  0% {
    background-image: url('bg.jpg');
    background-size: 21000rpx;
    background-repeat: no-repeat;
    background-position: 0 0;
  }
  100% {
    background-image: url('bg.jpg');
    background-size: 21000rpx;
    background-repeat: no-repeat;
    background-position: -20250rpx 0;
  }
}
相关推荐
人月神话-Lee1 小时前
【图像处理】Core Image 与 GPU 渲染管线——让滤镜飞起来
图像处理·人工智能·ios·chatgpt·ai编程·swift·gpu
罗超驿1 小时前
9.零基础学CSS:元素属性设置(字体、颜色、对齐等)全解析
前端·css
ZC跨境爬虫3 小时前
跟着 MDN 学CSS day_34:(CSS 布局全面解析)
前端·css·ui·html·tensorflow
ZC跨境爬虫4 小时前
跟着 MDN 学CSS day_32:(Web字体深度解析与实践指南)
前端·javascript·css·ui·html
ZC跨境爬虫5 小时前
跟着 MDN 学CSS day_35:浮动布局完全指南
前端·css·ui·html·tensorflow
夏天的峰没有风5 小时前
Typora+gitcode+picgo搭建免费图床
开发语言·ios·swift
double_eggm5 小时前
微信小程序8
微信小程序·小程序
库奇噜啦呼5 小时前
【iOS】源码学习-分类、扩展、关联对象
学习·ios·分类
宏笋5 小时前
qss/css 样式中margin和padding的作用和区别
css·qt
kyh100338112016 小时前
Cocos Creator 《打螺丝消除游戏》源码+实现
游戏·微信小程序·小程序·打螺丝小游戏源码·微笑小游戏源码