@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.
@@ -4,7 +4,7 @@ name: @egjs/flicking
4
4
  license: MIT
5
5
  author: NAVER Corp.
6
6
  repository: https://github.com/naver/egjs-flicking
7
- version: 4.12.1-beta.2
7
+ version: 4.12.1-beta.4
8
8
  */
9
9
  import Component, { ComponentEvent } from '@egjs/component';
10
10
  import Axes, { PanInput } from '@egjs/axes';
@@ -2915,7 +2915,6 @@ var SnapControl = /*#__PURE__*/function (_super) {
2915
2915
  targetAnchor = this._findSnappedAnchor(position, anchorAtCamera);
2916
2916
  } else if (absPosDelta >= flicking.threshold && absPosDelta > 0 && anchorAtCamera === activeAnchor) {
2917
2917
  // Move to the adjacent panel
2918
- // console.log("moveToPosition anchorAtCamera activeAnchor absPosDelta", camera.position, anchorAtCamera, activeAnchor, absPosDelta, snapThreshold)
2919
2918
  targetAnchor = this._findAdjacentAnchor(position, posDelta, anchorAtCamera);
2920
2919
  } else {
2921
2920
  // Fallback to nearest panel from current camera
@@ -2924,11 +2923,14 @@ var SnapControl = /*#__PURE__*/function (_super) {
2924
2923
  axesEvent: axesEvent
2925
2924
  });
2926
2925
  }
2927
- this._triggerIndexChangeEvent(targetAnchor.panel, position, axesEvent);
2926
+ var nextPanel = targetAnchor.panel;
2927
+ var direction = posDelta === 0 || activeAnchor === targetAnchor ? DIRECTION.NONE : posDelta > 0 ? DIRECTION.NEXT : DIRECTION.PREV;
2928
+ var nextPosition = this._getPosition(nextPanel, direction);
2929
+ this._triggerIndexChangeEvent(nextPanel, position, axesEvent);
2928
2930
  return this._animateToPosition({
2929
- position: camera.clampToReachablePosition(targetAnchor.position),
2931
+ position: camera.clampToReachablePosition(nextPosition),
2930
2932
  duration: duration,
2931
- newActivePanel: targetAnchor.panel,
2933
+ newActivePanel: nextPanel,
2932
2934
  axesEvent: axesEvent
2933
2935
  });
2934
2936
  };
@@ -2938,12 +2940,13 @@ var SnapControl = /*#__PURE__*/function (_super) {
2938
2940
  var count = this._count;
2939
2941
  var currentPos = camera.position;
2940
2942
  var clampedPosition = camera.clampToReachablePosition(position);
2943
+ var nearestAnchor = camera.findNearestAnchor(clampedPosition);
2941
2944
  var anchorAtPosition = camera.findAnchorIncludePosition(clampedPosition);
2942
- if (!anchorAtCamera || !anchorAtPosition) {
2945
+ if (!anchorAtCamera || !anchorAtPosition || !nearestAnchor) {
2943
2946
  throw new FlickingError(MESSAGE.POSITION_NOT_REACHABLE(position), CODE.POSITION_NOT_REACHABLE);
2944
2947
  }
2945
2948
  if (!isFinite(count)) {
2946
- return anchorAtPosition;
2949
+ return nearestAnchor;
2947
2950
  }
2948
2951
  var panelCount = flicking.panelCount;
2949
2952
  var anchors = camera.anchorPoints;
@@ -2990,7 +2993,6 @@ var SnapControl = /*#__PURE__*/function (_super) {
2990
2993
  return anchorIncludePosition;
2991
2994
  }
2992
2995
  }
2993
- // console.log("_findAdjacentAnchor", position, posDelta, anchorAtCamera)
2994
2996
  var adjacentAnchor = (_a = posDelta > 0 ? camera.getNextAnchor(anchorAtCamera) : camera.getPrevAnchor(anchorAtCamera)) !== null && _a !== void 0 ? _a : anchorAtCamera;
2995
2997
  return adjacentAnchor;
2996
2998
  };
@@ -7921,7 +7923,7 @@ var Flicking = /*#__PURE__*/function (_super) {
7921
7923
  * Flicking.VERSION; // ex) 4.0.0
7922
7924
  * ```
7923
7925
  */
7924
- Flicking.VERSION = "4.12.1-beta.2";
7926
+ Flicking.VERSION = "4.12.1-beta.4";
7925
7927
  return Flicking;
7926
7928
  }(Component);
7927
7929