@@ -9,7 +9,6 @@ import AnchorPoint from "../core/AnchorPoint";
9
9
import { circulateIndex , clamp , getFlickingAttached } from "../utils" ;
10
10
import * as AXES from "../const/axes" ;
11
11
import * as ERROR from "../const/error" ;
12
- import { DIRECTION } from "../const/external" ;
13
12
14
13
import Control from "./Control" ;
15
14
@@ -121,16 +120,12 @@ class SnapControl extends Control {
121
120
} ) ;
122
121
}
123
122
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 ) ;
129
124
130
125
return this . _animateToPosition ( {
131
- position : camera . clampToReachablePosition ( nextPosition ) ,
126
+ position : camera . clampToReachablePosition ( targetAnchor . position ) ,
132
127
duration,
133
- newActivePanel : nextPanel ,
128
+ newActivePanel : targetAnchor . panel ,
134
129
axesEvent
135
130
} ) ;
136
131
}
@@ -143,15 +138,14 @@ class SnapControl extends Control {
143
138
const currentPos = camera . position ;
144
139
145
140
const clampedPosition = camera . clampToReachablePosition ( position ) ;
146
- const nearestAnchor = camera . findNearestAnchor ( clampedPosition ) ;
147
141
const anchorAtPosition = camera . findAnchorIncludePosition ( clampedPosition ) ;
148
142
149
- if ( ! anchorAtCamera || ! anchorAtPosition || ! nearestAnchor ) {
143
+ if ( ! anchorAtCamera || ! anchorAtPosition ) {
150
144
throw new FlickingError ( ERROR . MESSAGE . POSITION_NOT_REACHABLE ( position ) , ERROR . CODE . POSITION_NOT_REACHABLE ) ;
151
145
}
152
146
153
147
if ( ! isFinite ( count ) ) {
154
- return nearestAnchor ;
148
+ return anchorAtPosition ;
155
149
}
156
150
157
151
const panelCount = flicking . panelCount ;
0 commit comments