Skip to content

Instantly share code, notes, and snippets.

View Yunkou's full-sized avatar
🏠
Working from home

yun.kou Yunkou

🏠
Working from home
View GitHub Profile
@Yunkou
Yunkou / zepto.smoothScroll.js
Created September 14, 2016 10:16 — forked from benjamincharity/zepto.smoothScroll.js
Smooth scrolling with Zepto.js
function smoothScroll(el, to, duration) {
if (duration < 0) {
return;
}
var difference = to - $(window).scrollTop();
var perTick = difference / duration * 10;
this.scrollToTimerCache = setTimeout(function() {
if (!isNaN(parseInt(perTick, 10))) {
window.scrollTo(0, $(window).scrollTop() + perTick);
smoothScroll(el, to, duration - 10);