<template>
<div class="sge">
<view
:animation="eggAnimationData"
@click="rotateAndScale"
>
<img
:src="eggsimg"
class="egg"
alt=""
>
</view>
<view
:animation="czAnimationData"
class="cz"
>
<img
src="https://appimg.super0.net/zjdcz.png"
alt=""
>
</view>
</div>
</template>
<script>
export default {
name: "ScrmH5SmashGoldenEggs",
data() {
return {
eggsimg: "https://appimg.super0.net/zjdopen.png",
eggAnimationData: {},
czAnimationData: {},
};
},
mounted() {
this.$nextTick(() => {
var animation = uni.createAnimation({
transformOrigin: "50% 50%",
duration: 20,
timingFunction: "ease",
});
this.animation = animation;
});
},
methods: {
rotateAndScale: function (e) {
this.animation.opacity(1).step({ duration: 300 });
this.animation
.rotateZ(80)
.step({ transformOrigin: "80% 80%", duration: 600 });
this.animation
.rotateZ(-50)
.step({ transformOrigin: "80% 80%", duration: 200 });
this.czAnimationData = this.animation.export();
setTimeout(() => {
this.animation.rotateZ(-50).step();
// this.animation.opacity(0).step();
this.czAnimationData = this.animation.export();
}, 1200);
setTimeout(() => {
this.animation.currentTransform = [];
for (let i = 0; i < 7; i++) {
this.animation.translate(5).step();
this.animation.translate(-5).step();
}
this.animation.translate(0).step();
this.eggAnimationData = this.animation.export();
}, 1800);
setTimeout(() => {
// this.$emit("result", e);
}, 1000);
},
},
};
</script>
<style lang="scss" scoped>
.sge {
position: relative;
display: flex;
justify-content: center;
align-items: center;
.egg {
width: 600rpx;
}
.cz {
position: absolute;
width: 200rpx;
right: 60rpx;
top: 60rpx;
opacity: 0;
img {
width: 100%;
}
}
}
</style>
![SuperGP](https://img-cdn-tc.dcloud.net.cn/account/identicon/dcf8dc3391b7d79c9ff2bff404440801.png)
- 发布:2022-10-25 17:07
- 更新:2022-10-25 17:07
- 阅读:192
产品分类: uniapp/H5
PC开发环境操作系统: Mac
PC开发环境操作系统版本号: 12.4 (21F79)
浏览器平台: Chrome
浏览器版本: 104.0.5112.101(正式版本) (x86_64)
项目创建方式: CLI
CLI版本号: 2.0.1-35320220729002
示例代码:
操作步骤:
点击方法执行动画小锤子会被偏移
点击方法执行动画小锤子会被偏移
预期结果:
两段动画互不干扰
两段动画互不干扰
实际结果:
会被干扰
会被干扰
bug描述:
多view窗口需要动画时 会互相干扰下层动画回干扰到上层就是指最后一段执行的动画回把上面的也一起被执行
![](http://img-cdn-tc.dcloud.net.cn/uploads/questions/20221025/9e9420d61b4728e7ad534571a31d6869.jpg)
![](http://img-cdn-tc.dcloud.net.cn/uploads/questions/20221025/bbf1d23f696099144a6212ce02cff89b.jpg)