@egjs/flicking 4.14.1 → 4.14.2-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.
@@ -53,6 +53,8 @@ export interface FlickingOptions {
53
53
  moveType: ValueOf<typeof MOVE_TYPE> | MoveTypeOptions<ValueOf<typeof MOVE_TYPE>>;
54
54
  threshold: number;
55
55
  dragThreshold: number;
56
+ animationThreshold: number;
57
+ useCSSOrderProperty: boolean;
56
58
  interruptable: boolean;
57
59
  bounce: number | string | [number | string, number | string];
58
60
  iOSEdgeSwipeThreshold: number;
@@ -105,6 +107,8 @@ declare class Flicking extends Component<FlickingEvents> {
105
107
  private _moveType;
106
108
  private _threshold;
107
109
  private _dragThreshold;
110
+ private _animationThreshold;
111
+ private _useCSSOrderProperty;
108
112
  private _interruptable;
109
113
  private _bounce;
110
114
  private _iOSEdgeSwipeThreshold;
@@ -166,6 +170,8 @@ declare class Flicking extends Component<FlickingEvents> {
166
170
  get moveType(): FlickingOptions["moveType"];
167
171
  get threshold(): FlickingOptions["threshold"];
168
172
  get dragThreshold(): FlickingOptions["dragThreshold"];
173
+ get animationThreshold(): FlickingOptions["animationThreshold"];
174
+ get useCSSOrderProperty(): FlickingOptions["useCSSOrderProperty"];
169
175
  get interruptable(): FlickingOptions["interruptable"];
170
176
  get bounce(): FlickingOptions["bounce"];
171
177
  get iOSEdgeSwipeThreshold(): FlickingOptions["iOSEdgeSwipeThreshold"];
@@ -207,6 +213,8 @@ declare class Flicking extends Component<FlickingEvents> {
207
213
  set moveType(val: FlickingOptions["moveType"]);
208
214
  set threshold(val: FlickingOptions["threshold"]);
209
215
  set dragThreshold(val: FlickingOptions["dragThreshold"]);
216
+ set animationThreshold(val: FlickingOptions["animationThreshold"]);
217
+ set useCSSOrderProperty(val: FlickingOptions["useCSSOrderProperty"]);
210
218
  set interruptable(val: FlickingOptions["interruptable"]);
211
219
  set bounce(val: FlickingOptions["bounce"]);
212
220
  set iOSEdgeSwipeThreshold(val: FlickingOptions["iOSEdgeSwipeThreshold"]);
@@ -219,7 +227,7 @@ declare class Flicking extends Component<FlickingEvents> {
219
227
  set useResizeObserver(val: FlickingOptions["useResizeObserver"]);
220
228
  set observePanelResize(val: FlickingOptions["observePanelResize"]);
221
229
  set optimizeSizeUpdate(val: FlickingOptions["optimizeSizeUpdate"]);
222
- 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, observePanelResize, maxResizeDebounce, useFractionalSize, externalRenderer, renderExternal, optimizeSizeUpdate }?: Partial<FlickingOptions>);
230
+ 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, observePanelResize, maxResizeDebounce, useFractionalSize, externalRenderer, renderExternal, optimizeSizeUpdate, animationThreshold, useCSSOrderProperty, }?: Partial<FlickingOptions>);
223
231
  init(): Promise<void>;
224
232
  destroy(): void;
225
233
  prev(duration?: number): Promise<void>;
@@ -35,6 +35,7 @@ declare class AxesController {
35
35
  addPreventClickHandler(): this;
36
36
  removePreventClickHandler(): this;
37
37
  animateTo(position: number, duration: number, axesEvent?: OnRelease): Promise<void>;
38
+ getCurrentPosition(): number;
38
39
  updateDirection(): void;
39
40
  private _resetInternalValues;
40
41
  private _onAxesHold;
@@ -25,6 +25,7 @@ declare abstract class Renderer {
25
25
  destroy(): void;
26
26
  getPanel(index: number): Panel | null;
27
27
  forceRenderAllPanels(): Promise<void>;
28
+ getRenderedPanels(): Panel[];
28
29
  updatePanelSize(): this;
29
30
  batchInsert(...items: Array<{
30
31
  index: number;
@@ -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.14.1
7
+ version: 4.14.2-beta.1
8
8
  */
9
9
  'use strict';
10
10
 
@@ -27,7 +27,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
27
27
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
28
28
  PERFORMANCE OF THIS SOFTWARE.
29
29
  ***************************************************************************** */
30
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
30
+ /* global Reflect, Promise, SuppressedError, Symbol */
31
31
 
32
32
  var extendStatics = function (d, b) {
33
33
  extendStatics = Object.setPrototypeOf || {
@@ -97,8 +97,12 @@ function __generator(thisArg, body) {
97
97
  f,
98
98
  y,
99
99
  t,
100
- g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
101
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function () {
100
+ g;
101
+ return g = {
102
+ next: verb(0),
103
+ "throw": verb(1),
104
+ "return": verb(2)
105
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
102
106
  return this;
103
107
  }), g;
104
108
  function verb(n) {
@@ -955,6 +959,9 @@ var Viewport = /*#__PURE__*/function () {
955
959
  * @ko autoResize 옵션을 사용할 때 크기 변화를 감지하고 Flicking의 resize를 호출하는 컴포넌트
956
960
  */
957
961
  var AutoResizer = /*#__PURE__*/function () {
962
+ /**
963
+ * @param flicking
964
+ */
958
965
  function AutoResizer(flicking) {
959
966
  var _this = this;
960
967
  this._onResizeWrapper = function () {
@@ -2397,7 +2404,7 @@ var AxesController = /*#__PURE__*/function () {
2397
2404
  if (!axes) {
2398
2405
  return Promise.reject(new FlickingError(MESSAGE.NOT_ATTACHED_TO_FLICKING, CODE.NOT_ATTACHED_TO_FLICKING));
2399
2406
  }
2400
- var startPos = axes.get([POSITION_KEY])[POSITION_KEY];
2407
+ var startPos = this.getCurrentPosition();
2401
2408
  if (startPos === position) {
2402
2409
  var flicking = getFlickingAttached(this._flicking);
2403
2410
  flicking.camera.lookAt(position);
@@ -2441,6 +2448,14 @@ var AxesController = /*#__PURE__*/function () {
2441
2448
  animate();
2442
2449
  });
2443
2450
  };
2451
+ /**
2452
+ * Returns the current axes position
2453
+ * @ko 현재 axes의 position을 반환합니다.
2454
+ */
2455
+ __proto.getCurrentPosition = function () {
2456
+ var _a, _b;
2457
+ return (_b = (_a = this._axes) === null || _a === void 0 ? void 0 : _a.get([POSITION_KEY])[POSITION_KEY]) !== null && _b !== void 0 ? _b : 0;
2458
+ };
2444
2459
  __proto.updateDirection = function () {
2445
2460
  var flicking = getFlickingAttached(this._flicking);
2446
2461
  var axes = this._axes;
@@ -2778,16 +2793,20 @@ var Control = /*#__PURE__*/function () {
2778
2793
  newActivePanel = _a.newActivePanel,
2779
2794
  axesEvent = _a.axesEvent;
2780
2795
  return __awaiter(this, void 0, void 0, function () {
2781
- var flicking, animate, state;
2796
+ var flicking, nextDuration, animate, state;
2782
2797
  var _this = this;
2783
2798
  return __generator(this, function (_b) {
2784
2799
  flicking = getFlickingAttached(this._flicking);
2800
+ nextDuration = duration;
2801
+ if (Math.abs(nextDuration - position) < flicking.animationThreshold) {
2802
+ nextDuration = 0;
2803
+ }
2785
2804
  animate = function () {
2786
- return _this._controller.animateTo(position, duration, axesEvent);
2805
+ return _this._controller.animateTo(position, nextDuration, axesEvent);
2787
2806
  };
2788
2807
  state = this._controller.state;
2789
2808
  state.targetPanel = newActivePanel;
2790
- if (duration <= 0) {
2809
+ if (nextDuration <= 0) {
2791
2810
  return [2 /*return*/, animate()];
2792
2811
  } else {
2793
2812
  return [2 /*return*/, animate().then(function () {
@@ -2813,6 +2832,7 @@ var Control = /*#__PURE__*/function () {
2813
2832
  });
2814
2833
  });
2815
2834
  };
2835
+
2816
2836
  __proto._getPosition = function (panel, direction) {
2817
2837
  if (direction === void 0) {
2818
2838
  direction = DIRECTION.NONE;
@@ -3378,8 +3398,9 @@ var StrictControl = /*#__PURE__*/function (_super) {
3378
3398
  var anchors = camera.anchorPoints;
3379
3399
  var firstAnchor = anchors[0];
3380
3400
  var lastAnchor = anchors[anchors.length - 1];
3381
- var shouldBounceToFirst = position <= cameraRange.min && isBetween(firstAnchor.panel.index, indexRange.min, indexRange.max);
3382
- var shouldBounceToLast = position >= cameraRange.max && isBetween(lastAnchor.panel.index, indexRange.min, indexRange.max);
3401
+ // position bounce으로 인하여 범위를 넘어가야 동작하도록 변경
3402
+ var shouldBounceToFirst = position < cameraRange.min && isBetween(firstAnchor.panel.index, indexRange.min, indexRange.max);
3403
+ var shouldBounceToLast = position > cameraRange.max && isBetween(lastAnchor.panel.index, indexRange.min, indexRange.max);
3383
3404
  var isAdjacent = adjacentAnchor && (indexRange.min <= indexRange.max ? isBetween(adjacentAnchor.index, indexRange.min, indexRange.max) : adjacentAnchor.index >= indexRange.min || adjacentAnchor.index <= indexRange.max);
3384
3405
  if (shouldBounceToFirst || shouldBounceToLast) {
3385
3406
  // In bounce area
@@ -4737,6 +4758,17 @@ var Renderer = /*#__PURE__*/function () {
4737
4758
  });
4738
4759
  return Promise.resolve();
4739
4760
  };
4761
+ /**
4762
+ * Return Rendered Panels
4763
+ * @ko 렌더링이 된 패널을 반환합니다.
4764
+ * @return {Panel[]}
4765
+ */
4766
+ __proto.getRenderedPanels = function () {
4767
+ var flicking = getFlickingAttached(this._flicking);
4768
+ return flicking.renderer.panels.filter(function (panel) {
4769
+ return panel.rendered;
4770
+ });
4771
+ };
4740
4772
  /**
4741
4773
  * Update all panel sizes
4742
4774
  * @ko 모든 패널의 크기를 업데이트합니다
@@ -5097,6 +5129,13 @@ var Renderer = /*#__PURE__*/function () {
5097
5129
  __proto._afterRender = function () {
5098
5130
  var flicking = getFlickingAttached(this._flicking);
5099
5131
  flicking.camera.applyTransform();
5132
+ if (flicking.useCSSOrderProperty) {
5133
+ // useCSSOrderProperty를 사용하는 경우 DOM은 변화가 없지만 대신 CSS Order가 추가 된다.
5134
+ var panels_1 = flicking.panels;
5135
+ this._strategy.getRenderingIndexesByOrder(flicking).forEach(function (domIndex, index) {
5136
+ panels_1[domIndex].element.style.order = "" + index;
5137
+ });
5138
+ }
5100
5139
  };
5101
5140
  return Renderer;
5102
5141
  }();
@@ -5125,6 +5164,7 @@ var VanillaRenderer = /*#__PURE__*/function (_super) {
5125
5164
  });
5126
5165
  });
5127
5166
  };
5167
+
5128
5168
  __proto._collectPanels = function () {
5129
5169
  var flicking = getFlickingAttached(this._flicking);
5130
5170
  var camera = flicking.camera;
@@ -5138,7 +5178,15 @@ var VanillaRenderer = /*#__PURE__*/function (_super) {
5138
5178
  var flicking = getFlickingAttached(this._flicking);
5139
5179
  var cameraEl = flicking.camera.element;
5140
5180
  // We're using reversed panels here as last panel should be the last element of camera element
5141
- var reversedElements = this._strategy.getRenderingElementsByOrder(flicking).reverse();
5181
+ var reversedElements = [];
5182
+ if (flicking.useCSSOrderProperty) {
5183
+ // useCSSOrderProperty를 사용하는 경우 원본 그대로 렌더링
5184
+ reversedElements = this.getRenderedPanels().map(function (panel) {
5185
+ return panel.element;
5186
+ }).reverse();
5187
+ } else {
5188
+ reversedElements = this._strategy.getRenderingElementsByOrder(flicking).reverse();
5189
+ }
5142
5190
  reversedElements.forEach(function (el, idx) {
5143
5191
  var nextEl = reversedElements[idx - 1] ? reversedElements[idx - 1] : null;
5144
5192
  if (el.nextElementSibling !== nextEl) {
@@ -6201,7 +6249,11 @@ var Flicking = /*#__PURE__*/function (_super) {
6201
6249
  _15 = _b.renderExternal,
6202
6250
  renderExternal = _15 === void 0 ? null : _15,
6203
6251
  _16 = _b.optimizeSizeUpdate,
6204
- optimizeSizeUpdate = _16 === void 0 ? false : _16;
6252
+ optimizeSizeUpdate = _16 === void 0 ? false : _16,
6253
+ _17 = _b.animationThreshold,
6254
+ animationThreshold = _17 === void 0 ? 0.5 : _17,
6255
+ _18 = _b.useCSSOrderProperty,
6256
+ useCSSOrderProperty = _18 === void 0 ? false : _18;
6205
6257
  var _this = _super.call(this) || this;
6206
6258
  // Internal states
6207
6259
  _this._initialized = false;
@@ -6247,6 +6299,8 @@ var Flicking = /*#__PURE__*/function (_super) {
6247
6299
  _this._externalRenderer = externalRenderer;
6248
6300
  _this._renderExternal = renderExternal;
6249
6301
  _this._optimizeSizeUpdate = optimizeSizeUpdate;
6302
+ _this._animationThreshold = animationThreshold;
6303
+ _this._useCSSOrderProperty = useCSSOrderProperty;
6250
6304
  // Create core components
6251
6305
  _this._viewport = new Viewport(_this, getElement(root));
6252
6306
  _this._autoResizer = new AutoResizer(_this);
@@ -6958,6 +7012,43 @@ var Flicking = /*#__PURE__*/function (_super) {
6958
7012
  enumerable: false,
6959
7013
  configurable: true
6960
7014
  });
7015
+ Object.defineProperty(__proto, "animationThreshold", {
7016
+ /**
7017
+ * The minimum distance for animation to proceed. If the distance to be moved is less than `animationThreshold`, the movement proceeds immediately without animation (duration: 0).
7018
+ * @ko animation이 진행되기 위한 최소한의 거리. 이동하려는 거리가 `animationThreshold`보다 적으면 애니메이션 없이(duration: 0) 즉시 이동한다.
7019
+ * @type {number}
7020
+ * @default 0.5
7021
+ * @see {@link https://naver.github.io/egjs-flicking/Options#animationThreshold animationThreshold ( Options )}
7022
+ */
7023
+ get: function () {
7024
+ return this._animationThreshold;
7025
+ },
7026
+ set: function (val) {
7027
+ this._animationThreshold = val;
7028
+ },
7029
+ enumerable: false,
7030
+ configurable: true
7031
+ });
7032
+ Object.defineProperty(__proto, "useCSSOrderProperty", {
7033
+ /**
7034
+ * When `circular` is used, the DOM order changes depending on the position. Using `useCSSOrderProperty` does not change the DOM order, but the `order` CSS property changes the order on the screen.
7035
+ * When using `iframe`, you can prevent reloading when the DOM order changes.
7036
+ * @ko `circular`를 사용한 경우 위치에 따라 DOM의 순서가 변경된다. `useCSSOrderProperty`를 사용하면 DOM의 순서는 변경되지 않지만 `order` css가 설정되면서 화면상 순서가 바뀐다.
7037
+ * `iframe`을 사용하는 경우 DOM의 순서가 변경되면서 reload가 되는 것을 막을 수 있다.
7038
+ * @type {boolean}
7039
+ * @requires `circular`
7040
+ * @default false
7041
+ * @see {@link https://naver.github.io/egjs-flicking/Options#useCSSOrderProperty animationThreshold ( Options )}
7042
+ */
7043
+ get: function () {
7044
+ return this._useCSSOrderProperty;
7045
+ },
7046
+ set: function (val) {
7047
+ this._useCSSOrderProperty = val;
7048
+ },
7049
+ enumerable: false,
7050
+ configurable: true
7051
+ });
6961
7052
  Object.defineProperty(__proto, "interruptable", {
6962
7053
  /**
6963
7054
  * Set animation to be interruptable by click/touch.
@@ -7846,6 +7937,7 @@ var Flicking = /*#__PURE__*/function (_super) {
7846
7937
  if (!this._initialized) {
7847
7938
  return [2 /*return*/];
7848
7939
  }
7940
+
7849
7941
  renderer.updatePanelSize();
7850
7942
  camera.updateAlignPos();
7851
7943
  camera.updateRange();
@@ -7859,6 +7951,7 @@ var Flicking = /*#__PURE__*/function (_super) {
7859
7951
  if (!this._initialized) {
7860
7952
  return [2 /*return*/];
7861
7953
  }
7954
+
7862
7955
  if (control.animating) ; else {
7863
7956
  control.updatePosition(prevProgressInPanel);
7864
7957
  control.updateInput();
@@ -8096,7 +8189,7 @@ var Flicking = /*#__PURE__*/function (_super) {
8096
8189
  * Flicking.VERSION; // ex) 4.0.0
8097
8190
  * ```
8098
8191
  */
8099
- Flicking.VERSION = "4.14.1";
8192
+ Flicking.VERSION = "4.14.2-beta.1";
8100
8193
  return Flicking;
8101
8194
  }(Component);
8102
8195
 
@@ -8612,13 +8705,16 @@ var getRenderingPanels = (function (flicking, diffResult) {
8612
8705
  map[prev] = current;
8613
8706
  return map;
8614
8707
  }, {});
8615
- return __spread(flicking.panels.filter(function (panel) {
8708
+ var renderingPanels = flicking.panels.filter(function (panel) {
8616
8709
  return !removedPanels[panel.index];
8617
- })
8618
- // Sort panels by position
8619
- .sort(function (panel1, panel2) {
8620
- return panel1.position + panel1.offset - (panel2.position + panel2.offset);
8621
- }).map(function (panel) {
8710
+ });
8711
+ if (!flicking.useCSSOrderProperty) {
8712
+ // useCSSOrderProperty를 사용하게 되는 경우 sort 하지 않는다.
8713
+ renderingPanels.sort(function (panel1, panel2) {
8714
+ return panel1.position + panel1.offset - (panel2.position + panel2.offset);
8715
+ });
8716
+ }
8717
+ return __spread(renderingPanels.map(function (panel) {
8622
8718
  return diffResult.list[maintainedMap[panel.index]];
8623
8719
  }), diffResult.added.map(function (idx) {
8624
8720
  return diffResult.list[idx];