@egjs/flicking 4.12.1-beta.3 → 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.
@@ -120,7 +120,6 @@ declare class Flicking extends Component<FlickingEvents> {
120
120
  private _renderExternal;
121
121
  private _initialized;
122
122
  private _plugins;
123
- private _isResizing;
124
123
  get control(): Control;
125
124
  get camera(): Camera;
126
125
  get renderer(): Renderer;
@@ -209,7 +208,7 @@ declare class Flicking extends Component<FlickingEvents> {
209
208
  set renderOnlyVisible(val: FlickingOptions["renderOnlyVisible"]);
210
209
  set autoResize(val: FlickingOptions["autoResize"]);
211
210
  set useResizeObserver(val: FlickingOptions["useResizeObserver"]);
212
- constructor(root: HTMLElement | string, { align, defaultIndex, horizontal, circular, circularFallback, bound, adaptive, panelsPerView, noPanelStyleOverride, resizeOnContentsReady, nested, needPanelThreshold, preventEventsBeforeInit, deceleration, duration, easing, inputType, moveType, threshold, dragThreshold, interruptable, bounce, iOSEdgeSwipeThreshold, preventClickOnDrag, preventDefaultOnDrag, disableOnInit, changeOnHold, renderOnlyVisible, virtual, autoInit, autoResize, useResizeObserver, resizeDebounce, maxResizeDebounce, useFractionalSize, externalRenderer, renderExternal, }?: Partial<FlickingOptions>);
211
+ constructor(root: HTMLElement | string, { align, defaultIndex, horizontal, circular, circularFallback, bound, adaptive, panelsPerView, noPanelStyleOverride, resizeOnContentsReady, nested, needPanelThreshold, preventEventsBeforeInit, deceleration, duration, easing, inputType, moveType, threshold, dragThreshold, interruptable, bounce, iOSEdgeSwipeThreshold, preventClickOnDrag, preventDefaultOnDrag, disableOnInit, changeOnHold, renderOnlyVisible, virtual, autoInit, autoResize, useResizeObserver, resizeDebounce, maxResizeDebounce, useFractionalSize, externalRenderer, renderExternal }?: Partial<FlickingOptions>);
213
212
  init(): Promise<void>;
214
213
  destroy(): void;
215
214
  prev(duration?: number): Promise<void>;
@@ -220,7 +219,7 @@ declare class Flicking extends Component<FlickingEvents> {
220
219
  getPanel(index: number): Panel | null;
221
220
  enableInput(): this;
222
221
  disableInput(): this;
223
- getStatus({ index, position, includePanelHTML, visiblePanelsOnly, }?: Partial<{
222
+ getStatus({ index, position, includePanelHTML, visiblePanelsOnly }?: Partial<{
224
223
  index: boolean;
225
224
  position: boolean;
226
225
  includePanelHTML: boolean;
@@ -40,6 +40,6 @@ declare abstract class Control {
40
40
  newActivePanel: Panel;
41
41
  axesEvent?: OnRelease;
42
42
  }): Promise<void>;
43
- private _getPosition;
43
+ protected _getPosition(panel: Panel, direction?: ValueOf<typeof DIRECTION>): number;
44
44
  }
45
45
  export default Control;
@@ -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.2-beta.0
7
+ version: 4.12.1-beta.4
8
8
  */
9
9
  'use strict';
10
10
 
@@ -949,25 +949,10 @@ var Viewport = /*#__PURE__*/function () {
949
949
  var AutoResizer = /*#__PURE__*/function () {
950
950
  function AutoResizer(flicking) {
951
951
  var _this = this;
952
- this._onResize = function (entries) {
952
+ this._onResize = function () {
953
953
  var flicking = _this._flicking;
954
954
  var resizeDebounce = flicking.resizeDebounce;
955
955
  var maxResizeDebounce = flicking.maxResizeDebounce;
956
- if (entries.length) {
957
- var resizeEntryInfo = entries[0].contentRect;
958
- var beforeSize = {
959
- width: flicking.viewport.width,
960
- height: flicking.viewport.height
961
- };
962
- var afterSize = {
963
- width: resizeEntryInfo.width,
964
- height: resizeEntryInfo.height
965
- };
966
- // resize 이벤트가 발생했으나 이전과 width, height의 변화가 없다면 이후 로직을 진행하지 않는다.
967
- if (beforeSize.height === afterSize.height && beforeSize.width === afterSize.width) {
968
- return;
969
- }
970
- }
971
956
  if (resizeDebounce <= 0) {
972
957
  void flicking.resize();
973
958
  } else {
@@ -993,12 +978,12 @@ var AutoResizer = /*#__PURE__*/function () {
993
978
  // eslint-disable-next-line @typescript-eslint/member-ordering
994
979
  this._skipFirstResize = function () {
995
980
  var isFirstResize = true;
996
- return function (entries) {
981
+ return function () {
997
982
  if (isFirstResize) {
998
983
  isFirstResize = false;
999
984
  return;
1000
985
  }
1001
- _this._onResize(entries);
986
+ _this._onResize();
1002
987
  };
1003
988
  }();
1004
989
  this._flicking = flicking;
@@ -1016,7 +1001,6 @@ var AutoResizer = /*#__PURE__*/function () {
1016
1001
  configurable: true
1017
1002
  });
1018
1003
  __proto.enable = function () {
1019
- var _this = this;
1020
1004
  var flicking = this._flicking;
1021
1005
  var viewport = flicking.viewport;
1022
1006
  if (this._enabled) {
@@ -1024,32 +1008,23 @@ var AutoResizer = /*#__PURE__*/function () {
1024
1008
  }
1025
1009
  if (flicking.useResizeObserver && !!window.ResizeObserver) {
1026
1010
  var viewportSizeNot0 = viewport.width !== 0 || viewport.height !== 0;
1027
- var resizeObserver = viewportSizeNot0 ? new ResizeObserver(function (entries) {
1028
- return _this._skipFirstResize(entries);
1029
- }) : new ResizeObserver(function (entries) {
1030
- return _this._onResize(entries);
1031
- });
1011
+ var resizeObserver = viewportSizeNot0 ? new ResizeObserver(this._skipFirstResize) : new ResizeObserver(this._onResize);
1032
1012
  resizeObserver.observe(flicking.viewport.element);
1033
1013
  this._resizeObserver = resizeObserver;
1034
1014
  } else {
1035
- window.addEventListener("resize", function () {
1036
- return _this._onResize([]);
1037
- });
1015
+ window.addEventListener("resize", this._onResize);
1038
1016
  }
1039
1017
  this._enabled = true;
1040
1018
  return this;
1041
1019
  };
1042
1020
  __proto.disable = function () {
1043
- var _this = this;
1044
1021
  if (!this._enabled) return this;
1045
1022
  var resizeObserver = this._resizeObserver;
1046
1023
  if (resizeObserver) {
1047
1024
  resizeObserver.disconnect();
1048
1025
  this._resizeObserver = null;
1049
1026
  } else {
1050
- window.removeEventListener("resize", function () {
1051
- return _this._onResize([]);
1052
- });
1027
+ window.removeEventListener("resize", this._onResize);
1053
1028
  }
1054
1029
  this._enabled = false;
1055
1030
  return this;
@@ -2940,7 +2915,7 @@ var SnapControl = /*#__PURE__*/function (_super) {
2940
2915
  if (snapDelta >= snapThreshold && snapDelta > 0) {
2941
2916
  // Move to anchor at position
2942
2917
  targetAnchor = this._findSnappedAnchor(position, anchorAtCamera);
2943
- } else if (absPosDelta >= flicking.threshold && absPosDelta > 0) {
2918
+ } else if (absPosDelta >= flicking.threshold && absPosDelta > 0 && anchorAtCamera === activeAnchor) {
2944
2919
  // Move to the adjacent panel
2945
2920
  targetAnchor = this._findAdjacentAnchor(position, posDelta, anchorAtCamera);
2946
2921
  } else {
@@ -2950,11 +2925,14 @@ var SnapControl = /*#__PURE__*/function (_super) {
2950
2925
  axesEvent: axesEvent
2951
2926
  });
2952
2927
  }
2953
- this._triggerIndexChangeEvent(targetAnchor.panel, position, axesEvent);
2928
+ var nextPanel = targetAnchor.panel;
2929
+ var direction = posDelta === 0 || activeAnchor === targetAnchor ? DIRECTION.NONE : posDelta > 0 ? DIRECTION.NEXT : DIRECTION.PREV;
2930
+ var nextPosition = this._getPosition(nextPanel, direction);
2931
+ this._triggerIndexChangeEvent(nextPanel, position, axesEvent);
2954
2932
  return this._animateToPosition({
2955
- position: camera.clampToReachablePosition(targetAnchor.position),
2933
+ position: camera.clampToReachablePosition(nextPosition),
2956
2934
  duration: duration,
2957
- newActivePanel: targetAnchor.panel,
2935
+ newActivePanel: nextPanel,
2958
2936
  axesEvent: axesEvent
2959
2937
  });
2960
2938
  };
@@ -2964,12 +2942,13 @@ var SnapControl = /*#__PURE__*/function (_super) {
2964
2942
  var count = this._count;
2965
2943
  var currentPos = camera.position;
2966
2944
  var clampedPosition = camera.clampToReachablePosition(position);
2945
+ var nearestAnchor = camera.findNearestAnchor(clampedPosition);
2967
2946
  var anchorAtPosition = camera.findAnchorIncludePosition(clampedPosition);
2968
- if (!anchorAtCamera || !anchorAtPosition) {
2947
+ if (!anchorAtCamera || !anchorAtPosition || !nearestAnchor) {
2969
2948
  throw new FlickingError(MESSAGE.POSITION_NOT_REACHABLE(position), CODE.POSITION_NOT_REACHABLE);
2970
2949
  }
2971
2950
  if (!isFinite(count)) {
2972
- return anchorAtPosition;
2951
+ return nearestAnchor;
2973
2952
  }
2974
2953
  var panelCount = flicking.panelCount;
2975
2954
  var anchors = camera.anchorPoints;
@@ -6136,7 +6115,6 @@ var Flicking = /*#__PURE__*/function (_super) {
6136
6115
  // Internal states
6137
6116
  _this._initialized = false;
6138
6117
  _this._plugins = [];
6139
- _this._isResizing = false;
6140
6118
  // Bind options
6141
6119
  _this._align = align;
6142
6120
  _this._defaultIndex = defaultIndex;
@@ -7676,8 +7654,6 @@ var Flicking = /*#__PURE__*/function (_super) {
7676
7654
  return __generator(this, function (_a) {
7677
7655
  switch (_a.label) {
7678
7656
  case 0:
7679
- if (this._isResizing) return [2 /*return*/];
7680
- this._isResizing = true;
7681
7657
  viewport = this._viewport;
7682
7658
  renderer = this._renderer;
7683
7659
  camera = this._camera;
@@ -7730,7 +7706,6 @@ var Flicking = /*#__PURE__*/function (_super) {
7730
7706
  sizeChanged: sizeChanged,
7731
7707
  element: viewport.element
7732
7708
  }));
7733
- this._isResizing = false;
7734
7709
  return [2 /*return*/];
7735
7710
  }
7736
7711
  });
@@ -7858,7 +7833,7 @@ var Flicking = /*#__PURE__*/function (_super) {
7858
7833
  __proto._createCamera = function () {
7859
7834
  if (this._circular && this._bound) {
7860
7835
  // eslint-disable-next-line no-console
7861
- console.warn('"circular" and "bound" option cannot be used together, ignoring bound.');
7836
+ console.warn("\"circular\" and \"bound\" option cannot be used together, ignoring bound.");
7862
7837
  }
7863
7838
  return new Camera(this, {
7864
7839
  align: this._align
@@ -7868,7 +7843,7 @@ var Flicking = /*#__PURE__*/function (_super) {
7868
7843
  var externalRenderer = this._externalRenderer;
7869
7844
  if (this._virtual && this._panelsPerView <= 0) {
7870
7845
  // eslint-disable-next-line no-console
7871
- console.warn('"virtual" and "panelsPerView" option should be used together, ignoring virtual.');
7846
+ console.warn("\"virtual\" and \"panelsPerView\" option should be used together, ignoring virtual.");
7872
7847
  }
7873
7848
  return externalRenderer ? externalRenderer : this._renderExternal ? this._createExternalRenderer() : this._createVanillaRenderer();
7874
7849
  };
@@ -7950,7 +7925,7 @@ var Flicking = /*#__PURE__*/function (_super) {
7950
7925
  * Flicking.VERSION; // ex) 4.0.0
7951
7926
  * ```
7952
7927
  */
7953
- Flicking.VERSION = "4.12.2-beta.0";
7928
+ Flicking.VERSION = "4.12.1-beta.4";
7954
7929
  return Flicking;
7955
7930
  }(Component);
7956
7931