Merge b541aea4cd into f90c2a6d4b
This commit is contained in:
commit
a3fef40ca6
|
|
@ -9,6 +9,9 @@ import * as Log from '../util/logging.js';
|
||||||
import { isTouchDevice } from '../util/browser.js';
|
import { isTouchDevice } from '../util/browser.js';
|
||||||
import { setCapture, stopEvent, getPointerEvent } from '../util/events.js';
|
import { setCapture, stopEvent, getPointerEvent } from '../util/events.js';
|
||||||
|
|
||||||
|
var tpCache = new Array();
|
||||||
|
var tpTreshold = null;
|
||||||
|
|
||||||
const WHEEL_STEP = 10; // Delta threshold for a mouse wheel step
|
const WHEEL_STEP = 10; // Delta threshold for a mouse wheel step
|
||||||
const WHEEL_STEP_TIMEOUT = 50; // ms
|
const WHEEL_STEP_TIMEOUT = 50; // ms
|
||||||
const WHEEL_LINE_HEIGHT = 19;
|
const WHEEL_LINE_HEIGHT = 19;
|
||||||
|
|
@ -103,6 +106,15 @@ Mouse.prototype = {
|
||||||
},
|
},
|
||||||
|
|
||||||
_handleMouseDown: function (e) {
|
_handleMouseDown: function (e) {
|
||||||
|
if(e.type == 'touchstart') {
|
||||||
|
|
||||||
|
if (e.targetTouches.length == 2) {
|
||||||
|
for (var i = 0; i < e.targetTouches.length; i++) {
|
||||||
|
tpCache.push(e.targetTouches[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
// Touch events have implicit capture
|
// Touch events have implicit capture
|
||||||
if (e.type === "mousedown") {
|
if (e.type === "mousedown") {
|
||||||
setCapture(this._target);
|
setCapture(this._target);
|
||||||
|
|
@ -195,11 +207,44 @@ Mouse.prototype = {
|
||||||
},
|
},
|
||||||
|
|
||||||
_handleMouseMove: function (e) {
|
_handleMouseMove: function (e) {
|
||||||
|
this._handlePinchZoom(e);
|
||||||
this._updateMousePosition(e);
|
this._updateMousePosition(e);
|
||||||
this.onmousemove(this._pos.x, this._pos.y);
|
this.onmousemove(this._pos.x, this._pos.y);
|
||||||
stopEvent(e);
|
stopEvent(e);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_handlePinchZoom: function (e) {
|
||||||
|
if(e.targetTouches) {
|
||||||
|
if (e.targetTouches.length == 2 && e.changedTouches.length == 2) {
|
||||||
|
// Check if the two target touches are the same ones that started
|
||||||
|
// the 2-touch
|
||||||
|
var point1 = -1, point2 = -1;
|
||||||
|
for (var i = 0; i < tpCache.length; i++) {
|
||||||
|
if (tpCache[i].identifier == e.targetTouches[0].identifier) point1 = i;
|
||||||
|
if (tpCache[i].identifier == e.targetTouches[1].identifier) point2 = i;
|
||||||
|
}
|
||||||
|
if (point1 >= 0 && point2 >= 0) {
|
||||||
|
var tpDist = Math.abs(e.targetTouches[0].clientX - e.targetTouches[1].clientX);
|
||||||
|
|
||||||
|
if (tpTreshold == null) {
|
||||||
|
tpTreshold = tpDist;
|
||||||
|
}
|
||||||
|
this._accumulatedWheelDeltaY = tpTreshold - tpDist;
|
||||||
|
if (Math.abs(this._accumulatedWheelDeltaY) > WHEEL_STEP) {
|
||||||
|
this._generateWheelStepY();
|
||||||
|
} else {
|
||||||
|
this._wheelStepYTimer = window.setTimeout(this._generateWheelStepY.bind(this), WHEEL_STEP_TIMEOUT);
|
||||||
|
}
|
||||||
|
tpTreshold = tpDist;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// empty tpCache
|
||||||
|
tpCache = new Array();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
_handleMouseDisable: function (e) {
|
_handleMouseDisable: function (e) {
|
||||||
/*
|
/*
|
||||||
* Stop propagation if inside canvas area
|
* Stop propagation if inside canvas area
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue