onPointerUp method

dynamic onPointerUp(
  1. dynamic event
)

Implementation

onPointerUp(event) {
  if (event.pointerType == 'touch' && _input != Input.cursor) {
    var nTouch = _touchCurrent.length;

    for (var i = 0; i < nTouch; i++) {
      if (_touchCurrent[i].pointerId == event.pointerId) {
        _touchCurrent.splice(i, 1);
        _touchStart.splice(i, 1);
        break;
      }
    }

    switch (_input) {
      case Input.oneFinger:
      case Input.oneFingerSwitched:

        //singleEnd
        domElement.removeEventListener('pointermove', onPointerMove);
        domElement.removeEventListener('pointerup', onPointerUp);

        _input = Input.none;
        onSinglePanEnd();

        break;

      case Input.twoFinger:

        //doubleEnd
        onDoublePanEnd(event);
        onPinchEnd(event);
        onRotateEnd(event);

        //switching to singleStart
        _input = Input.oneFingerSwitched;

        break;

      case Input.multiFinger:
        if (_touchCurrent.isEmpty) {
          domElement.removeEventListener('pointermove', onPointerMove);
          domElement.removeEventListener('pointerup', onPointerUp);

          //multCancel
          _input = Input.none;
          onTriplePanEnd();
        }

        break;
    }
  } else if (event.pointerType != 'touch' && _input == Input.cursor) {
    domElement.removeEventListener('pointermove', onPointerMove);
    domElement.removeEventListener('pointerup', onPointerUp);

    _input = Input.none;
    onSinglePanEnd();
    _button = -1;
  }

  if (event.isPrimary) {
    if (_downValid) {
      var downTime = event.timeStamp - _downEvents[_downEvents.length - 1].timeStamp;

      if (downTime <= _maxDownTime) {
        if (_nclicks == 0) {
          //first valid click detected
          _nclicks = 1;
          _clickStart = DateTime.now().millisecondsSinceEpoch;
        } else {
          var clickInterval = event.timeStamp - _clickStart;
          var movement = calculatePointersDistance(_downEvents[1], _downEvents[0]) * _devPxRatio;

          if (clickInterval <= _maxInterval && movement <= _posThreshold) {
            //second valid click detected
            //fire double tap and reset values
            _nclicks = 0;
            _downEvents.splice(0, _downEvents.length);
            onDoubleTap(event);
          } else {
            //new 'first click'
            _nclicks = 1;
            _downEvents.removeAt(0);
            _clickStart = DateTime.now().millisecondsSinceEpoch;
          }
        }
      } else {
        _downValid = false;
        _nclicks = 0;
        _downEvents.splice(0, _downEvents.length);
      }
    } else {
      _nclicks = 0;
      _downEvents.splice(0, _downEvents.length);
    }
  }
}