@@ -9,7 +9,6 @@ import AnchorPoint from "../core/AnchorPoint";
99import { circulateIndex , clamp , getFlickingAttached } from "../utils" ;
1010import * as AXES from "../const/axes" ;
1111import * as ERROR from "../const/error" ;
12- import { DIRECTION } from "../const/external" ;
1312
1413import Control from "./Control" ;
1514
@@ -121,16 +120,12 @@ class SnapControl extends Control {
121120 } ) ;
122121 }
123122
124- const nextPanel = targetAnchor . panel ;
125- const direction = ( posDelta === 0 || activeAnchor === targetAnchor ) ? DIRECTION . NONE : ( posDelta > 0 ? DIRECTION . NEXT : DIRECTION . PREV ) ;
126- const nextPosition = this . _getPosition ( nextPanel , direction ) ;
127-
128- this . _triggerIndexChangeEvent ( nextPanel , position , axesEvent ) ;
123+ this . _triggerIndexChangeEvent ( targetAnchor . panel , position , axesEvent ) ;
129124
130125 return this . _animateToPosition ( {
131- position : camera . clampToReachablePosition ( nextPosition ) ,
126+ position : camera . clampToReachablePosition ( targetAnchor . position ) ,
132127 duration,
133- newActivePanel : nextPanel ,
128+ newActivePanel : targetAnchor . panel ,
134129 axesEvent
135130 } ) ;
136131 }
@@ -143,15 +138,14 @@ class SnapControl extends Control {
143138 const currentPos = camera . position ;
144139
145140 const clampedPosition = camera . clampToReachablePosition ( position ) ;
146- const nearestAnchor = camera . findNearestAnchor ( clampedPosition ) ;
147141 const anchorAtPosition = camera . findAnchorIncludePosition ( clampedPosition ) ;
148142
149- if ( ! anchorAtCamera || ! anchorAtPosition || ! nearestAnchor ) {
143+ if ( ! anchorAtCamera || ! anchorAtPosition ) {
150144 throw new FlickingError ( ERROR . MESSAGE . POSITION_NOT_REACHABLE ( position ) , ERROR . CODE . POSITION_NOT_REACHABLE ) ;
151145 }
152146
153147 if ( ! isFinite ( count ) ) {
154- return nearestAnchor ;
148+ return anchorAtPosition ;
155149 }
156150
157151 const panelCount = flicking . panelCount ;
0 commit comments