Merge pull request #1 from CartoDB/touchmove

Avoid to process touchmove event if target has class ps-prevent-touch…
This commit is contained in:
Buti 2017-02-14 11:02:53 +01:00 committed by GitHub
commit 735c6c0bf3

View File

@ -88,32 +88,37 @@ function bindTouchHandler(element, i, supportsTouch, supportsIePointer) {
} }
} }
function touchMove(e) { function touchMove(e) {
if (!inLocalTouch && i.settings.swipePropagation) { var target = e.target;
touchStart(e); var className = target && target.getAttribute('class') || '';
}
if (!inGlobalTouch && inLocalTouch && shouldHandle(e)) {
var touch = getTouch(e);
var currentOffset = {pageX: touch.pageX, pageY: touch.pageY}; if (!className.match(/ps-prevent-touchmove/)) {
if (!inLocalTouch && i.settings.swipePropagation) {
var differenceX = currentOffset.pageX - startOffset.pageX; touchStart(e);
var differenceY = currentOffset.pageY - startOffset.pageY;
applyTouchMove(differenceX, differenceY);
startOffset = currentOffset;
var currentTime = (new Date()).getTime();
var timeGap = currentTime - startTime;
if (timeGap > 0) {
speed.x = differenceX / timeGap;
speed.y = differenceY / timeGap;
startTime = currentTime;
} }
if (!inGlobalTouch && inLocalTouch && shouldHandle(e)) {
var touch = getTouch(e);
if (shouldPreventDefault(differenceX, differenceY)) { var currentOffset = {pageX: touch.pageX, pageY: touch.pageY};
e.stopPropagation();
e.preventDefault(); var differenceX = currentOffset.pageX - startOffset.pageX;
var differenceY = currentOffset.pageY - startOffset.pageY;
applyTouchMove(differenceX, differenceY);
startOffset = currentOffset;
var currentTime = (new Date()).getTime();
var timeGap = currentTime - startTime;
if (timeGap > 0) {
speed.x = differenceX / timeGap;
speed.y = differenceY / timeGap;
startTime = currentTime;
}
if (shouldPreventDefault(differenceX, differenceY)) {
e.stopPropagation();
e.preventDefault();
}
} }
} }
} }