Skip to content

Commit

Permalink
ability to seek scrollable with iPod/iPhone touch event
Browse files Browse the repository at this point in the history
  • Loading branch information
tipiirai committed Sep 20, 2010
1 parent b3e9d79 commit d63892b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/rangeinput/rangeinput.js
Expand Up @@ -371,7 +371,7 @@
if (input.is(":disabled") || e.target == handle[0]) {
return e.preventDefault();
}
init();
var fix = handle.width() / 2;
slide(e, vertical ? len-origo-fix + e.pageY : e.pageX -origo -fix);
});
Expand Down
25 changes: 25 additions & 0 deletions src/scrollable/scrollable.js
Expand Up @@ -31,6 +31,7 @@
prev: '.prev',
speed: 400,
vertical: false,
touch: true,
wheelSpeed: 0
}
};
Expand Down Expand Up @@ -256,6 +257,30 @@
});
}

// touch event
if (conf.touch) {
var touch = {};

itemWrap[0].ontouchstart = function(e) {
var t = e.touches[0];
touch.x = t.clientX;
touch.y = t.clientY;
};

itemWrap[0].ontouchmove = function(e) {

// only deal with one finger
if (e.touches.length == 1 && !itemWrap.is(":animated")) {
var t = e.touches[0],
deltaX = touch.x - t.clientX,
deltaY = touch.y - t.clientY;

self[vertical && deltaY > 0 || !vertical && deltaX > 0 ? 'next' : 'prev']();
e.preventDefault();
}
};
}

if (conf.keyboard) {

$(document).bind("keydown.scrollable", function(evt) {
Expand Down

0 comments on commit d63892b

Please sign in to comment.