Bind touch handlers only when it's supported.

Fix #227.
This commit is contained in:
Hyunje Alex Jun 2014-10-21 21:06:16 +01:00
parent 664dec23d6
commit ee4fc96b7a

View File

@ -531,7 +531,7 @@
});
}
function bindTouchHandler() {
function bindTouchHandler(supportsTouch, supportsIePointer) {
function applyTouchMove(differenceX, differenceY) {
$this.scrollTop($this.scrollTop() - differenceY);
$this.scrollLeft($this.scrollLeft() - differenceX);
@ -613,12 +613,15 @@
}, 10);
}
if (supportsTouch) {
$(window).bind("touchstart" + eventClassName, globalTouchStart);
$(window).bind("touchend" + eventClassName, globalTouchEnd);
$this.bind("touchstart" + eventClassName, touchStart);
$this.bind("touchmove" + eventClassName, touchMove);
$this.bind("touchend" + eventClassName, touchEnd);
}
if (supportsIePointer) {
if (window.PointerEvent) {
$(window).bind("pointerdown" + eventClassName, globalTouchStart);
$(window).bind("pointerup" + eventClassName, globalTouchEnd);
@ -633,6 +636,7 @@
$this.bind("MSPointerUp" + eventClassName, touchEnd);
}
}
}
function bindScrollHandler() {
$this.bind('scroll' + eventClassName, function (e) {
@ -689,7 +693,7 @@
bindMouseWheelHandler();
if (supportsTouch || supportsIePointer) {
bindTouchHandler();
bindTouchHandler(supportsTouch, supportsIePointer);
}
if (settings.useKeyboard) {
bindKeyboardHandler();