onTouchStart method

dynamic onTouchStart(
  1. dynamic event
)

Implementation

onTouchStart(event) {
  trackPointer(event);

  switch (_pointers.length) {
    case 1:
      _state = State.touchRotate;
      _moveCurr.copy(getMouseOnCircle(_pointers[0].pageX, _pointers[0].pageY));
      _movePrev.copy(_moveCurr);
      break;

    default: // 2 or more
      _state = State.touchZoomPan;
      var dx = _pointers[0].pageX - _pointers[1].pageX;
      var dy = _pointers[0].pageY - _pointers[1].pageY;
      _touchZoomDistanceEnd = _touchZoomDistanceStart = Math.sqrt(dx * dx + dy * dy);

      var x = (_pointers[0].pageX + _pointers[1].pageX) / 2;
      var y = (_pointers[0].pageY + _pointers[1].pageY) / 2;
      _panStart.copy(getMouseOnScreen(x, y));
      _panEnd.copy(_panStart);
      break;
  }

  scope.dispatchEvent(_startEvent);
}