簡體   English   中英

關於JavaScript幫助實現淡入淡出animation

[英]about JavaScript help to implement fade-in and fade-out animation

const animation=document.querySelectorAll('.fade');
console.log(animation);
window.addEventListener("scroll",fadeIN);
function fadeIN()
{
  for (let i=0; i<animation.length; i++)
  {
    let j=animation[i];
    let height = j.getBoundingClientRect().top - window.innerHeight + 20; 
    if (height < 0) {
      j.classList.add("visible");
    } else {
      j.classList.remove("visible");
    }
  }
}
fadeIN()

幫我改變這個邏輯

let height = j.getBoundingClientRect().top - window.innerHeight + 20; 

使用簡單的 JavaScript 代碼使用 web API 庫

此 javascipt 代碼即將淡入淡出 animation 代碼正在運行,但我必須更改此 DOMreact 代碼,let height = j.getBoundingClientRect().top - window.innerHeight + 20; 使用簡單的 javascript 邏輯是否可能

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

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