[英]JavaScript + CSS3 animations not working properly?
我目前正在編程一個名為quickly.js
的庫。 有conceal(milliseconds)
和display()
函數,它們具有通過CSS編程的動畫。 隱藏功能動畫正常工作,但顯示功能動畫正常工作。 它不會淡入。相反,它會突然出現。 這是一個演示該錯誤的JSFiddle: https ://jsfiddle.net/v6esmqtf/6/。
您只是沒有設置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);
};
接着...
document.getElementById("conceal").onclick = function() {
document.getElementById("get").conceal(800);
};
document.getElementById("display").onclick = function() {
document.getElementById("get").display(0);
};
希望這可以幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.