Inhance the scroll logic with mobile touches.
The scroll works only when the user touch and scroll the wrapper div with just one touch. By this patch, the zoom function will not be prevented by scrolling content.
This commit is contained in:
parent
aeab94c7d6
commit
3b1c37440e
@ -236,7 +236,15 @@
|
|||||||
var startCoords = {},
|
var startCoords = {},
|
||||||
startTime = 0,
|
startTime = 0,
|
||||||
speed = {},
|
speed = {},
|
||||||
breakingProcess = null;
|
breakingProcess = null,
|
||||||
|
inGlobalTouch = false;
|
||||||
|
|
||||||
|
$(window).bind("touchstart.perfect-scroll", function (e) {
|
||||||
|
inGlobalTouch = true;
|
||||||
|
});
|
||||||
|
$(window).bind("touchend.perfect-scroll", function (e) {
|
||||||
|
inGlobalTouch = false;
|
||||||
|
});
|
||||||
|
|
||||||
$this.bind("touchstart.perfect-scroll", function (e) {
|
$this.bind("touchstart.perfect-scroll", function (e) {
|
||||||
var touch = e.originalEvent.targetTouches[0];
|
var touch = e.originalEvent.targetTouches[0];
|
||||||
@ -249,26 +257,30 @@
|
|||||||
if (breakingProcess !== null) {
|
if (breakingProcess !== null) {
|
||||||
clearInterval(breakingProcess);
|
clearInterval(breakingProcess);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
e.stopPropagation();
|
||||||
});
|
});
|
||||||
$this.bind("touchmove.perfect-scroll", function (e) {
|
$this.bind("touchmove.perfect-scroll", function (e) {
|
||||||
var touch = e.originalEvent.targetTouches[0];
|
if (!inGlobalTouch && e.originalEvent.targetTouches.length === 1) {
|
||||||
|
var touch = e.originalEvent.targetTouches[0];
|
||||||
|
|
||||||
var currentCoords = {};
|
var currentCoords = {};
|
||||||
currentCoords.pageX = touch.pageX;
|
currentCoords.pageX = touch.pageX;
|
||||||
currentCoords.pageY = touch.pageY;
|
currentCoords.pageY = touch.pageY;
|
||||||
|
|
||||||
var differenceX = currentCoords.pageX - startCoords.pageX,
|
var differenceX = currentCoords.pageX - startCoords.pageX,
|
||||||
differenceY = currentCoords.pageY - startCoords.pageY;
|
differenceY = currentCoords.pageY - startCoords.pageY;
|
||||||
|
|
||||||
applyTouchMove(differenceX, differenceY);
|
applyTouchMove(differenceX, differenceY);
|
||||||
startCoords = currentCoords;
|
startCoords = currentCoords;
|
||||||
|
|
||||||
var currentTime = (new Date()).getTime();
|
var currentTime = (new Date()).getTime();
|
||||||
speed.x = differenceX / (currentTime - startTime);
|
speed.x = differenceX / (currentTime - startTime);
|
||||||
speed.y = differenceY / (currentTime - startTime);
|
speed.y = differenceY / (currentTime - startTime);
|
||||||
startTime = currentTime;
|
startTime = currentTime;
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
$this.bind("touchend.perfect-scroll", function (e) {
|
$this.bind("touchend.perfect-scroll", function (e) {
|
||||||
breakingProcess = setInterval(function () {
|
breakingProcess = setInterval(function () {
|
||||||
|
Loading…
Reference in New Issue
Block a user