onSinglePanEnd method

dynamic onSinglePanEnd()

Implementation

onSinglePanEnd() {
  if (_state == State2.rotate) {
    if (!enableRotate) {
      return;
    }

    if (enableAnimations) {
      //perform rotation animation
      var deltaTime = (DateTime.now().millisecondsSinceEpoch - _timeCurrent);
      if (deltaTime < 120) {
        var w = Math.abs((_wPrev + _wCurr) / 2);

        var self = this;
        _animationId = requestAnimationFrame((t) {
          self.updateTbState(State2.animationRotate, true);
          var rotationAxis = self.calculateRotationAxis(self._cursorPosPrev, self._cursorPosCurr);

          self.onRotationAnim(t, rotationAxis, Math.min(w, self.wMax));
        });
      } else {
        //cursor has been standing still for over 120 ms since last movement
        updateTbState(State2.idle, false);
        activateGizmos(false);
        dispatchEvent(_changeEvent);
      }
    } else {
      updateTbState(State2.idle, false);
      activateGizmos(false);
      dispatchEvent(_changeEvent);
    }
  } else if (_state == State2.pan || _state == State2.idle) {
    updateTbState(State2.idle, false);

    if (enableGrid) {
      disposeGrid();
    }

    activateGizmos(false);
    dispatchEvent(_changeEvent);
  }

  dispatchEvent(_endEvent);
}