动画与缓动

let liTags = document.getElementsByClassName('menuTigger')//document.querySelectorAll('nav.menu>ul>li')

for(let i=0;i0){
        topNavBar.classList.add('sticky')

    }else{
        topNavBar.classList.add('sticky')
    }
}    
setTimeout(function(){
    siteWelcome.classList.remove('active')
},1000)


div1.style.position = 'relative'
div1.style.left = 0
var n = 0
var id = setInterval(()=>{
    n = n+1 
    div1.style.left =n+'px'//必须px
    if(n>200){
        window.clearInterval(id)
    }
},40)

let aTags = document.querySelectorAll('nav.menu > ul > li >a')
for(let i = 0;i{
            if(i===n){
                window.clearInterval(id)
                return
            }
            i =i+1
            window.scrollTo(0, currentTop +distance*i)//最初始的高度,加多少次呢,还需要变量i
        },duration)//从当前的高度滚到要去的高度.要滚的距离:target.scrollY(div.offsetTop) - window.scrollY
    }
}

你可能感兴趣的:(动画与缓动)