@egjs/flicking 4.11.3-beta.3 → 4.11.3-beta.4

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.11.0-snapshot
7
+ version: 4.11.3-beta.4
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')) :
@@ -398,6 +398,17 @@ version: 4.11.0-snapshot
398
398
  LINEAR: "linear",
399
399
  BOUND: "bound"
400
400
  };
401
+ /**
402
+ * 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`)
403
+ * @ko 카메라 엘리먼트(`.flicking-camera`)에 적용된 {@link https://developer.mozilla.org/en-US/docs/Web/CSS/direction direction} CSS 속성을 구분하기 위한 객체
404
+ * @type {object}
405
+ * @property {string} LTR "ltr"
406
+ * @property {string} RTL "rtl"
407
+ */
408
+ var ORDER = {
409
+ LTR: "ltr",
410
+ RTL: "rtl"
411
+ };
401
412
 
402
413
  var Constants = {
403
414
  __proto__: null,
@@ -407,6 +418,7 @@ version: 4.11.0-snapshot
407
418
  MOVE_TYPE: MOVE_TYPE,
408
419
  CLASS: CLASS,
409
420
  CIRCULAR_FALLBACK: CIRCULAR_FALLBACK,
421
+ ORDER: ORDER,
410
422
  ERROR_CODE: CODE
411
423
  };
412
424
 
@@ -702,20 +714,22 @@ version: 4.11.0-snapshot
702
714
  useFractionalSize = _a.useFractionalSize,
703
715
  useOffset = _a.useOffset,
704
716
  style = _a.style;
717
+ var size = 0;
705
718
  if (useFractionalSize) {
706
- var baseSize = parseFloat(horizontal ? style.width : style.height);
719
+ var baseSize = parseFloat(horizontal ? style.width : style.height) || 0;
707
720
  var isBorderBoxSizing = style.boxSizing === "border-box";
708
721
  var border = horizontal ? parseFloat(style.borderLeftWidth || "0") + parseFloat(style.borderRightWidth || "0") : parseFloat(style.borderTopWidth || "0") + parseFloat(style.borderBottomWidth || "0");
709
722
  if (isBorderBoxSizing) {
710
- return useOffset ? baseSize : baseSize - border;
723
+ size = useOffset ? baseSize : baseSize - border;
711
724
  } else {
712
725
  var padding = horizontal ? parseFloat(style.paddingLeft || "0") + parseFloat(style.paddingRight || "0") : parseFloat(style.paddingTop || "0") + parseFloat(style.paddingBottom || "0");
713
- return useOffset ? baseSize + padding + border : baseSize + padding;
726
+ size = useOffset ? baseSize + padding + border : baseSize + padding;
714
727
  }
715
728
  } else {
716
729
  var sizeStr = horizontal ? "Width" : "Height";
717
- return useOffset ? el["offset" + sizeStr] : el["client" + sizeStr];
730
+ size = useOffset ? el["offset" + sizeStr] : el["client" + sizeStr];
718
731
  }
732
+ return Math.max(size, 0);
719
733
  };
720
734
  var setPrototypeOf = Object.setPrototypeOf || function (obj, proto) {
721
735
  obj.__proto__ = proto;
@@ -2132,7 +2146,7 @@ version: 4.11.0-snapshot
2132
2146
  threshold: 1,
2133
2147
  iOSEdgeSwipeThreshold: flicking.iOSEdgeSwipeThreshold,
2134
2148
  preventDefaultOnDrag: flicking.preventDefaultOnDrag,
2135
- scale: flicking.horizontal ? [-1, 0] : [0, -1],
2149
+ scale: flicking.horizontal ? [flicking.camera.panelOrder === ORDER.RTL ? 1 : -1, 0] : [0, -1],
2136
2150
  releaseOnScroll: true
2137
2151
  });
2138
2152
  var axes = this._axes;
@@ -2357,7 +2371,7 @@ version: 4.11.0-snapshot
2357
2371
  var panInput = this._panInput;
2358
2372
  axes.disconnect(panInput);
2359
2373
  axes.connect(flicking.horizontal ? [POSITION_KEY, ""] : ["", POSITION_KEY], panInput);
2360
- panInput.options.scale = flicking.horizontal ? [-1, 0] : [0, -1];
2374
+ panInput.options.scale = flicking.horizontal ? [flicking.camera.panelOrder === ORDER.RTL ? 1 : -1, 0] : [0, -1];
2361
2375
  };
2362
2376
  __proto._resetInternalValues = function () {
2363
2377
  this._flicking = null;
@@ -2622,7 +2636,7 @@ version: 4.11.0-snapshot
2622
2636
  var position;
2623
2637
  return __generator(this, function (_c) {
2624
2638
  position = this._getPosition(panel, direction);
2625
- this._triggerIndexChangeEvent(panel, panel.position, axesEvent);
2639
+ this._triggerIndexChangeEvent(panel, panel.position, axesEvent, direction);
2626
2640
  return [2 /*return*/, this._animateToPosition({
2627
2641
  position: position,
2628
2642
  duration: duration,
@@ -2639,6 +2653,7 @@ version: 4.11.0-snapshot
2639
2653
  var _a;
2640
2654
  var flicking = getFlickingAttached(this._flicking);
2641
2655
  this._activePanel = newActivePanel;
2656
+ this._nextPanel = null;
2642
2657
  flicking.camera.updateAdaptiveHeight();
2643
2658
  if (newActivePanel !== prevActivePanel) {
2644
2659
  flicking.trigger(new Component.ComponentEvent(EVENTS.CHANGED, {
@@ -2663,7 +2678,7 @@ version: 4.11.0-snapshot
2663
2678
  this._activePanel = control._activePanel;
2664
2679
  this._controller = control._controller;
2665
2680
  };
2666
- __proto._triggerIndexChangeEvent = function (panel, position, axesEvent) {
2681
+ __proto._triggerIndexChangeEvent = function (panel, position, axesEvent, direction) {
2667
2682
  var _a;
2668
2683
  var flicking = getFlickingAttached(this._flicking);
2669
2684
  var triggeringEvent = panel !== this._activePanel ? EVENTS.WILL_CHANGE : EVENTS.WILL_RESTORE;
@@ -2673,8 +2688,9 @@ version: 4.11.0-snapshot
2673
2688
  index: panel.index,
2674
2689
  panel: panel,
2675
2690
  isTrusted: (axesEvent === null || axesEvent === void 0 ? void 0 : axesEvent.isTrusted) || false,
2676
- direction: getDirection((_a = activePanel === null || activePanel === void 0 ? void 0 : activePanel.position) !== null && _a !== void 0 ? _a : camera.position, position)
2691
+ direction: direction !== null && direction !== void 0 ? direction : getDirection((_a = activePanel === null || activePanel === void 0 ? void 0 : activePanel.position) !== null && _a !== void 0 ? _a : camera.position, position)
2677
2692
  });
2693
+ this._nextPanel = panel;
2678
2694
  flicking.trigger(event);
2679
2695
  if (event.isCanceled()) {
2680
2696
  throw new FlickingError(MESSAGE.STOP_CALLED_BY_USER, CODE.STOP_CALLED_BY_USER);
@@ -2893,7 +2909,7 @@ version: 4.11.0-snapshot
2893
2909
  if (!activeAnchor || !anchorAtCamera) {
2894
2910
  return Promise.reject(new FlickingError(MESSAGE.POSITION_NOT_REACHABLE(position), CODE.POSITION_NOT_REACHABLE));
2895
2911
  }
2896
- var snapThreshold = this._calcSnapThreshold(position, activeAnchor);
2912
+ var snapThreshold = this._calcSnapThreshold(flicking.threshold, position, activeAnchor);
2897
2913
  var posDelta = flicking.animating ? state.delta : position - camera.position;
2898
2914
  var absPosDelta = Math.abs(posDelta);
2899
2915
  var snapDelta = axesEvent && axesEvent.delta[POSITION_KEY] !== 0 ? Math.abs(axesEvent.delta[POSITION_KEY]) : absPosDelta;
@@ -2980,7 +2996,7 @@ version: 4.11.0-snapshot
2980
2996
  var adjacentAnchor = (_a = posDelta > 0 ? camera.getNextAnchor(anchorAtCamera) : camera.getPrevAnchor(anchorAtCamera)) !== null && _a !== void 0 ? _a : anchorAtCamera;
2981
2997
  return adjacentAnchor;
2982
2998
  };
2983
- __proto._calcSnapThreshold = function (position, activeAnchor) {
2999
+ __proto._calcSnapThreshold = function (threshold, position, activeAnchor) {
2984
3000
  var isNextDirection = position > activeAnchor.position;
2985
3001
  var panel = activeAnchor.panel;
2986
3002
  var panelSize = panel.size;
@@ -2991,7 +3007,7 @@ version: 4.11.0-snapshot
2991
3007
  * |<------>|<------------>|
2992
3008
  * [ |<-Anchor ]
2993
3009
  */
2994
- return isNextDirection ? panelSize - alignPos + panel.margin.next : alignPos + panel.margin.prev;
3010
+ return Math.max(threshold, isNextDirection ? panelSize - alignPos + panel.margin.next : alignPos + panel.margin.prev);
2995
3011
  };
2996
3012
  return SnapControl;
2997
3013
  }(Control$1);
@@ -3262,19 +3278,20 @@ version: 4.11.0-snapshot
3262
3278
  * @return {Promise<void>} A Promise which will be resolved after reaching the target position<ko>해당 좌표 도달시에 resolve되는 Promise</ko>
3263
3279
  */
3264
3280
  __proto.moveToPosition = function (position, duration, axesEvent) {
3281
+ var _a;
3265
3282
  var flicking = getFlickingAttached(this._flicking);
3266
3283
  var camera = flicking.camera;
3267
- var activePanel = this._activePanel;
3284
+ var currentPanel = (_a = this._nextPanel) !== null && _a !== void 0 ? _a : this._activePanel;
3268
3285
  var axesRange = this._controller.range;
3269
3286
  var indexRange = this._indexRange;
3270
3287
  var cameraRange = camera.range;
3271
3288
  var state = this._controller.state;
3272
3289
  var clampedPosition = clamp(camera.clampToReachablePosition(position), axesRange[0], axesRange[1]);
3273
3290
  var anchorAtPosition = camera.findAnchorIncludePosition(clampedPosition);
3274
- if (!anchorAtPosition || !activePanel) {
3291
+ if (!anchorAtPosition || !currentPanel) {
3275
3292
  return Promise.reject(new FlickingError(MESSAGE.POSITION_NOT_REACHABLE(position), CODE.POSITION_NOT_REACHABLE));
3276
3293
  }
3277
- var prevPos = activePanel.position;
3294
+ var prevPos = currentPanel.position;
3278
3295
  var posDelta = flicking.animating ? state.delta : position - camera.position;
3279
3296
  var isOverThreshold = Math.abs(posDelta) >= flicking.threshold;
3280
3297
  var adjacentAnchor = position > prevPos ? camera.getNextAnchor(anchorAtPosition) : camera.getPrevAnchor(anchorAtPosition);
@@ -3291,7 +3308,7 @@ version: 4.11.0-snapshot
3291
3308
  var targetAnchor = position < cameraRange.min ? firstAnchor : lastAnchor;
3292
3309
  targetPanel = targetAnchor.panel;
3293
3310
  targetPos = targetAnchor.position;
3294
- } else if (isOverThreshold && anchorAtPosition.position !== activePanel.position) {
3311
+ } else if (isOverThreshold && anchorAtPosition.position !== currentPanel.position) {
3295
3312
  // Move to anchor at position
3296
3313
  targetPanel = anchorAtPosition.panel;
3297
3314
  targetPos = anchorAtPosition.position;
@@ -4050,6 +4067,19 @@ version: 4.11.0-snapshot
4050
4067
  enumerable: false,
4051
4068
  configurable: true
4052
4069
  });
4070
+ Object.defineProperty(__proto, "panelOrder", {
4071
+ /**
4072
+ * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/direction direction} CSS property applied to the camera element(`.flicking-camera`)
4073
+ * @ko 카메라 엘리먼트(`.flicking-camera`)에 적용된 {@link https://developer.mozilla.org/en-US/docs/Web/CSS/direction direction} CSS 속성
4074
+ * @type {string}
4075
+ * @readonly
4076
+ */
4077
+ get: function () {
4078
+ return this._panelOrder;
4079
+ },
4080
+ enumerable: false,
4081
+ configurable: true
4082
+ });
4053
4083
  Object.defineProperty(__proto, "align", {
4054
4084
  // Options Getter
4055
4085
  /**
@@ -4081,6 +4111,7 @@ version: 4.11.0-snapshot
4081
4111
  this._el = viewportEl.firstElementChild;
4082
4112
  this._checkTranslateSupport();
4083
4113
  this._updateMode();
4114
+ this.updatePanelOrder();
4084
4115
  return this;
4085
4116
  };
4086
4117
  /**
@@ -4202,11 +4233,13 @@ version: 4.11.0-snapshot
4202
4233
  * @return {AnchorPoint | null}
4203
4234
  */
4204
4235
  __proto.findActiveAnchor = function () {
4236
+ var _a;
4205
4237
  var flicking = getFlickingAttached(this._flicking);
4206
- var activeIndex = flicking.control.activeIndex;
4207
- return find(this._anchors, function (anchor) {
4208
- return anchor.panel.index === activeIndex;
4209
- });
4238
+ var activePanel = flicking.control.activePanel;
4239
+ if (!activePanel) return null;
4240
+ return (_a = find(this._anchors, function (anchor) {
4241
+ return anchor.panel.index === activePanel.index;
4242
+ })) !== null && _a !== void 0 ? _a : this.findNearestAnchor(activePanel.position);
4210
4243
  };
4211
4244
  /**
4212
4245
  * Clamp the given position between camera's range
@@ -4323,6 +4356,24 @@ version: 4.11.0-snapshot
4323
4356
  this.applyTransform();
4324
4357
  return this;
4325
4358
  };
4359
+ /**
4360
+ * Update direction to match the {@link https://developer.mozilla.org/en-US/docs/Web/CSS/direction direction} CSS property applied to the camera element
4361
+ * @ko 카메라 엘리먼트에 적용된 {@link https://developer.mozilla.org/en-US/docs/Web/CSS/direction direction} CSS 속성에 맞게 방향을 업데이트합니다
4362
+ * @return {this}
4363
+ */
4364
+ __proto.updatePanelOrder = function () {
4365
+ var flicking = getFlickingAttached(this._flicking);
4366
+ if (!flicking.horizontal) return this;
4367
+ var el = this._el;
4368
+ var direction = getStyle(el).direction;
4369
+ if (direction !== this._panelOrder) {
4370
+ this._panelOrder = direction === ORDER.RTL ? ORDER.RTL : ORDER.LTR;
4371
+ if (flicking.initialized) {
4372
+ flicking.control.controller.updateDirection();
4373
+ }
4374
+ }
4375
+ return this;
4376
+ };
4326
4377
  /**
4327
4378
  * Reset the history of {@link Flicking#event:needPanel needPanel} events so it can be triggered again
4328
4379
  * @ko 발생한 {@link Flicking#event:needPanel needPanel} 이벤트들을 초기화하여 다시 발생할 수 있도록 합니다
@@ -4347,7 +4398,7 @@ version: 4.11.0-snapshot
4347
4398
  var renderer = flicking.renderer;
4348
4399
  if (renderer.rendering || !flicking.initialized) return this;
4349
4400
  var actualPosition = this._position - this._alignPos - this._offset + this._circularOffset;
4350
- el.style[this._transform] = flicking.horizontal ? "translate(" + -actualPosition + "px)" : "translate(0, " + -actualPosition + "px)";
4401
+ el.style[this._transform] = flicking.horizontal ? "translate(" + (this._panelOrder === ORDER.RTL ? actualPosition : -actualPosition) + "px)" : "translate(0, " + -actualPosition + "px)";
4351
4402
  return this;
4352
4403
  };
4353
4404
  __proto._resetInternalValues = function () {
@@ -7622,15 +7673,24 @@ version: 4.11.0-snapshot
7622
7673
  return [4 /*yield*/, renderer.forceRenderAllPanels()];
7623
7674
  case 1:
7624
7675
  _a.sent(); // Render all panel elements, to update sizes
7676
+ if (!this._initialized) {
7677
+ return [2 /*return*/];
7678
+ }
7679
+
7625
7680
  renderer.updatePanelSize();
7626
7681
  camera.updateAlignPos();
7627
7682
  camera.updateRange();
7628
7683
  camera.updateAnchors();
7629
7684
  camera.updateAdaptiveHeight();
7685
+ camera.updatePanelOrder();
7630
7686
  camera.updateOffset();
7631
7687
  return [4 /*yield*/, renderer.render()];
7632
7688
  case 2:
7633
7689
  _a.sent();
7690
+ if (!this._initialized) {
7691
+ return [2 /*return*/];
7692
+ }
7693
+
7634
7694
  if (control.animating) ; else {
7635
7695
  control.updatePosition(prevProgressInPanel);
7636
7696
  control.updateInput();
@@ -7867,7 +7927,7 @@ version: 4.11.0-snapshot
7867
7927
  * Flicking.VERSION; // ex) 4.0.0
7868
7928
  * ```
7869
7929
  */
7870
- Flicking.VERSION = "4.11.0-snapshot";
7930
+ Flicking.VERSION = "4.11.3-beta.4";
7871
7931
  return Flicking;
7872
7932
  }(Component);
7873
7933