Avoid to process touchmove event if target has class ps-prevent-touchmove.

This allow us to filter histogram widgets inside ps when touch events happen.
This commit is contained in:
nobuti 2017-02-13 15:53:34 +01:00
parent 4707acc287
commit 553756b346

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();
}
} }
} }
} }