@egjs/flicking 4.11.3-beta.0 → 4.11.3-beta.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@egjs/flicking",
3
- "version": "4.11.3-beta.0",
3
+ "version": "4.11.3-beta.1",
4
4
  "description": "Everyday 30 million people experience. It's reliable, flexible and extendable carousel.",
5
5
  "main": "dist/flicking.cjs.js",
6
6
  "module": "dist/flicking.esm.js",
@@ -404,9 +404,11 @@ class Camera {
404
404
  */
405
405
  public findActiveAnchor(): AnchorPoint | null {
406
406
  const flicking = getFlickingAttached(this._flicking);
407
- const activeIndex = flicking.control.activeIndex;
407
+ const activePanel = flicking.control.activePanel;
408
+
409
+ if (!activePanel) return null;
408
410
 
409
- return find(this._anchors, anchor => anchor.panel.index === activeIndex);
411
+ return find(this._anchors, anchor => anchor.panel.index === activePanel.index) ?? this.findNearestAnchor(activePanel.position);
410
412
  }
411
413
 
412
414
  /**
@@ -95,7 +95,7 @@ class SnapControl extends Control {
95
95
  return Promise.reject(new FlickingError(ERROR.MESSAGE.POSITION_NOT_REACHABLE(position), ERROR.CODE.POSITION_NOT_REACHABLE));
96
96
  }
97
97
 
98
- const snapThreshold = this._calcSnapThreshold(flicking.threshold, position, activeAnchor);
98
+ const snapThreshold = this._calcSnapThreshold(position, activeAnchor);
99
99
 
100
100
  const posDelta = flicking.animating
101
101
  ? state.delta
@@ -210,7 +210,7 @@ class SnapControl extends Control {
210
210
  return adjacentAnchor;
211
211
  }
212
212
 
213
- private _calcSnapThreshold(threshold: number, position: number, activeAnchor: AnchorPoint): number {
213
+ private _calcSnapThreshold(position: number, activeAnchor: AnchorPoint): number {
214
214
  const isNextDirection = position > activeAnchor.position;
215
215
  const panel = activeAnchor.panel;
216
216
  const panelSize = panel.size;
@@ -222,9 +222,9 @@ class SnapControl extends Control {
222
222
  * |<------>|<------------>|
223
223
  * [ |<-Anchor ]
224
224
  */
225
- return Math.max(threshold, isNextDirection
225
+ return isNextDirection
226
226
  ? panelSize - alignPos + panel.margin.next
227
- : alignPos + panel.margin.prev);
227
+ : alignPos + panel.margin.prev;
228
228
  }
229
229
  }
230
230