onPointerUp method
dynamic
onPointerUp(
- dynamic event
Implementation
onPointerUp(event) {
if (event.pointerType == 'touch' && this._input != INPUT.CURSOR) {
var nTouch = this._touchCurrent.length;
for (var i = 0; i < nTouch; i++) {
if (this._touchCurrent[i].pointerId == event.pointerId) {
this._touchCurrent.splice(i, 1);
this._touchStart.splice(i, 1);
break;
}
}
switch (this._input) {
case INPUT.ONE_FINGER:
case INPUT.ONE_FINGER_SWITCHED:
//singleEnd
domElement.removeEventListener('pointermove', this.onPointerMove);
domElement.removeEventListener('pointerup', this.onPointerUp);
this._input = INPUT.NONE;
this.onSinglePanEnd();
break;
case INPUT.TWO_FINGER:
//doubleEnd
this.onDoublePanEnd(event);
this.onPinchEnd(event);
this.onRotateEnd(event);
//switching to singleStart
this._input = INPUT.ONE_FINGER_SWITCHED;
break;
case INPUT.MULT_FINGER:
if (this._touchCurrent.length == 0) {
domElement.removeEventListener('pointermove', this.onPointerMove);
domElement.removeEventListener('pointerup', this.onPointerUp);
//multCancel
this._input = INPUT.NONE;
this.onTriplePanEnd();
}
break;
}
} else if (event.pointerType != 'touch' && this._input == INPUT.CURSOR) {
domElement.removeEventListener('pointermove', this.onPointerMove);
domElement.removeEventListener('pointerup', this.onPointerUp);
this._input = INPUT.NONE;
this.onSinglePanEnd();
this._button = -1;
}
if (event.isPrimary) {
if (this._downValid) {
var downTime = event.timeStamp -
this._downEvents[this._downEvents.length - 1].timeStamp;
if (downTime <= this._maxDownTime) {
if (this._nclicks == 0) {
//first valid click detected
this._nclicks = 1;
this._clickStart = DateTime.now().millisecondsSinceEpoch;
} else {
var clickInterval = event.timeStamp - this._clickStart;
var movement = this.calculatePointersDistance(
this._downEvents[1], this._downEvents[0]) *
this._devPxRatio;
if (clickInterval <= this._maxInterval &&
movement <= this._posThreshold) {
//second valid click detected
//fire double tap and reset values
this._nclicks = 0;
this._downEvents.splice(0, this._downEvents.length);
this.onDoubleTap(event);
} else {
//new 'first click'
this._nclicks = 1;
this._downEvents.removeAt(0);
this._clickStart = DateTime.now().millisecondsSinceEpoch;
}
}
} else {
this._downValid = false;
this._nclicks = 0;
this._downEvents.splice(0, this._downEvents.length);
}
} else {
this._nclicks = 0;
this._downEvents.splice(0, this._downEvents.length);
}
}
}