javascript Web Animations APIを使った波纹アニメーション(涟漪效应)参考:https://qiita.com/shisama/items/c1cf3c52695ff17af Posted 2021-05-04
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript Web Animations APIを使った波纹アニメーション(涟漪效应)参考:https://qiita.com/shisama/items/c1cf3c52695ff17af相关的知识,希望对你有一定的参考价值。
animation.oncancel = function() {
alert("canceled!");
}
document.querySelector(".some-button").addEventListener("click", function(event) {
animation.play();
setTimeout(function () {
animation.cancel();
}, 5000);
});
animation.cancel()
document.querySelector(".some-button").addEventListener("click", function(event) {
animation.play();
});
animation.play()
const keyframes = new KeyframeEffect(
el,
{
boxShadow: ["0 0 0 0 rgba(255,0,0, 1)", "0 0 0 20px rgba(255,0,0, 0)"]
},
{
duration: 1500,
iterations: Infinity
}
);
const animation = new Animation(keyframes, document.timeline);
const animation = el.animate([
{
boxShadow: "0 0 0 0 rgba(255,0,0, 1)",
background: "red"
},
{
boxShadow: "0 0 0 20px rgba(255,0,0, 0)",
background: "pink"
}
],
{
duration: 1500,
iterations: Infinity
}
);
{
boxShadow: ["0 0 0 0 rgba(255,0,0, 1)", "0 0 0 20px rgba(255,0,0, 0)"],
background: ["red", "pink"]
},
window.onkeydown = function(event) {
if (event.key === "Enter") {
animation.reverse();
}
};
animation.reverse()
animation.onfinish = function() {
alert("finished!");
}
window.onkeydown = function(event) {
if (event.key === "Escape") {
animation.finish();
}
};
animation.finish()
el.onmouseover = function(event) {
animation.pause();
};
animation.pause()
const el = document.querySelector(".pulsator");
const animation = el.animate(
{
boxShadow: ["0 0 0 0 rgba(255,0,0, 1)", "0 0 0 20px rgba(255,0,0, 0)"]
},
{
duration: 1500,
iterations: Infinity
}
);
const el = document.querySelector(".pulsator");
const style = {
width: "15px",
height: "15px",
borderRadius: "50%",
borderColor: "red",
background: "red",
boxShadow: "0 0 0 rgba(255,0,0, 0.4)"
};
Object.assign(element.style, style);
以上是关于javascript Web Animations APIを使った波纹アニメーション(涟漪效应)参考:https://qiita.com/shisama/items/c1cf3c52695ff17af的主要内容,如果未能解决你的问题,请参考以下文章
[Angular Tutorial] 14 -Animations
css CSS Web Animations无前缀
css3 动画应用 animations 和transtions transform在加上JavaScript 可以实现硬件加速动画。
优化算法动画演示Alec Radford's animations for optimization algorithms
用于CSS3文本动画的jquery插件。
Animations in UWP Community Toolkit - Overview