css 仿老虎机的loader动画,每一轮结束,都要停顿一下才到下一轮。
<view class="slot-machine flex_cc" style="top: {{ top + '%' }};">
<image
class="slot-machine__back"
src="../images/slot-back-1.svg"
mode="aspectFill" />
<view class="carousel flex_space">
<block wx:for="{{ 3 }}" wx:for-index="index" wx:key="item">
<image
class="slot-column"
src="../images/slot-machine-{{ index }}.svg"
mode="aspectFill" />
</block>
</view>
</view>
.slot-machine,
.slot-machine__back {
width: 260rpx;
height: 260rpx;
position: absolute;
left: 50%;
transform: translate(-50%, -50%);
}
.slot-machine {
background-color: var(--color-ffe30a);
border-radius: 260rpx;
overflow: hidden;
}
.slot-machine__back {
top: 50%;
z-index: 0;
}
.carousel {
width: 260rpx;
height: 60rpx;
overflow: hidden;
position: absolute;
top: 110rpx;
left: 0;
right: 0;
z-index: 2;
}
.slot-column {
height: 312rpx;
position: absolute;
top: 0;
will-change: transform;
transform: translateZ(0);
}
.slot-column:nth-child(1) {
width: 90rpx;
animation: scroll1 5s cubic-bezier(0.19, 1, 0.22, 1) infinite;
left: 0;
}
.slot-column:nth-child(2) {
width: 60rpx;
animation: scroll2 5.5s cubic-bezier(0.19, 1, 0.22, 1) infinite;
animation-delay: 0.7s;
left: 0;
right: 0;
margin: 0 auto;
}
.slot-column:nth-child(3) {
width: 90rpx;
animation: scroll3 4.2s cubic-bezier(0.19, 1, 0.22, 1) infinite;
animation-delay: 0.5s;
right: 0;
}
@keyframes scroll1 {
0% {
transform: translateY(0);
}
100% {
transform: translateY(-100%);
}
}
@keyframes scroll2 {
0% {
transform: translateY(0);
}
100% {
transform: translateY(-100%);
}
}
@keyframes scroll3 {
0% {
transform: translateY(0);
}
100% {
transform: translateY(-100%);
}
}