@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.
@@ -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
  import Component, { ComponentEvent } from '@egjs/component';
10
10
  import Axes, { PanInput } from '@egjs/axes';
@@ -25,7 +25,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
25
25
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
26
26
  PERFORMANCE OF THIS SOFTWARE.
27
27
  ***************************************************************************** */
28
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
28
+ /* global Reflect, Promise, SuppressedError, Symbol */
29
29
 
30
30
  var extendStatics = function (d, b) {
31
31
  extendStatics = Object.setPrototypeOf || {
@@ -95,8 +95,12 @@ function __generator(thisArg, body) {
95
95
  f,
96
96
  y,
97
97
  t,
98
- g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
99
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function () {
98
+ g;
99
+ return g = {
100
+ next: verb(0),
101
+ "throw": verb(1),
102
+ "return": verb(2)
103
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
100
104
  return this;
101
105
  }), g;
102
106
  function verb(n) {
@@ -953,6 +957,9 @@ var Viewport = /*#__PURE__*/function () {
953
957
  * @ko autoResize 옵션을 사용할 때 크기 변화를 감지하고 Flicking의 resize를 호출하는 컴포넌트
954
958
  */
955
959
  var AutoResizer = /*#__PURE__*/function () {
960
+ /**
961
+ * @param flicking
962
+ */
956
963
  function AutoResizer(flicking) {
957
964
  var _this = this;
958
965
  this._onResizeWrapper = function () {
@@ -2395,7 +2402,7 @@ var AxesController = /*#__PURE__*/function () {
2395
2402
  if (!axes) {
2396
2403
  return Promise.reject(new FlickingError(MESSAGE.NOT_ATTACHED_TO_FLICKING, CODE.NOT_ATTACHED_TO_FLICKING));
2397
2404
  }
2398
- var startPos = axes.get([POSITION_KEY])[POSITION_KEY];
2405
+ var startPos = this.getCurrentPosition();
2399
2406
  if (startPos === position) {
2400
2407
  var flicking = getFlickingAttached(this._flicking);
2401
2408
  flicking.camera.lookAt(position);
@@ -2439,6 +2446,14 @@ var AxesController = /*#__PURE__*/function () {
2439
2446
  animate();
2440
2447
  });
2441
2448
  };
2449
+ /**
2450
+ * Returns the current axes position
2451
+ * @ko 현재 axes의 position을 반환합니다.
2452
+ */
2453
+ __proto.getCurrentPosition = function () {
2454
+ var _a, _b;
2455
+ return (_b = (_a = this._axes) === null || _a === void 0 ? void 0 : _a.get([POSITION_KEY])[POSITION_KEY]) !== null && _b !== void 0 ? _b : 0;
2456
+ };
2442
2457
  __proto.updateDirection = function () {
2443
2458
  var flicking = getFlickingAttached(this._flicking);
2444
2459
  var axes = this._axes;
@@ -2776,16 +2791,20 @@ var Control = /*#__PURE__*/function () {
2776
2791
  newActivePanel = _a.newActivePanel,
2777
2792
  axesEvent = _a.axesEvent;
2778
2793
  return __awaiter(this, void 0, void 0, function () {
2779
- var flicking, animate, state;
2794
+ var flicking, nextDuration, animate, state;
2780
2795
  var _this = this;
2781
2796
  return __generator(this, function (_b) {
2782
2797
  flicking = getFlickingAttached(this._flicking);
2798
+ nextDuration = duration;
2799
+ if (Math.abs(nextDuration - position) < flicking.animationThreshold) {
2800
+ nextDuration = 0;
2801
+ }
2783
2802
  animate = function () {
2784
- return _this._controller.animateTo(position, duration, axesEvent);
2803
+ return _this._controller.animateTo(position, nextDuration, axesEvent);
2785
2804
  };
2786
2805
  state = this._controller.state;
2787
2806
  state.targetPanel = newActivePanel;
2788
- if (duration <= 0) {
2807
+ if (nextDuration <= 0) {
2789
2808
  return [2 /*return*/, animate()];
2790
2809
  } else {
2791
2810
  return [2 /*return*/, animate().then(function () {
@@ -2811,6 +2830,7 @@ var Control = /*#__PURE__*/function () {
2811
2830
  });
2812
2831
  });
2813
2832
  };
2833
+
2814
2834
  __proto._getPosition = function (panel, direction) {
2815
2835
  if (direction === void 0) {
2816
2836
  direction = DIRECTION.NONE;
@@ -3376,8 +3396,9 @@ var StrictControl = /*#__PURE__*/function (_super) {
3376
3396
  var anchors = camera.anchorPoints;
3377
3397
  var firstAnchor = anchors[0];
3378
3398
  var lastAnchor = anchors[anchors.length - 1];
3379
- var shouldBounceToFirst = position <= cameraRange.min && isBetween(firstAnchor.panel.index, indexRange.min, indexRange.max);
3380
- var shouldBounceToLast = position >= cameraRange.max && isBetween(lastAnchor.panel.index, indexRange.min, indexRange.max);
3399
+ // position bounce으로 인하여 범위를 넘어가야 동작하도록 변경
3400
+ var shouldBounceToFirst = position < cameraRange.min && isBetween(firstAnchor.panel.index, indexRange.min, indexRange.max);
3401
+ var shouldBounceToLast = position > cameraRange.max && isBetween(lastAnchor.panel.index, indexRange.min, indexRange.max);
3381
3402
  var isAdjacent = adjacentAnchor && (indexRange.min <= indexRange.max ? isBetween(adjacentAnchor.index, indexRange.min, indexRange.max) : adjacentAnchor.index >= indexRange.min || adjacentAnchor.index <= indexRange.max);
3382
3403
  if (shouldBounceToFirst || shouldBounceToLast) {
3383
3404
  // In bounce area
@@ -4735,6 +4756,17 @@ var Renderer = /*#__PURE__*/function () {
4735
4756
  });
4736
4757
  return Promise.resolve();
4737
4758
  };
4759
+ /**
4760
+ * Return Rendered Panels
4761
+ * @ko 렌더링이 된 패널을 반환합니다.
4762
+ * @return {Panel[]}
4763
+ */
4764
+ __proto.getRenderedPanels = function () {
4765
+ var flicking = getFlickingAttached(this._flicking);
4766
+ return flicking.renderer.panels.filter(function (panel) {
4767
+ return panel.rendered;
4768
+ });
4769
+ };
4738
4770
  /**
4739
4771
  * Update all panel sizes
4740
4772
  * @ko 모든 패널의 크기를 업데이트합니다
@@ -5095,6 +5127,13 @@ var Renderer = /*#__PURE__*/function () {
5095
5127
  __proto._afterRender = function () {
5096
5128
  var flicking = getFlickingAttached(this._flicking);
5097
5129
  flicking.camera.applyTransform();
5130
+ if (flicking.useCSSOrderProperty) {
5131
+ // useCSSOrderProperty를 사용하는 경우 DOM은 변화가 없지만 대신 CSS Order가 추가 된다.
5132
+ var panels_1 = flicking.panels;
5133
+ this._strategy.getRenderingIndexesByOrder(flicking).forEach(function (domIndex, index) {
5134
+ panels_1[domIndex].element.style.order = "" + index;
5135
+ });
5136
+ }
5098
5137
  };
5099
5138
  return Renderer;
5100
5139
  }();
@@ -5123,6 +5162,7 @@ var VanillaRenderer = /*#__PURE__*/function (_super) {
5123
5162
  });
5124
5163
  });
5125
5164
  };
5165
+
5126
5166
  __proto._collectPanels = function () {
5127
5167
  var flicking = getFlickingAttached(this._flicking);
5128
5168
  var camera = flicking.camera;
@@ -5136,7 +5176,15 @@ var VanillaRenderer = /*#__PURE__*/function (_super) {
5136
5176
  var flicking = getFlickingAttached(this._flicking);
5137
5177
  var cameraEl = flicking.camera.element;
5138
5178
  // We're using reversed panels here as last panel should be the last element of camera element
5139
- var reversedElements = this._strategy.getRenderingElementsByOrder(flicking).reverse();
5179
+ var reversedElements = [];
5180
+ if (flicking.useCSSOrderProperty) {
5181
+ // useCSSOrderProperty를 사용하는 경우 원본 그대로 렌더링
5182
+ reversedElements = this.getRenderedPanels().map(function (panel) {
5183
+ return panel.element;
5184
+ }).reverse();
5185
+ } else {
5186
+ reversedElements = this._strategy.getRenderingElementsByOrder(flicking).reverse();
5187
+ }
5140
5188
  reversedElements.forEach(function (el, idx) {
5141
5189
  var nextEl = reversedElements[idx - 1] ? reversedElements[idx - 1] : null;
5142
5190
  if (el.nextElementSibling !== nextEl) {
@@ -6199,7 +6247,11 @@ var Flicking = /*#__PURE__*/function (_super) {
6199
6247
  _15 = _b.renderExternal,
6200
6248
  renderExternal = _15 === void 0 ? null : _15,
6201
6249
  _16 = _b.optimizeSizeUpdate,
6202
- optimizeSizeUpdate = _16 === void 0 ? false : _16;
6250
+ optimizeSizeUpdate = _16 === void 0 ? false : _16,
6251
+ _17 = _b.animationThreshold,
6252
+ animationThreshold = _17 === void 0 ? 0.5 : _17,
6253
+ _18 = _b.useCSSOrderProperty,
6254
+ useCSSOrderProperty = _18 === void 0 ? false : _18;
6203
6255
  var _this = _super.call(this) || this;
6204
6256
  // Internal states
6205
6257
  _this._initialized = false;
@@ -6245,6 +6297,8 @@ var Flicking = /*#__PURE__*/function (_super) {
6245
6297
  _this._externalRenderer = externalRenderer;
6246
6298
  _this._renderExternal = renderExternal;
6247
6299
  _this._optimizeSizeUpdate = optimizeSizeUpdate;
6300
+ _this._animationThreshold = animationThreshold;
6301
+ _this._useCSSOrderProperty = useCSSOrderProperty;
6248
6302
  // Create core components
6249
6303
  _this._viewport = new Viewport(_this, getElement(root));
6250
6304
  _this._autoResizer = new AutoResizer(_this);
@@ -6956,6 +7010,43 @@ var Flicking = /*#__PURE__*/function (_super) {
6956
7010
  enumerable: false,
6957
7011
  configurable: true
6958
7012
  });
7013
+ Object.defineProperty(__proto, "animationThreshold", {
7014
+ /**
7015
+ * 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).
7016
+ * @ko animation이 진행되기 위한 최소한의 거리. 이동하려는 거리가 `animationThreshold`보다 적으면 애니메이션 없이(duration: 0) 즉시 이동한다.
7017
+ * @type {number}
7018
+ * @default 0.5
7019
+ * @see {@link https://naver.github.io/egjs-flicking/Options#animationThreshold animationThreshold ( Options )}
7020
+ */
7021
+ get: function () {
7022
+ return this._animationThreshold;
7023
+ },
7024
+ set: function (val) {
7025
+ this._animationThreshold = val;
7026
+ },
7027
+ enumerable: false,
7028
+ configurable: true
7029
+ });
7030
+ Object.defineProperty(__proto, "useCSSOrderProperty", {
7031
+ /**
7032
+ * 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.
7033
+ * When using `iframe`, you can prevent reloading when the DOM order changes.
7034
+ * @ko `circular`를 사용한 경우 위치에 따라 DOM의 순서가 변경된다. `useCSSOrderProperty`를 사용하면 DOM의 순서는 변경되지 않지만 `order` css가 설정되면서 화면상 순서가 바뀐다.
7035
+ * `iframe`을 사용하는 경우 DOM의 순서가 변경되면서 reload가 되는 것을 막을 수 있다.
7036
+ * @type {boolean}
7037
+ * @requires `circular`
7038
+ * @default false
7039
+ * @see {@link https://naver.github.io/egjs-flicking/Options#useCSSOrderProperty animationThreshold ( Options )}
7040
+ */
7041
+ get: function () {
7042
+ return this._useCSSOrderProperty;
7043
+ },
7044
+ set: function (val) {
7045
+ this._useCSSOrderProperty = val;
7046
+ },
7047
+ enumerable: false,
7048
+ configurable: true
7049
+ });
6959
7050
  Object.defineProperty(__proto, "interruptable", {
6960
7051
  /**
6961
7052
  * Set animation to be interruptable by click/touch.
@@ -7844,6 +7935,7 @@ var Flicking = /*#__PURE__*/function (_super) {
7844
7935
  if (!this._initialized) {
7845
7936
  return [2 /*return*/];
7846
7937
  }
7938
+
7847
7939
  renderer.updatePanelSize();
7848
7940
  camera.updateAlignPos();
7849
7941
  camera.updateRange();
@@ -7857,6 +7949,7 @@ var Flicking = /*#__PURE__*/function (_super) {
7857
7949
  if (!this._initialized) {
7858
7950
  return [2 /*return*/];
7859
7951
  }
7952
+
7860
7953
  if (control.animating) ; else {
7861
7954
  control.updatePosition(prevProgressInPanel);
7862
7955
  control.updateInput();
@@ -8094,7 +8187,7 @@ var Flicking = /*#__PURE__*/function (_super) {
8094
8187
  * Flicking.VERSION; // ex) 4.0.0
8095
8188
  * ```
8096
8189
  */
8097
- Flicking.VERSION = "4.14.1";
8190
+ Flicking.VERSION = "4.14.2-beta.1";
8098
8191
  return Flicking;
8099
8192
  }(Component);
8100
8193
 
@@ -8610,13 +8703,16 @@ var getRenderingPanels = (function (flicking, diffResult) {
8610
8703
  map[prev] = current;
8611
8704
  return map;
8612
8705
  }, {});
8613
- return __spread(flicking.panels.filter(function (panel) {
8706
+ var renderingPanels = flicking.panels.filter(function (panel) {
8614
8707
  return !removedPanels[panel.index];
8615
- })
8616
- // Sort panels by position
8617
- .sort(function (panel1, panel2) {
8618
- return panel1.position + panel1.offset - (panel2.position + panel2.offset);
8619
- }).map(function (panel) {
8708
+ });
8709
+ if (!flicking.useCSSOrderProperty) {
8710
+ // useCSSOrderProperty를 사용하게 되는 경우 sort 하지 않는다.
8711
+ renderingPanels.sort(function (panel1, panel2) {
8712
+ return panel1.position + panel1.offset - (panel2.position + panel2.offset);
8713
+ });
8714
+ }
8715
+ return __spread(renderingPanels.map(function (panel) {
8620
8716
  return diffResult.list[maintainedMap[panel.index]];
8621
8717
  }), diffResult.added.map(function (idx) {
8622
8718
  return diffResult.list[idx];