var s = 0; var l = 4; var timer = null; var isback = false; W(document).on('mousewheel', function(e) { var isTop = document.body.scrollTop == document.documentElement.scrollTop; if (isTop && !isback && s < 100 && e.detail < 0) { clearTimeout(timer); console.log(s, l); s += l; l++; document.body.style.marginTop = s + 'px'; timer = setTimeout(function() { isback = true; anim = new Anim(document.body, { "margin-top": { "to": 0 } }, 500, Anim.Easing.easeInStrong); anim.on('suspend', function(e) { s = 0; l = 0; isback = false }); anim.play(); }, 50); } });