@@ -21,7 +21,6 @@ const NO_TRANSITION_PROPS = {
2121const DEFAULT_INERTIA = 300 ;
2222const INERTIA_EASING = t => 1 - ( 1 - t ) * ( 1 - t ) ;
2323const MAX_PINCH_ZOOM_DELTA_PER_EVENT = 0.18 ;
24- const MAX_PINCH_INERTIA_ZOOM_DELTA = 0.35 ;
2524
2625const EVENT_TYPES = {
2726 WHEEL : [ 'wheel' ] ,
@@ -655,9 +654,7 @@ export default abstract class Controller<ControllerState extends IViewState<Cont
655654 const newControllerState = this . controllerState . zoomStart ( { pos} ) . rotateStart ( { pos} ) ;
656655 // hack - hammer's `rotation` field doesn't seem to produce the correct angle
657656 pinchEventWorkaround . _startPinchRotation = event . rotation ;
658- pinchEventWorkaround . _lastPinchEvent = event ;
659657 pinchEventWorkaround . _smoothedPinchScaleLog = 0 ;
660- pinchEventWorkaround . _lastPinchScaleLog = 0 ;
661658 this . updateViewport ( newControllerState , NO_TRANSITION_PROPS , { isDragging : true } ) ;
662659 return true ;
663660 }
@@ -679,7 +676,6 @@ export default abstract class Controller<ControllerState extends IViewState<Cont
679676 const previousScaleLog = pinchEventWorkaround . _smoothedPinchScaleLog ?? 0 ;
680677 const smoothedScaleLog =
681678 previousScaleLog + clampPinchZoomDelta ( rawScaleLog - previousScaleLog ) ;
682- pinchEventWorkaround . _lastPinchScaleLog = previousScaleLog ;
683679 pinchEventWorkaround . _smoothedPinchScaleLog = smoothedScaleLog ;
684680 newControllerState = newControllerState . zoom ( { pos, scale : Math . pow ( 2 , smoothedScaleLog ) } ) ;
685681 }
@@ -696,59 +692,22 @@ export default abstract class Controller<ControllerState extends IViewState<Cont
696692 isZooming : this . touchZoom ,
697693 isRotating : this . touchRotate
698694 } ) ;
699- pinchEventWorkaround . _lastPinchEvent = event ;
700695 return true ;
701696 }
702697
703698 protected _onPinchEnd ( event : MjolnirGestureEvent ) : boolean {
704699 if ( ! this . isDragging ( ) ) {
705700 return false ;
706701 }
707- const { inertia} = this ;
708- const { _lastPinchEvent} = pinchEventWorkaround ;
709- if ( this . touchZoom && inertia && _lastPinchEvent && event . scale !== _lastPinchEvent . scale ) {
710- const pos = this . getCenter ( event ) ;
711- let newControllerState = this . controllerState . rotateEnd ( ) ;
712- const z = pinchEventWorkaround . _smoothedPinchScaleLog ?? Math . log2 ( event . scale ) ;
713- const lastZ = pinchEventWorkaround . _lastPinchScaleLog ?? Math . log2 ( _lastPinchEvent . scale ) ;
714- const deltaTime = Math . max ( 16 , event . deltaTime - _lastPinchEvent . deltaTime ) ;
715- const velocityZ =
716- ( z - lastZ ) / deltaTime ;
717- const inertiaZoomDelta = Math . max (
718- - MAX_PINCH_INERTIA_ZOOM_DELTA ,
719- Math . min ( MAX_PINCH_INERTIA_ZOOM_DELTA , ( velocityZ * inertia ) / 2 )
720- ) ;
721- const endScale = Math . pow ( 2 , z + inertiaZoomDelta ) ;
722- newControllerState = newControllerState . zoom ( { pos, scale : endScale } ) . zoomEnd ( ) ;
723-
724- this . updateViewport (
725- newControllerState ,
726- {
727- ...this . _getTransitionProps ( { around : pos } ) ,
728- transitionDuration : inertia ,
729- transitionEasing : INERTIA_EASING
730- } ,
731- {
732- isDragging : false ,
733- isPanning : this . touchZoom ,
734- isZooming : this . touchZoom ,
735- isRotating : false
736- }
737- ) ;
738- this . blockEvents ( inertia ) ;
739- } else {
740- const newControllerState = this . controllerState . zoomEnd ( ) . rotateEnd ( ) ;
741- this . updateViewport ( newControllerState , null , {
742- isDragging : false ,
743- isPanning : false ,
744- isZooming : false ,
745- isRotating : false
746- } ) ;
747- }
702+ const newControllerState = this . controllerState . zoomEnd ( ) . rotateEnd ( ) ;
703+ this . updateViewport ( newControllerState , null , {
704+ isDragging : false ,
705+ isPanning : false ,
706+ isZooming : false ,
707+ isRotating : false
708+ } ) ;
748709 pinchEventWorkaround . _startPinchRotation = null ;
749- pinchEventWorkaround . _lastPinchEvent = null ;
750710 pinchEventWorkaround . _smoothedPinchScaleLog = null ;
751- pinchEventWorkaround . _lastPinchScaleLog = null ;
752711 return true ;
753712 }
754713
0 commit comments