down method

void down(
  1. PointerDownEvent e
)

Implementation

void down(PointerDownEvent e) {
  final onMarker = _onMarker;
  _onMarker = false;
  if (options.keyboard) focus.requestFocus();
  target.stop();
  _fingers[e.pointer] = e.localPosition;
  _downAt[e.pointer] = e.timeStamp;
  _most = math.max(_most, _fingers.length);
  _longPress?.cancel();
  if (_fingers.length == 1) {
    _markerTouch = onMarker;
    _moved = false;
    final last = _tapUpAt;
    _secondTap =
        (_tapZooms || _pinchZooms) &&
        !onMarker &&
        last != null &&
        e.timeStamp - last < _doubleTapGap &&
        (e.localPosition - _tapUpPosition).distance < _doubleTapReach;
    final mouse = e.kind == PointerDeviceKind.mouse;
    final keys = HardwareKeyboard.instance;
    if (_secondTap) {
      _gesture = _Gesture.quickZoom;
      _quickAnchor = e.localPosition;
      _quickStartZoom = target.zoom;
      _zoomOutTap = mouse && keys.isShiftPressed;
    } else if (mouse &&
        (e.buttons & kSecondaryMouseButton != 0 ||
            e.buttons & kPrimaryMouseButton != 0 && keys.isControlPressed)) {
      _gesture = _Gesture.turnTilt;
      if (options.dragRotate) _holdContextMenu();
    } else if (mouse &&
        options.boxZoom &&
        !onMarker &&
        e.buttons & kPrimaryMouseButton != 0 &&
        keys.isShiftPressed) {
      _gesture = _Gesture.box;
      _boxStart = e.localPosition;
    }
    if (mouse) cursor.value = SystemMouseCursors.grabbing;
    final onLongPress = this.onLongPress;
    if (onLongPress != null && !onMarker) {
      final at = e.localPosition;
      _longPress = Timer(_longPressTime, () {
        if (_disposed || _moved || _fingers.length != 1) return;
        _longPressed = true;
        onLongPress(at);
      });
    }
  } else {
    _secondTap = false;
    if (_gesture == _Gesture.quickZoom) _gesture = _Gesture.undecided;
  }
  _longPressed = false;
  final keep = _gesture;
  _restart(e.timeStamp, fresh: _fingers.length == 1);
  if (keep == _Gesture.box && _fingers.length == 1) _gesture = keep;
}