onPointerUp method

void onPointerUp(
  1. dynamic event
)

Implementation

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

    for (int i = 0; i < nTouch; i++) {
      if (_touchCurrent[i].pointerId == event.pointerId) {
        _touchCurrent.removeAt(i);
        _touchStart.removeAt(i);
        break;
      }
    }

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

        //singleEnd
        domElement.removeEventListener(PeripheralType.pointermove, onPointerMove);
        domElement.removeEventListener(PeripheralType.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(PeripheralType.pointermove, onPointerMove);
          domElement.removeEventListener(PeripheralType.pointerup, onPointerUp);

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

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

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

  if (event.isPrimary) {
    if (_downValid) {
      final 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 {
          final clickInterval = event.timeStamp - _clickStart;
          final 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.clear();
            onDoubleTap(event);
          } else {
            //'first click'
            _nclicks = 1;
            _downEvents.removeAt(0);
            _clickStart = DateTime.now().millisecondsSinceEpoch;
          }
        }
      } else {
        _downValid = false;
        _nclicks = 0;
        _downEvents.clear();
      }
    } else {
      _nclicks = 0;
      _downEvents.clear();
    }
  }
}