@egjs/flicking 4.12.1-beta.2 → 4.12.1-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/declaration/control/Control.d.ts +1 -1
- package/dist/flicking.cjs.js +11 -9
- package/dist/flicking.cjs.js.map +1 -1
- package/dist/flicking.esm.js +11 -9
- package/dist/flicking.esm.js.map +1 -1
- package/dist/flicking.js +11 -9
- package/dist/flicking.js.map +1 -1
- package/dist/flicking.min.js +2 -2
- package/dist/flicking.min.js.map +1 -1
- package/dist/flicking.pkgd.js +11 -9
- package/dist/flicking.pkgd.js.map +1 -1
- package/dist/flicking.pkgd.min.js +2 -2
- package/dist/flicking.pkgd.min.js.map +1 -1
- package/package.json +1 -1
- package/src/control/Control.ts +1 -1
- package/src/control/SnapControl.ts +11 -7
package/package.json
CHANGED
package/src/control/Control.ts
CHANGED
|
@@ -397,7 +397,7 @@ abstract class Control {
|
|
|
397
397
|
}
|
|
398
398
|
}
|
|
399
399
|
|
|
400
|
-
|
|
400
|
+
protected _getPosition(panel: Panel, direction: ValueOf<typeof DIRECTION> = DIRECTION.NONE) {
|
|
401
401
|
const flicking = getFlickingAttached(this._flicking);
|
|
402
402
|
const camera = flicking.camera;
|
|
403
403
|
|
|
@@ -9,6 +9,7 @@ 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";
|
|
12
13
|
|
|
13
14
|
import Control from "./Control";
|
|
14
15
|
|
|
@@ -111,7 +112,6 @@ class SnapControl extends Control {
|
|
|
111
112
|
targetAnchor = this._findSnappedAnchor(position, anchorAtCamera);
|
|
112
113
|
} else if (absPosDelta >= flicking.threshold && absPosDelta > 0 && anchorAtCamera === activeAnchor) {
|
|
113
114
|
// Move to the adjacent panel
|
|
114
|
-
// console.log("moveToPosition anchorAtCamera activeAnchor absPosDelta", camera.position, anchorAtCamera, activeAnchor, absPosDelta, snapThreshold)
|
|
115
115
|
targetAnchor = this._findAdjacentAnchor(position, posDelta, anchorAtCamera);
|
|
116
116
|
} else {
|
|
117
117
|
// Fallback to nearest panel from current camera
|
|
@@ -121,12 +121,16 @@ class SnapControl extends Control {
|
|
|
121
121
|
});
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
|
|
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);
|
|
125
129
|
|
|
126
130
|
return this._animateToPosition({
|
|
127
|
-
position: camera.clampToReachablePosition(
|
|
131
|
+
position: camera.clampToReachablePosition(nextPosition),
|
|
128
132
|
duration,
|
|
129
|
-
newActivePanel:
|
|
133
|
+
newActivePanel: nextPanel,
|
|
130
134
|
axesEvent
|
|
131
135
|
});
|
|
132
136
|
}
|
|
@@ -139,14 +143,15 @@ class SnapControl extends Control {
|
|
|
139
143
|
const currentPos = camera.position;
|
|
140
144
|
|
|
141
145
|
const clampedPosition = camera.clampToReachablePosition(position);
|
|
146
|
+
const nearestAnchor = camera.findNearestAnchor(clampedPosition);
|
|
142
147
|
const anchorAtPosition = camera.findAnchorIncludePosition(clampedPosition);
|
|
143
148
|
|
|
144
|
-
if (!anchorAtCamera || !anchorAtPosition) {
|
|
149
|
+
if (!anchorAtCamera || !anchorAtPosition || !nearestAnchor) {
|
|
145
150
|
throw new FlickingError(ERROR.MESSAGE.POSITION_NOT_REACHABLE(position), ERROR.CODE.POSITION_NOT_REACHABLE);
|
|
146
151
|
}
|
|
147
152
|
|
|
148
153
|
if (!isFinite(count)) {
|
|
149
|
-
return
|
|
154
|
+
return nearestAnchor;
|
|
150
155
|
}
|
|
151
156
|
|
|
152
157
|
const panelCount = flicking.panelCount;
|
|
@@ -206,7 +211,6 @@ class SnapControl extends Control {
|
|
|
206
211
|
}
|
|
207
212
|
}
|
|
208
213
|
|
|
209
|
-
// console.log("_findAdjacentAnchor", position, posDelta, anchorAtCamera)
|
|
210
214
|
const adjacentAnchor = (posDelta > 0 ? camera.getNextAnchor(anchorAtCamera) : camera.getPrevAnchor(anchorAtCamera)) ?? anchorAtCamera;
|
|
211
215
|
|
|
212
216
|
return adjacentAnchor;
|