3 回答

TA貢獻1712條經(jīng)驗 獲得超3個贊
嘗試使用 CSS 過渡。在 CSS 中,做這樣的事情:
button.continue {
transition: 5s;
}
然后在 JS 中,你可以只設(shè)置左/上值:
document.querySelectorAll('button.continue').forEach(button => {
button.style.left = '100px';
button.style.top = '200px';
});

TA貢獻1848條經(jīng)驗 獲得超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條經(jīng)驗 獲得超5個贊
嘗試使用WebComponents,您可以執(zhí)行只使用任何類型的動畫VanillaJS,有預(yù)定義如動畫Animate.css,但你可以通過創(chuàng)建自定義動畫關(guān)鍵幀:
<!-- 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>
有關(guān)更多詳細信息,請查看此處:https : //github.com/proyecto26/animatable-component
添加回答
舉報