Skip to content

Commit

Permalink
v3.2.3
Browse files Browse the repository at this point in the history
Fixes zenscroll.moving() not returning true when scroll is in progress
  • Loading branch information
zengabor committed Oct 23, 2016
1 parent f6e4b7b commit f470f72
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "zenscroll",
"version": "3.2.2",
"version": "3.2.3",
"description": "A module to smooth-scroll web pages and containers (DIVs)",
"main": "zenscroll.js",
"files": ["zenscroll.js", "zenscroll-min.js"],
Expand Down
2 changes: 1 addition & 1 deletion zenscroll-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions zenscroll.js
@@ -1,5 +1,5 @@
/**
* Zenscroll 3.2.2
* Zenscroll 3.2.3
* https://github.com/zengabor/zenscroll/
*
* Copyright 2015–2016 Gabor Lenard
Expand Down Expand Up @@ -61,6 +61,9 @@
}

var scrollTimeoutId
var setScrollTimeoutId = function (newValue) {
scrollTimeoutId = newValue
}
var docElem = document.documentElement

// Detect if the browser already supports native smooth scrolling (e.g., Firefox 36+ and Chrome 49+) and it is enabled:
Expand Down Expand Up @@ -98,7 +101,7 @@
*/
var stopScroll = function () {
clearTimeout(scrollTimeoutId)
scrollTimeoutId = 0
setScrollTimeoutId(0)
}

/**
Expand All @@ -122,7 +125,7 @@
duration = duration || Math.min(Math.abs(distance), defaultDuration)
var startTime = new Date().getTime();
(function loopScroll() {
scrollTimeoutId = setTimeout(function () {
setScrollTimeoutId(setTimeout(function () {
var p = Math.min((new Date().getTime() - startTime) / duration, 1) // percentage
var y = Math.max(Math.floor(startY + distance*(p < 0.5 ? 2*p*p : p*(4 - p*2)-1)), 0)
if (scrollContainer) {
Expand All @@ -138,7 +141,7 @@
onDone()
}
}
}, 9)
}, 9))
})()
}
}
Expand Down

0 comments on commit f470f72

Please sign in to comment.