簡體   English   中英

JavaScript + CSS3動畫無法正常工作?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM