samedi 23 mars 2019

how stop animation in scroll when it arrive it

i need when i arrive if section exicute just ones put ijn my code still do it when i arrive to the spot and scrolling to the bottom

var tf=true;
window.addEventListener("scroll", () => {
  var div=document.getElementById("firstone");
  const scrol=document.documentElement.scrollHeight-window.innerHeight;
  const ookk=window.innerHeight-300;  //the height of ur screen 
  const scroly=window.scrollY;
//  console.log(scroly);
//  console.log(ookk+"fuck u anyways");

  if(scroly=>ookk && tf==true){
    tf=false;
    console.log("done");
    div.classList.toggle("animationleftright");
    setTimeout(shityone, 400);
//    div.addEventListener("animationend", ()=>{div.style.marginLeft="0px";div.classList.toggle("animationleftright");});
  }
} );
function shityone(){
  var div2=document.getElementById("firstone");
  div2.style.marginLeft="0px";
  div2.classList.toggle("animationleftright");
}
~~~~




Aucun commentaire:

Enregistrer un commentaire