@egjs/flicking 4.14.2-beta.0 → 4.14.2-beta.2

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.
package/dist/flicking.js CHANGED
@@ -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.2
8
8
  */
9
9
  (function (global, factory) {
10
10
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@egjs/component'), require('@egjs/axes'), require('@egjs/imready'), require('@cfcs/core')) :
@@ -26,7 +26,7 @@ version: 4.14.2-beta.0
26
26
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
27
27
  PERFORMANCE OF THIS SOFTWARE.
28
28
  ***************************************************************************** */
29
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
29
+ /* global Reflect, Promise, SuppressedError, Symbol */
30
30
 
31
31
  var extendStatics = function (d, b) {
32
32
  extendStatics = Object.setPrototypeOf || {
@@ -96,8 +96,12 @@ version: 4.14.2-beta.0
96
96
  f,
97
97
  y,
98
98
  t,
99
- g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
100
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function () {
99
+ g;
100
+ return g = {
101
+ next: verb(0),
102
+ "throw": verb(1),
103
+ "return": verb(2)
104
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
101
105
  return this;
102
106
  }), g;
103
107
  function verb(n) {
@@ -2492,8 +2496,8 @@ version: 4.14.2-beta.0
2492
2496
  });
2493
2497
  };
2494
2498
  /**
2495
- * 현재
2496
- * @returns
2499
+ * Returns the current axes position
2500
+ * @ko 현재 axes의 position을 반환합니다.
2497
2501
  */
2498
2502
  __proto.getCurrentPosition = function () {
2499
2503
  var _a, _b;
@@ -2841,7 +2845,7 @@ version: 4.14.2-beta.0
2841
2845
  return __generator(this, function (_b) {
2842
2846
  flicking = getFlickingAttached(this._flicking);
2843
2847
  nextDuration = duration;
2844
- if (Math.abs(nextDuration - position) < 0.5) {
2848
+ if (Math.abs(nextDuration - position) < flicking.animationThreshold) {
2845
2849
  nextDuration = 0;
2846
2850
  }
2847
2851
  animate = function () {
@@ -2875,6 +2879,7 @@ version: 4.14.2-beta.0
2875
2879
  });
2876
2880
  });
2877
2881
  };
2882
+
2878
2883
  __proto._getPosition = function (panel, direction) {
2879
2884
  if (direction === void 0) {
2880
2885
  direction = DIRECTION.NONE;
@@ -4834,6 +4839,17 @@ version: 4.14.2-beta.0
4834
4839
  });
4835
4840
  return Promise.resolve();
4836
4841
  };
4842
+ /**
4843
+ * Return Rendered Panels
4844
+ * @ko 렌더링이 된 패널을 반환합니다.
4845
+ * @return {Panel[]}
4846
+ */
4847
+ __proto.getRenderedPanels = function () {
4848
+ var flicking = getFlickingAttached(this._flicking);
4849
+ return flicking.renderer.panels.filter(function (panel) {
4850
+ return panel.rendered;
4851
+ });
4852
+ };
4837
4853
  /**
4838
4854
  * Update all panel sizes
4839
4855
  * @ko 모든 패널의 크기를 업데이트합니다
@@ -5194,6 +5210,13 @@ version: 4.14.2-beta.0
5194
5210
  __proto._afterRender = function () {
5195
5211
  var flicking = getFlickingAttached(this._flicking);
5196
5212
  flicking.camera.applyTransform();
5213
+ if (flicking.useCSSOrder) {
5214
+ // useCSSOrder를 사용하는 경우 DOM은 변화가 없지만 대신 CSS Order가 추가 된다.
5215
+ var panels_1 = flicking.panels;
5216
+ this._strategy.getRenderingIndexesByOrder(flicking).forEach(function (domIndex, index) {
5217
+ panels_1[domIndex].element.style.order = "" + index;
5218
+ });
5219
+ }
5197
5220
  };
5198
5221
  return Renderer;
5199
5222
  }();
@@ -5222,6 +5245,7 @@ version: 4.14.2-beta.0
5222
5245
  });
5223
5246
  });
5224
5247
  };
5248
+
5225
5249
  __proto._collectPanels = function () {
5226
5250
  var flicking = getFlickingAttached(this._flicking);
5227
5251
  var camera = flicking.camera;
@@ -5235,7 +5259,15 @@ version: 4.14.2-beta.0
5235
5259
  var flicking = getFlickingAttached(this._flicking);
5236
5260
  var cameraEl = flicking.camera.element;
5237
5261
  // We're using reversed panels here as last panel should be the last element of camera element
5238
- var reversedElements = this._strategy.getRenderingElementsByOrder(flicking).reverse();
5262
+ var reversedElements = [];
5263
+ if (flicking.useCSSOrder) {
5264
+ // useCSSOrder를 사용하는 경우 원본 그대로 렌더링
5265
+ reversedElements = this.getRenderedPanels().map(function (panel) {
5266
+ return panel.element;
5267
+ }).reverse();
5268
+ } else {
5269
+ reversedElements = this._strategy.getRenderingElementsByOrder(flicking).reverse();
5270
+ }
5239
5271
  reversedElements.forEach(function (el, idx) {
5240
5272
  var nextEl = reversedElements[idx - 1] ? reversedElements[idx - 1] : null;
5241
5273
  if (el.nextElementSibling !== nextEl) {
@@ -6312,8 +6344,13 @@ version: 4.14.2-beta.0
6312
6344
  _15 = _b.renderExternal,
6313
6345
  renderExternal = _15 === void 0 ? null : _15,
6314
6346
  _16 = _b.optimizeSizeUpdate,
6315
- optimizeSizeUpdate = _16 === void 0 ? false : _16;
6347
+ optimizeSizeUpdate = _16 === void 0 ? false : _16,
6348
+ _17 = _b.animationThreshold,
6349
+ animationThreshold = _17 === void 0 ? 0.5 : _17,
6350
+ _18 = _b.useCSSOrder,
6351
+ useCSSOrder = _18 === void 0 ? false : _18;
6316
6352
  var _this = _super.call(this) || this;
6353
+ _this._scheduleResize = false;
6317
6354
  // Internal states
6318
6355
  _this._initialized = false;
6319
6356
  _this._plugins = [];
@@ -6358,6 +6395,8 @@ version: 4.14.2-beta.0
6358
6395
  _this._externalRenderer = externalRenderer;
6359
6396
  _this._renderExternal = renderExternal;
6360
6397
  _this._optimizeSizeUpdate = optimizeSizeUpdate;
6398
+ _this._animationThreshold = animationThreshold;
6399
+ _this._useCSSOrder = useCSSOrder;
6361
6400
  // Create core components
6362
6401
  _this._viewport = new Viewport(_this, getElement(root));
6363
6402
  _this._autoResizer = new AutoResizer(_this);
@@ -7069,6 +7108,44 @@ version: 4.14.2-beta.0
7069
7108
  enumerable: false,
7070
7109
  configurable: true
7071
7110
  });
7111
+ Object.defineProperty(__proto, "animationThreshold", {
7112
+ /**
7113
+ * 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).
7114
+ * @ko animation이 진행되기 위한 최소한의 거리. 이동하려는 거리가 `animationThreshold`보다 적으면 애니메이션 없이(duration: 0) 즉시 이동한다.
7115
+ * @type {number}
7116
+ * @default 0.5
7117
+ * @see {@link https://naver.github.io/egjs-flicking/Options#animationThreshold animationThreshold ( Options )}
7118
+ */
7119
+ get: function () {
7120
+ return this._animationThreshold;
7121
+ },
7122
+ set: function (val) {
7123
+ this._animationThreshold = val;
7124
+ },
7125
+ enumerable: false,
7126
+ configurable: true
7127
+ });
7128
+ Object.defineProperty(__proto, "useCSSOrder", {
7129
+ /**
7130
+ * Using `useCSSOrder` does not change the DOM order, but the `order` CSS property changes the order on the screen. (When `circular` is used, the DOM order changes depending on the position.)
7131
+ * When using `iframe`, you can prevent reloading when the DOM order changes.
7132
+ * In svelte, CSS order is always used.
7133
+ * @ko `useCSSOrder`를 사용하면 DOM의 순서는 변경되지 않지만 `order` css가 설정되면서 화면상 순서가 바뀐다. (`circular`를 사용한 경우 위치에 따라 DOM의 순서가 변경된다.)
7134
+ * `iframe`을 사용하는 경우 DOM의 순서가 변경되면서 reload가 되는 것을 막을 수 있다.
7135
+ * svelte에서는 css order를 무조건 사용한다.
7136
+ * @type {boolean}
7137
+ * @default false
7138
+ * @see {@link https://naver.github.io/egjs-flicking/Options#useCSSOrder useCSSOrder ( Options )}
7139
+ */
7140
+ get: function () {
7141
+ return this._useCSSOrder;
7142
+ },
7143
+ set: function (val) {
7144
+ this._useCSSOrder = val;
7145
+ },
7146
+ enumerable: false,
7147
+ configurable: true
7148
+ });
7072
7149
  Object.defineProperty(__proto, "interruptable", {
7073
7150
  /**
7074
7151
  * Set animation to be interruptable by click/touch.
@@ -7551,7 +7628,9 @@ version: 4.14.2-beta.0
7551
7628
  this._plugins.forEach(function (plugin) {
7552
7629
  return plugin.destroy();
7553
7630
  });
7631
+ this._scheduleResize = false;
7554
7632
  this._initialized = false;
7633
+ this._isResizing = false;
7555
7634
  };
7556
7635
  /**
7557
7636
  * Move to the previous panel (current index - 1)
@@ -7916,7 +7995,7 @@ version: 4.14.2-beta.0
7916
7995
  * @method
7917
7996
  * @fires Flicking#beforeResize
7918
7997
  * @fires Flicking#afterResize
7919
- * @return {this}
7998
+ * @return {boolean}
7920
7999
  */
7921
8000
  __proto.resize = function () {
7922
8001
  return __awaiter(this, void 0, void 0, function () {
@@ -7924,7 +8003,16 @@ version: 4.14.2-beta.0
7924
8003
  return __generator(this, function (_a) {
7925
8004
  switch (_a.label) {
7926
8005
  case 0:
7927
- if (this._isResizing) return [2 /*return*/];
8006
+ if (!this._initialized) {
8007
+ return [2 /*return*/];
8008
+ }
8009
+
8010
+ if (this._isResizing) {
8011
+ this._scheduleResize = true;
8012
+ return [2 /*return*/];
8013
+ }
8014
+
8015
+ this._scheduleResize = false;
7928
8016
  this._isResizing = true;
7929
8017
  viewport = this._viewport;
7930
8018
  renderer = this._renderer;
@@ -7957,6 +8045,7 @@ version: 4.14.2-beta.0
7957
8045
  if (!this._initialized) {
7958
8046
  return [2 /*return*/];
7959
8047
  }
8048
+
7960
8049
  renderer.updatePanelSize();
7961
8050
  camera.updateAlignPos();
7962
8051
  camera.updateRange();
@@ -7970,6 +8059,7 @@ version: 4.14.2-beta.0
7970
8059
  if (!this._initialized) {
7971
8060
  return [2 /*return*/];
7972
8061
  }
8062
+
7973
8063
  if (control.animating) ; else {
7974
8064
  control.updatePosition(prevProgressInPanel);
7975
8065
  control.updateInput();
@@ -7988,6 +8078,9 @@ version: 4.14.2-beta.0
7988
8078
  element: viewport.element
7989
8079
  }));
7990
8080
  this._isResizing = false;
8081
+ if (this._scheduleResize) {
8082
+ this.resize();
8083
+ }
7991
8084
  return [2 /*return*/];
7992
8085
  }
7993
8086
  });
@@ -8207,7 +8300,7 @@ version: 4.14.2-beta.0
8207
8300
  * Flicking.VERSION; // ex) 4.0.0
8208
8301
  * ```
8209
8302
  */
8210
- Flicking.VERSION = "4.14.2-beta.0";
8303
+ Flicking.VERSION = "4.14.2-beta.2";
8211
8304
  return Flicking;
8212
8305
  }(Component);
8213
8306
 
@@ -8746,13 +8839,16 @@ version: 4.14.2-beta.0
8746
8839
  map[prev] = current;
8747
8840
  return map;
8748
8841
  }, {});
8749
- return __spread(flicking.panels.filter(function (panel) {
8842
+ var renderingPanels = flicking.panels.filter(function (panel) {
8750
8843
  return !removedPanels[panel.index];
8751
- })
8752
- // Sort panels by position
8753
- .sort(function (panel1, panel2) {
8754
- return panel1.position + panel1.offset - (panel2.position + panel2.offset);
8755
- }).map(function (panel) {
8844
+ });
8845
+ if (!flicking.useCSSOrder) {
8846
+ // useCSSOrder를 사용하게 되는 경우 sort 하지 않는다.
8847
+ renderingPanels.sort(function (panel1, panel2) {
8848
+ return panel1.position + panel1.offset - (panel2.position + panel2.offset);
8849
+ });
8850
+ }
8851
+ return __spread(renderingPanels.map(function (panel) {
8756
8852
  return diffResult.list[maintainedMap[panel.index]];
8757
8853
  }), diffResult.added.map(function (idx) {
8758
8854
  return diffResult.list[idx];