3 回答
TA贡献1712条经验 获得超3个赞
尝试使用 CSS 过渡。在 CSS 中,做这样的事情:
button.continue {
transition: 5s;
}
然后在 JS 中,你可以只设置左/上值:
document.querySelectorAll('button.continue').forEach(button => {
button.style.left = '100px';
button.style.top = '200px';
});
TA贡献1848条经验 获得超2个赞
在 Firefox 中测试。
document
.querySelector(".text.thank-you")
.animate({ opacity: [0, 1] }, { duration: 5000, iterations: 1, easing: "ease-out" })
.onfinish = (e) => {
e.target.effect.target.style.opacity = 1;
};
TA贡献1780条经验 获得超5个赞
尝试使用WebComponents,您可以执行只使用任何类型的动画VanillaJS,有预定义如动画Animate.css,但你可以通过创建自定义动画关键帧:
<!-- Add Web Animations Polyfill :) -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/web-animations/2.3.2/web-animations.min.js"></script>
<script type="module" src="https://unpkg.com/@proyecto26/animatable-component@1.0.0/dist/animatable-component/animatable-component.esm.js"></script>
<script nomodule="" src="https://unpkg.com/@proyecto26/animatable-component@1.0.0/dist/animatable-component/animatable-component.js"></script>
<animatable-component
autoplay
easing="ease-in-out"
duration="1200"
delay="300"
animation="heartBeat"
iterations="Infinity"
style="display: flex;align-self: center;"
>
<h1>Hello World</h1>
</animatable-component>
有关更多详细信息,请查看此处:https : //github.com/proyecto26/animatable-component
添加回答
举报
