@egjs/flicking 4.14.2-beta.0 → 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.2-beta.0
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) {
@@ -2443,8 +2447,8 @@ var AxesController = /*#__PURE__*/function () {
2443
2447
  });
2444
2448
  };
2445
2449
  /**
2446
- * 현재
2447
- * @returns
2450
+ * Returns the current axes position
2451
+ * @ko 현재 axes의 position을 반환합니다.
2448
2452
  */
2449
2453
  __proto.getCurrentPosition = function () {
2450
2454
  var _a, _b;
@@ -2792,7 +2796,7 @@ var Control = /*#__PURE__*/function () {
2792
2796
  return __generator(this, function (_b) {
2793
2797
  flicking = getFlickingAttached(this._flicking);
2794
2798
  nextDuration = duration;
2795
- if (Math.abs(nextDuration - position) < 0.5) {
2799
+ if (Math.abs(nextDuration - position) < flicking.animationThreshold) {
2796
2800
  nextDuration = 0;
2797
2801
  }
2798
2802
  animate = function () {
@@ -2826,6 +2830,7 @@ var Control = /*#__PURE__*/function () {
2826
2830
  });
2827
2831
  });
2828
2832
  };
2833
+
2829
2834
  __proto._getPosition = function (panel, direction) {
2830
2835
  if (direction === void 0) {
2831
2836
  direction = DIRECTION.NONE;
@@ -4751,6 +4756,17 @@ var Renderer = /*#__PURE__*/function () {
4751
4756
  });
4752
4757
  return Promise.resolve();
4753
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
+ };
4754
4770
  /**
4755
4771
  * Update all panel sizes
4756
4772
  * @ko 모든 패널의 크기를 업데이트합니다
@@ -5111,6 +5127,13 @@ var Renderer = /*#__PURE__*/function () {
5111
5127
  __proto._afterRender = function () {
5112
5128
  var flicking = getFlickingAttached(this._flicking);
5113
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
+ }
5114
5137
  };
5115
5138
  return Renderer;
5116
5139
  }();
@@ -5139,6 +5162,7 @@ var VanillaRenderer = /*#__PURE__*/function (_super) {
5139
5162
  });
5140
5163
  });
5141
5164
  };
5165
+
5142
5166
  __proto._collectPanels = function () {
5143
5167
  var flicking = getFlickingAttached(this._flicking);
5144
5168
  var camera = flicking.camera;
@@ -5152,7 +5176,15 @@ var VanillaRenderer = /*#__PURE__*/function (_super) {
5152
5176
  var flicking = getFlickingAttached(this._flicking);
5153
5177
  var cameraEl = flicking.camera.element;
5154
5178
  // We're using reversed panels here as last panel should be the last element of camera element
5155
- 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
+ }
5156
5188
  reversedElements.forEach(function (el, idx) {
5157
5189
  var nextEl = reversedElements[idx - 1] ? reversedElements[idx - 1] : null;
5158
5190
  if (el.nextElementSibling !== nextEl) {
@@ -6215,7 +6247,11 @@ var Flicking = /*#__PURE__*/function (_super) {
6215
6247
  _15 = _b.renderExternal,
6216
6248
  renderExternal = _15 === void 0 ? null : _15,
6217
6249
  _16 = _b.optimizeSizeUpdate,
6218
- 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;
6219
6255
  var _this = _super.call(this) || this;
6220
6256
  // Internal states
6221
6257
  _this._initialized = false;
@@ -6261,6 +6297,8 @@ var Flicking = /*#__PURE__*/function (_super) {
6261
6297
  _this._externalRenderer = externalRenderer;
6262
6298
  _this._renderExternal = renderExternal;
6263
6299
  _this._optimizeSizeUpdate = optimizeSizeUpdate;
6300
+ _this._animationThreshold = animationThreshold;
6301
+ _this._useCSSOrderProperty = useCSSOrderProperty;
6264
6302
  // Create core components
6265
6303
  _this._viewport = new Viewport(_this, getElement(root));
6266
6304
  _this._autoResizer = new AutoResizer(_this);
@@ -6972,6 +7010,43 @@ var Flicking = /*#__PURE__*/function (_super) {
6972
7010
  enumerable: false,
6973
7011
  configurable: true
6974
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
+ });
6975
7050
  Object.defineProperty(__proto, "interruptable", {
6976
7051
  /**
6977
7052
  * Set animation to be interruptable by click/touch.
@@ -7860,6 +7935,7 @@ var Flicking = /*#__PURE__*/function (_super) {
7860
7935
  if (!this._initialized) {
7861
7936
  return [2 /*return*/];
7862
7937
  }
7938
+
7863
7939
  renderer.updatePanelSize();
7864
7940
  camera.updateAlignPos();
7865
7941
  camera.updateRange();
@@ -7873,6 +7949,7 @@ var Flicking = /*#__PURE__*/function (_super) {
7873
7949
  if (!this._initialized) {
7874
7950
  return [2 /*return*/];
7875
7951
  }
7952
+
7876
7953
  if (control.animating) ; else {
7877
7954
  control.updatePosition(prevProgressInPanel);
7878
7955
  control.updateInput();
@@ -8110,7 +8187,7 @@ var Flicking = /*#__PURE__*/function (_super) {
8110
8187
  * Flicking.VERSION; // ex) 4.0.0
8111
8188
  * ```
8112
8189
  */
8113
- Flicking.VERSION = "4.14.2-beta.0";
8190
+ Flicking.VERSION = "4.14.2-beta.1";
8114
8191
  return Flicking;
8115
8192
  }(Component);
8116
8193
 
@@ -8626,13 +8703,16 @@ var getRenderingPanels = (function (flicking, diffResult) {
8626
8703
  map[prev] = current;
8627
8704
  return map;
8628
8705
  }, {});
8629
- return __spread(flicking.panels.filter(function (panel) {
8706
+ var renderingPanels = flicking.panels.filter(function (panel) {
8630
8707
  return !removedPanels[panel.index];
8631
- })
8632
- // Sort panels by position
8633
- .sort(function (panel1, panel2) {
8634
- return panel1.position + panel1.offset - (panel2.position + panel2.offset);
8635
- }).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) {
8636
8716
  return diffResult.list[maintainedMap[panel.index]];
8637
8717
  }), diffResult.added.map(function (idx) {
8638
8718
  return diffResult.list[idx];