@egjs/flicking 4.11.3-beta.3 → 4.11.3

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.11.0-snapshot
7
+ version: 4.11.3
8
8
  */
9
9
  (function (global, factory) {
10
10
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -12,7 +12,7 @@ version: 4.11.0-snapshot
12
12
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Flicking = factory());
13
13
  })(this, (function () { 'use strict';
14
14
 
15
- /*! *****************************************************************************
15
+ /******************************************************************************
16
16
  Copyright (c) Microsoft Corporation.
17
17
 
18
18
  Permission to use, copy, modify, and/or distribute this software for any
@@ -26,7 +26,7 @@ version: 4.11.0-snapshot
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 */
29
+ /* global Reflect, Promise, SuppressedError, Symbol */
30
30
 
31
31
  var extendStatics$3 = function (d, b) {
32
32
  extendStatics$3 = Object.setPrototypeOf || {
@@ -111,7 +111,7 @@ version: 4.11.0-snapshot
111
111
  }
112
112
  function step(op) {
113
113
  if (f) throw new TypeError("Generator is already executing.");
114
- while (_) try {
114
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
115
115
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
116
116
  if (y = 0, t) op = [op[0] & 2, t.value];
117
117
  switch (op[0]) {
@@ -215,6 +215,10 @@ version: 4.11.0-snapshot
215
215
  for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read$1(arguments[i]));
216
216
  return ar;
217
217
  }
218
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
219
+ var e = new Error(message);
220
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
221
+ };
218
222
 
219
223
  /*
220
224
  Copyright (c) NAVER Corp.
@@ -805,6 +809,17 @@ version: 4.11.0-snapshot
805
809
  LINEAR: "linear",
806
810
  BOUND: "bound"
807
811
  };
812
+ /**
813
+ * An object for identifying {@link https://developer.mozilla.org/en-US/docs/Web/CSS/direction direction} CSS property applied to the camera element(`.flicking-camera`)
814
+ * @ko 카메라 엘리먼트(`.flicking-camera`)에 적용된 {@link https://developer.mozilla.org/en-US/docs/Web/CSS/direction direction} CSS 속성을 구분하기 위한 객체
815
+ * @type {object}
816
+ * @property {string} LTR "ltr"
817
+ * @property {string} RTL "rtl"
818
+ */
819
+ var ORDER = {
820
+ LTR: "ltr",
821
+ RTL: "rtl"
822
+ };
808
823
 
809
824
  var Constants = {
810
825
  __proto__: null,
@@ -814,6 +829,7 @@ version: 4.11.0-snapshot
814
829
  MOVE_TYPE: MOVE_TYPE,
815
830
  CLASS: CLASS,
816
831
  CIRCULAR_FALLBACK: CIRCULAR_FALLBACK,
832
+ ORDER: ORDER,
817
833
  ERROR_CODE: CODE
818
834
  };
819
835
 
@@ -1109,20 +1125,22 @@ version: 4.11.0-snapshot
1109
1125
  useFractionalSize = _a.useFractionalSize,
1110
1126
  useOffset = _a.useOffset,
1111
1127
  style = _a.style;
1128
+ var size = 0;
1112
1129
  if (useFractionalSize) {
1113
- var baseSize = parseFloat(horizontal ? style.width : style.height);
1130
+ var baseSize = parseFloat(horizontal ? style.width : style.height) || 0;
1114
1131
  var isBorderBoxSizing = style.boxSizing === "border-box";
1115
1132
  var border = horizontal ? parseFloat(style.borderLeftWidth || "0") + parseFloat(style.borderRightWidth || "0") : parseFloat(style.borderTopWidth || "0") + parseFloat(style.borderBottomWidth || "0");
1116
1133
  if (isBorderBoxSizing) {
1117
- return useOffset ? baseSize : baseSize - border;
1134
+ size = useOffset ? baseSize : baseSize - border;
1118
1135
  } else {
1119
1136
  var padding = horizontal ? parseFloat(style.paddingLeft || "0") + parseFloat(style.paddingRight || "0") : parseFloat(style.paddingTop || "0") + parseFloat(style.paddingBottom || "0");
1120
- return useOffset ? baseSize + padding + border : baseSize + padding;
1137
+ size = useOffset ? baseSize + padding + border : baseSize + padding;
1121
1138
  }
1122
1139
  } else {
1123
1140
  var sizeStr = horizontal ? "Width" : "Height";
1124
- return useOffset ? el["offset" + sizeStr] : el["client" + sizeStr];
1141
+ size = useOffset ? el["offset" + sizeStr] : el["client" + sizeStr];
1125
1142
  }
1143
+ return Math.max(size, 0);
1126
1144
  };
1127
1145
  var setPrototypeOf = Object.setPrototypeOf || function (obj, proto) {
1128
1146
  obj.__proto__ = proto;
@@ -6290,7 +6308,7 @@ version: 4.11.0-snapshot
6290
6308
  threshold: 1,
6291
6309
  iOSEdgeSwipeThreshold: flicking.iOSEdgeSwipeThreshold,
6292
6310
  preventDefaultOnDrag: flicking.preventDefaultOnDrag,
6293
- scale: flicking.horizontal ? [-1, 0] : [0, -1],
6311
+ scale: flicking.horizontal ? [flicking.camera.panelOrder === ORDER.RTL ? 1 : -1, 0] : [0, -1],
6294
6312
  releaseOnScroll: true
6295
6313
  });
6296
6314
  var axes = this._axes;
@@ -6515,7 +6533,7 @@ version: 4.11.0-snapshot
6515
6533
  var panInput = this._panInput;
6516
6534
  axes.disconnect(panInput);
6517
6535
  axes.connect(flicking.horizontal ? [POSITION_KEY, ""] : ["", POSITION_KEY], panInput);
6518
- panInput.options.scale = flicking.horizontal ? [-1, 0] : [0, -1];
6536
+ panInput.options.scale = flicking.horizontal ? [flicking.camera.panelOrder === ORDER.RTL ? 1 : -1, 0] : [0, -1];
6519
6537
  };
6520
6538
  __proto._resetInternalValues = function () {
6521
6539
  this._flicking = null;
@@ -6780,7 +6798,7 @@ version: 4.11.0-snapshot
6780
6798
  var position;
6781
6799
  return __generator(this, function (_c) {
6782
6800
  position = this._getPosition(panel, direction);
6783
- this._triggerIndexChangeEvent(panel, panel.position, axesEvent);
6801
+ this._triggerIndexChangeEvent(panel, panel.position, axesEvent, direction);
6784
6802
  return [2 /*return*/, this._animateToPosition({
6785
6803
  position: position,
6786
6804
  duration: duration,
@@ -6797,6 +6815,7 @@ version: 4.11.0-snapshot
6797
6815
  var _a;
6798
6816
  var flicking = getFlickingAttached(this._flicking);
6799
6817
  this._activePanel = newActivePanel;
6818
+ this._nextPanel = null;
6800
6819
  flicking.camera.updateAdaptiveHeight();
6801
6820
  if (newActivePanel !== prevActivePanel) {
6802
6821
  flicking.trigger(new ComponentEvent$1(EVENTS.CHANGED, {
@@ -6821,7 +6840,7 @@ version: 4.11.0-snapshot
6821
6840
  this._activePanel = control._activePanel;
6822
6841
  this._controller = control._controller;
6823
6842
  };
6824
- __proto._triggerIndexChangeEvent = function (panel, position, axesEvent) {
6843
+ __proto._triggerIndexChangeEvent = function (panel, position, axesEvent, direction) {
6825
6844
  var _a;
6826
6845
  var flicking = getFlickingAttached(this._flicking);
6827
6846
  var triggeringEvent = panel !== this._activePanel ? EVENTS.WILL_CHANGE : EVENTS.WILL_RESTORE;
@@ -6831,8 +6850,9 @@ version: 4.11.0-snapshot
6831
6850
  index: panel.index,
6832
6851
  panel: panel,
6833
6852
  isTrusted: (axesEvent === null || axesEvent === void 0 ? void 0 : axesEvent.isTrusted) || false,
6834
- direction: getDirection$1((_a = activePanel === null || activePanel === void 0 ? void 0 : activePanel.position) !== null && _a !== void 0 ? _a : camera.position, position)
6853
+ direction: direction !== null && direction !== void 0 ? direction : getDirection$1((_a = activePanel === null || activePanel === void 0 ? void 0 : activePanel.position) !== null && _a !== void 0 ? _a : camera.position, position)
6835
6854
  });
6855
+ this._nextPanel = panel;
6836
6856
  flicking.trigger(event);
6837
6857
  if (event.isCanceled()) {
6838
6858
  throw new FlickingError(MESSAGE.STOP_CALLED_BY_USER, CODE.STOP_CALLED_BY_USER);
@@ -7051,7 +7071,7 @@ version: 4.11.0-snapshot
7051
7071
  if (!activeAnchor || !anchorAtCamera) {
7052
7072
  return Promise.reject(new FlickingError(MESSAGE.POSITION_NOT_REACHABLE(position), CODE.POSITION_NOT_REACHABLE));
7053
7073
  }
7054
- var snapThreshold = this._calcSnapThreshold(position, activeAnchor);
7074
+ var snapThreshold = this._calcSnapThreshold(flicking.threshold, position, activeAnchor);
7055
7075
  var posDelta = flicking.animating ? state.delta : position - camera.position;
7056
7076
  var absPosDelta = Math.abs(posDelta);
7057
7077
  var snapDelta = axesEvent && axesEvent.delta[POSITION_KEY] !== 0 ? Math.abs(axesEvent.delta[POSITION_KEY]) : absPosDelta;
@@ -7138,7 +7158,7 @@ version: 4.11.0-snapshot
7138
7158
  var adjacentAnchor = (_a = posDelta > 0 ? camera.getNextAnchor(anchorAtCamera) : camera.getPrevAnchor(anchorAtCamera)) !== null && _a !== void 0 ? _a : anchorAtCamera;
7139
7159
  return adjacentAnchor;
7140
7160
  };
7141
- __proto._calcSnapThreshold = function (position, activeAnchor) {
7161
+ __proto._calcSnapThreshold = function (threshold, position, activeAnchor) {
7142
7162
  var isNextDirection = position > activeAnchor.position;
7143
7163
  var panel = activeAnchor.panel;
7144
7164
  var panelSize = panel.size;
@@ -7149,7 +7169,7 @@ version: 4.11.0-snapshot
7149
7169
  * |<------>|<------------>|
7150
7170
  * [ |<-Anchor ]
7151
7171
  */
7152
- return isNextDirection ? panelSize - alignPos + panel.margin.next : alignPos + panel.margin.prev;
7172
+ return Math.max(threshold, isNextDirection ? panelSize - alignPos + panel.margin.next : alignPos + panel.margin.prev);
7153
7173
  };
7154
7174
  return SnapControl;
7155
7175
  }(Control$1);
@@ -7420,19 +7440,20 @@ version: 4.11.0-snapshot
7420
7440
  * @return {Promise<void>} A Promise which will be resolved after reaching the target position<ko>해당 좌표 도달시에 resolve되는 Promise</ko>
7421
7441
  */
7422
7442
  __proto.moveToPosition = function (position, duration, axesEvent) {
7443
+ var _a;
7423
7444
  var flicking = getFlickingAttached(this._flicking);
7424
7445
  var camera = flicking.camera;
7425
- var activePanel = this._activePanel;
7446
+ var currentPanel = (_a = this._nextPanel) !== null && _a !== void 0 ? _a : this._activePanel;
7426
7447
  var axesRange = this._controller.range;
7427
7448
  var indexRange = this._indexRange;
7428
7449
  var cameraRange = camera.range;
7429
7450
  var state = this._controller.state;
7430
7451
  var clampedPosition = clamp$1(camera.clampToReachablePosition(position), axesRange[0], axesRange[1]);
7431
7452
  var anchorAtPosition = camera.findAnchorIncludePosition(clampedPosition);
7432
- if (!anchorAtPosition || !activePanel) {
7453
+ if (!anchorAtPosition || !currentPanel) {
7433
7454
  return Promise.reject(new FlickingError(MESSAGE.POSITION_NOT_REACHABLE(position), CODE.POSITION_NOT_REACHABLE));
7434
7455
  }
7435
- var prevPos = activePanel.position;
7456
+ var prevPos = currentPanel.position;
7436
7457
  var posDelta = flicking.animating ? state.delta : position - camera.position;
7437
7458
  var isOverThreshold = Math.abs(posDelta) >= flicking.threshold;
7438
7459
  var adjacentAnchor = position > prevPos ? camera.getNextAnchor(anchorAtPosition) : camera.getPrevAnchor(anchorAtPosition);
@@ -7449,7 +7470,7 @@ version: 4.11.0-snapshot
7449
7470
  var targetAnchor = position < cameraRange.min ? firstAnchor : lastAnchor;
7450
7471
  targetPanel = targetAnchor.panel;
7451
7472
  targetPos = targetAnchor.position;
7452
- } else if (isOverThreshold && anchorAtPosition.position !== activePanel.position) {
7473
+ } else if (isOverThreshold && anchorAtPosition.position !== currentPanel.position) {
7453
7474
  // Move to anchor at position
7454
7475
  targetPanel = anchorAtPosition.panel;
7455
7476
  targetPos = anchorAtPosition.position;
@@ -8208,6 +8229,19 @@ version: 4.11.0-snapshot
8208
8229
  enumerable: false,
8209
8230
  configurable: true
8210
8231
  });
8232
+ Object.defineProperty(__proto, "panelOrder", {
8233
+ /**
8234
+ * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/direction direction} CSS property applied to the camera element(`.flicking-camera`)
8235
+ * @ko 카메라 엘리먼트(`.flicking-camera`)에 적용된 {@link https://developer.mozilla.org/en-US/docs/Web/CSS/direction direction} CSS 속성
8236
+ * @type {string}
8237
+ * @readonly
8238
+ */
8239
+ get: function () {
8240
+ return this._panelOrder;
8241
+ },
8242
+ enumerable: false,
8243
+ configurable: true
8244
+ });
8211
8245
  Object.defineProperty(__proto, "align", {
8212
8246
  // Options Getter
8213
8247
  /**
@@ -8239,6 +8273,7 @@ version: 4.11.0-snapshot
8239
8273
  this._el = viewportEl.firstElementChild;
8240
8274
  this._checkTranslateSupport();
8241
8275
  this._updateMode();
8276
+ this.updatePanelOrder();
8242
8277
  return this;
8243
8278
  };
8244
8279
  /**
@@ -8360,11 +8395,13 @@ version: 4.11.0-snapshot
8360
8395
  * @return {AnchorPoint | null}
8361
8396
  */
8362
8397
  __proto.findActiveAnchor = function () {
8398
+ var _a;
8363
8399
  var flicking = getFlickingAttached(this._flicking);
8364
- var activeIndex = flicking.control.activeIndex;
8365
- return find$1(this._anchors, function (anchor) {
8366
- return anchor.panel.index === activeIndex;
8367
- });
8400
+ var activePanel = flicking.control.activePanel;
8401
+ if (!activePanel) return null;
8402
+ return (_a = find$1(this._anchors, function (anchor) {
8403
+ return anchor.panel.index === activePanel.index;
8404
+ })) !== null && _a !== void 0 ? _a : this.findNearestAnchor(activePanel.position);
8368
8405
  };
8369
8406
  /**
8370
8407
  * Clamp the given position between camera's range
@@ -8481,6 +8518,24 @@ version: 4.11.0-snapshot
8481
8518
  this.applyTransform();
8482
8519
  return this;
8483
8520
  };
8521
+ /**
8522
+ * Update direction to match the {@link https://developer.mozilla.org/en-US/docs/Web/CSS/direction direction} CSS property applied to the camera element
8523
+ * @ko 카메라 엘리먼트에 적용된 {@link https://developer.mozilla.org/en-US/docs/Web/CSS/direction direction} CSS 속성에 맞게 방향을 업데이트합니다
8524
+ * @return {this}
8525
+ */
8526
+ __proto.updatePanelOrder = function () {
8527
+ var flicking = getFlickingAttached(this._flicking);
8528
+ if (!flicking.horizontal) return this;
8529
+ var el = this._el;
8530
+ var direction = getStyle(el).direction;
8531
+ if (direction !== this._panelOrder) {
8532
+ this._panelOrder = direction === ORDER.RTL ? ORDER.RTL : ORDER.LTR;
8533
+ if (flicking.initialized) {
8534
+ flicking.control.controller.updateDirection();
8535
+ }
8536
+ }
8537
+ return this;
8538
+ };
8484
8539
  /**
8485
8540
  * Reset the history of {@link Flicking#event:needPanel needPanel} events so it can be triggered again
8486
8541
  * @ko 발생한 {@link Flicking#event:needPanel needPanel} 이벤트들을 초기화하여 다시 발생할 수 있도록 합니다
@@ -8505,7 +8560,7 @@ version: 4.11.0-snapshot
8505
8560
  var renderer = flicking.renderer;
8506
8561
  if (renderer.rendering || !flicking.initialized) return this;
8507
8562
  var actualPosition = this._position - this._alignPos - this._offset + this._circularOffset;
8508
- el.style[this._transform] = flicking.horizontal ? "translate(" + -actualPosition + "px)" : "translate(0, " + -actualPosition + "px)";
8563
+ el.style[this._transform] = flicking.horizontal ? "translate(" + (this._panelOrder === ORDER.RTL ? actualPosition : -actualPosition) + "px)" : "translate(0, " + -actualPosition + "px)";
8509
8564
  return this;
8510
8565
  };
8511
8566
  __proto._resetInternalValues = function () {
@@ -12650,15 +12705,24 @@ version: 4.11.0-snapshot
12650
12705
  return [4 /*yield*/, renderer.forceRenderAllPanels()];
12651
12706
  case 1:
12652
12707
  _a.sent(); // Render all panel elements, to update sizes
12708
+ if (!this._initialized) {
12709
+ return [2 /*return*/];
12710
+ }
12711
+
12653
12712
  renderer.updatePanelSize();
12654
12713
  camera.updateAlignPos();
12655
12714
  camera.updateRange();
12656
12715
  camera.updateAnchors();
12657
12716
  camera.updateAdaptiveHeight();
12717
+ camera.updatePanelOrder();
12658
12718
  camera.updateOffset();
12659
12719
  return [4 /*yield*/, renderer.render()];
12660
12720
  case 2:
12661
12721
  _a.sent();
12722
+ if (!this._initialized) {
12723
+ return [2 /*return*/];
12724
+ }
12725
+
12662
12726
  if (control.animating) ; else {
12663
12727
  control.updatePosition(prevProgressInPanel);
12664
12728
  control.updateInput();
@@ -12895,7 +12959,7 @@ version: 4.11.0-snapshot
12895
12959
  * Flicking.VERSION; // ex) 4.0.0
12896
12960
  * ```
12897
12961
  */
12898
- Flicking.VERSION = "4.11.0-snapshot";
12962
+ Flicking.VERSION = "4.11.3";
12899
12963
  return Flicking;
12900
12964
  }(Component);
12901
12965