Skip to content

Commit aa5dd17

Browse files
committed
* Support progammatic scrolling on x axis
* Detect touch screen
1 parent c20e40d commit aa5dd17

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

scrollability-min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scrollability.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ var kScrollToTime = 12;
3535

3636
var isWebkit = "webkitTransform" in document.documentElement.style;
3737
var isFirefox = "MozTransform" in document.documentElement.style;
38+
var isTouch = "ontouchstart" in window;
3839

3940
// ===============================================================================================
4041

@@ -71,10 +72,11 @@ window.scrollability = {
7172
touchTargets = [target];
7273
touchMoved = true;
7374
if (animationTime) {
74-
// XXXjoe Support horizontal if that is the axis of element
7575
var orig = element[target.key];
76+
var dest = target.filter(x, y);
77+
7678
animationInterval = setInterval(function() {
77-
target.updater(orig + ((y-orig) * (t/animationTime)));
79+
target.updater(orig + ((dest-orig) * (t/animationTime)));
7880
if (++t > animationTime) {
7981
clearInterval(animationInterval);
8082
setTimeout(stopAnimation, 200);
@@ -96,7 +98,7 @@ function onScroll(event) {
9698
setTimeout(function() {
9799
if (justChangedOrientation) {
98100
justChangedOrientation = false;
99-
} else {
101+
} else if (isTouch) {
100102
var scrollables = document.getElementsByClassName('scrollable');
101103
if (scrollables.length) {
102104
var scrollable = scrollables[0];

0 commit comments

Comments
 (0)