[英]JavaScript + CSS3 animations not working properly?
I am currently programming a library called quickly.js
. 我目前正在编程一个名为
quickly.js
的库。 There are conceal(milliseconds)
and display()
functions, which have animations that are programmed through CSS. 有
conceal(milliseconds)
和display()
函数,它们具有通过CSS编程的动画。 The conceal function animation is working correctly, but the display function animation does not work correctly. 隐藏功能动画正常工作,但显示功能动画正常工作。 It does not fade in. Instead, it abruptly appears.
它不会淡入。相反,它会突然出现。 Here is a JSFiddle demonstrating the bug: https://jsfiddle.net/v6esmqtf/6/ .
这是一个演示该错误的JSFiddle: https ://jsfiddle.net/v6esmqtf/6/。
You simply didn't have the display
function set up. 您只是没有设置
display
功能。
Element.prototype.conceal = function(ms) {
ms = ms || 0;
var thisStyle = this.style;
thisStyle.opacity = 0;
setTimeout(function() {
thisStyle.display = "none";
}, ms);
};
Element.prototype.display = function(ms) {
ms = ms || 0;
var thisStyle = this.style;
thisStyle.display = "";
setTimeout(function() {
thisStyle.opacity = 1;
}, ms);
};
And then... 接着...
document.getElementById("conceal").onclick = function() {
document.getElementById("get").conceal(800);
};
document.getElementById("display").onclick = function() {
document.getElementById("get").display(0);
};
Hope this helps. 希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.