zepto下动画返回顶部

 function scroll(scrollTo, time) {
                var scrollFrom = parseInt(document.body.scrollTop),
                        i = 0,
                        runEvery = 5; // run every 5ms

                scrollTo = parseInt(scrollTo);
                time /= runEvery;

                var interval = setInterval(function () {
                        i++;

                        document.body.scrollTop = (scrollTo - scrollFrom) / time * i + scrollFrom;

                        if (i >= time) {
                                clearInterval(interval);
                        }
                }, runEvery);
        } 
 var scrolltop=$(".content_discuss1").offset().top-window.innerHeight;
scroll(scrolltop,800); 
上一篇:Java代码优化小结(三)


下一篇:H5 应用程序返回button的js代码设计,设计仿stack