@egjs/flicking 4.11.0 → 4.11.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.
@@ -1,6 +1,7 @@
1
1
  import Flicking, { FlickingOptions } from "../Flicking";
2
2
  import Panel from "../core/panel/Panel";
3
3
  import AnchorPoint from "../core/AnchorPoint";
4
+ import { ValueOf } from "../type/internal";
4
5
  import { CameraMode } from "./mode";
5
6
  export interface CameraOptions {
6
7
  align: FlickingOptions["align"];
@@ -20,6 +21,7 @@ declare class Camera {
20
21
  private _visiblePanels;
21
22
  private _anchors;
22
23
  private _needPanelTriggered;
24
+ private _panelOrder;
23
25
  get element(): HTMLElement;
24
26
  get children(): HTMLElement[];
25
27
  get position(): number;
@@ -49,6 +51,10 @@ declare class Camera {
49
51
  get atEdge(): boolean;
50
52
  get size(): number;
51
53
  get progress(): number;
54
+ get panelOrder(): ValueOf<{
55
+ readonly LTR: "ltr";
56
+ readonly RTL: "rtl";
57
+ }>;
52
58
  get align(): FlickingOptions["align"];
53
59
  set align(val: FlickingOptions["align"]);
54
60
  constructor(flicking: Flicking, { align }?: Partial<CameraOptions>);
@@ -69,6 +75,7 @@ declare class Camera {
69
75
  updateAnchors(): this;
70
76
  updateAdaptiveHeight(): void;
71
77
  updateOffset(): this;
78
+ updatePanelOrder(): this;
72
79
  resetNeedPanelHistory(): this;
73
80
  applyTransform(): this;
74
81
  private _resetInternalValues;
@@ -42,3 +42,7 @@ export declare const CIRCULAR_FALLBACK: {
42
42
  readonly LINEAR: "linear";
43
43
  readonly BOUND: "bound";
44
44
  };
45
+ export declare const ORDER: {
46
+ readonly LTR: "ltr";
47
+ readonly RTL: "rtl";
48
+ };
@@ -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
7
+ version: 4.11.1
8
8
  */
9
9
  'use strict';
10
10
 
@@ -398,6 +398,17 @@ var CIRCULAR_FALLBACK = {
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
  // eslint-disable-next-line @typescript-eslint/ban-types
403
414
  var merge = function (target) {
@@ -691,20 +702,22 @@ var getElementSize = function (_a) {
691
702
  useFractionalSize = _a.useFractionalSize,
692
703
  useOffset = _a.useOffset,
693
704
  style = _a.style;
705
+ var size = 0;
694
706
  if (useFractionalSize) {
695
- var baseSize = parseFloat(horizontal ? style.width : style.height);
707
+ var baseSize = parseFloat(horizontal ? style.width : style.height) || 0;
696
708
  var isBorderBoxSizing = style.boxSizing === "border-box";
697
709
  var border = horizontal ? parseFloat(style.borderLeftWidth || "0") + parseFloat(style.borderRightWidth || "0") : parseFloat(style.borderTopWidth || "0") + parseFloat(style.borderBottomWidth || "0");
698
710
  if (isBorderBoxSizing) {
699
- return useOffset ? baseSize : baseSize - border;
711
+ size = useOffset ? baseSize : baseSize - border;
700
712
  } else {
701
713
  var padding = horizontal ? parseFloat(style.paddingLeft || "0") + parseFloat(style.paddingRight || "0") : parseFloat(style.paddingTop || "0") + parseFloat(style.paddingBottom || "0");
702
- return useOffset ? baseSize + padding + border : baseSize + padding;
714
+ size = useOffset ? baseSize + padding + border : baseSize + padding;
703
715
  }
704
716
  } else {
705
717
  var sizeStr = horizontal ? "Width" : "Height";
706
- return useOffset ? el["offset" + sizeStr] : el["client" + sizeStr];
718
+ size = useOffset ? el["offset" + sizeStr] : el["client" + sizeStr];
707
719
  }
720
+ return Math.max(size, 0);
708
721
  };
709
722
  var setPrototypeOf = Object.setPrototypeOf || function (obj, proto) {
710
723
  obj.__proto__ = proto;
@@ -2088,7 +2101,7 @@ var AxesController = /*#__PURE__*/function () {
2088
2101
  threshold: 1,
2089
2102
  iOSEdgeSwipeThreshold: flicking.iOSEdgeSwipeThreshold,
2090
2103
  preventDefaultOnDrag: flicking.preventDefaultOnDrag,
2091
- scale: flicking.horizontal ? [-1, 0] : [0, -1],
2104
+ scale: flicking.horizontal ? [flicking.camera.panelOrder === ORDER.RTL ? 1 : -1, 0] : [0, -1],
2092
2105
  releaseOnScroll: true
2093
2106
  });
2094
2107
  var axes = this._axes;
@@ -2313,7 +2326,7 @@ var AxesController = /*#__PURE__*/function () {
2313
2326
  var panInput = this._panInput;
2314
2327
  axes.disconnect(panInput);
2315
2328
  axes.connect(flicking.horizontal ? [POSITION_KEY, ""] : ["", POSITION_KEY], panInput);
2316
- panInput.options.scale = flicking.horizontal ? [-1, 0] : [0, -1];
2329
+ panInput.options.scale = flicking.horizontal ? [flicking.camera.panelOrder === ORDER.RTL ? 1 : -1, 0] : [0, -1];
2317
2330
  };
2318
2331
  __proto._resetInternalValues = function () {
2319
2332
  this._flicking = null;
@@ -3985,6 +3998,19 @@ var Camera = /*#__PURE__*/function () {
3985
3998
  enumerable: false,
3986
3999
  configurable: true
3987
4000
  });
4001
+ Object.defineProperty(__proto, "panelOrder", {
4002
+ /**
4003
+ * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/direction direction} CSS property applied to the camera element(`.flicking-camera`)
4004
+ * @ko 카메라 엘리먼트(`.flicking-camera`)에 적용된 {@link https://developer.mozilla.org/en-US/docs/Web/CSS/direction direction} CSS 속성
4005
+ * @type {string}
4006
+ * @readonly
4007
+ */
4008
+ get: function () {
4009
+ return this._panelOrder;
4010
+ },
4011
+ enumerable: false,
4012
+ configurable: true
4013
+ });
3988
4014
  Object.defineProperty(__proto, "align", {
3989
4015
  // Options Getter
3990
4016
  /**
@@ -4016,6 +4042,7 @@ var Camera = /*#__PURE__*/function () {
4016
4042
  this._el = viewportEl.firstElementChild;
4017
4043
  this._checkTranslateSupport();
4018
4044
  this._updateMode();
4045
+ this.updatePanelOrder();
4019
4046
  return this;
4020
4047
  };
4021
4048
  /**
@@ -4258,6 +4285,24 @@ var Camera = /*#__PURE__*/function () {
4258
4285
  this.applyTransform();
4259
4286
  return this;
4260
4287
  };
4288
+ /**
4289
+ * Update direction to match the {@link https://developer.mozilla.org/en-US/docs/Web/CSS/direction direction} CSS property applied to the camera element
4290
+ * @ko 카메라 엘리먼트에 적용된 {@link https://developer.mozilla.org/en-US/docs/Web/CSS/direction direction} CSS 속성에 맞게 방향을 업데이트합니다
4291
+ * @return {this}
4292
+ */
4293
+ __proto.updatePanelOrder = function () {
4294
+ var flicking = getFlickingAttached(this._flicking);
4295
+ if (!flicking.horizontal) return this;
4296
+ var el = this._el;
4297
+ var direction = getStyle(el).direction;
4298
+ if (direction !== this._panelOrder) {
4299
+ this._panelOrder = direction === ORDER.RTL ? ORDER.RTL : ORDER.LTR;
4300
+ if (flicking.initialized) {
4301
+ flicking.control.controller.updateDirection();
4302
+ }
4303
+ }
4304
+ return this;
4305
+ };
4261
4306
  /**
4262
4307
  * Reset the history of {@link Flicking#event:needPanel needPanel} events so it can be triggered again
4263
4308
  * @ko 발생한 {@link Flicking#event:needPanel needPanel} 이벤트들을 초기화하여 다시 발생할 수 있도록 합니다
@@ -4282,7 +4327,7 @@ var Camera = /*#__PURE__*/function () {
4282
4327
  var renderer = flicking.renderer;
4283
4328
  if (renderer.rendering || !flicking.initialized) return this;
4284
4329
  var actualPosition = this._position - this._alignPos - this._offset + this._circularOffset;
4285
- el.style[this._transform] = flicking.horizontal ? "translate(" + -actualPosition + "px)" : "translate(0, " + -actualPosition + "px)";
4330
+ el.style[this._transform] = flicking.horizontal ? "translate(" + (this._panelOrder === ORDER.RTL ? actualPosition : -actualPosition) + "px)" : "translate(0, " + -actualPosition + "px)";
4286
4331
  return this;
4287
4332
  };
4288
4333
  __proto._resetInternalValues = function () {
@@ -7535,6 +7580,7 @@ var Flicking = /*#__PURE__*/function (_super) {
7535
7580
  camera.updateRange();
7536
7581
  camera.updateAnchors();
7537
7582
  camera.updateAdaptiveHeight();
7583
+ camera.updatePanelOrder();
7538
7584
  camera.updateOffset();
7539
7585
  return [4 /*yield*/, renderer.render()];
7540
7586
  case 2:
@@ -7775,7 +7821,7 @@ var Flicking = /*#__PURE__*/function (_super) {
7775
7821
  * Flicking.VERSION; // ex) 4.0.0
7776
7822
  * ```
7777
7823
  */
7778
- Flicking.VERSION = "4.11.0";
7824
+ Flicking.VERSION = "4.11.1";
7779
7825
  return Flicking;
7780
7826
  }(Component);
7781
7827
 
@@ -8032,6 +8078,7 @@ var modules = {
8032
8078
  MOVE_TYPE: MOVE_TYPE,
8033
8079
  CLASS: CLASS,
8034
8080
  CIRCULAR_FALLBACK: CIRCULAR_FALLBACK,
8081
+ ORDER: ORDER,
8035
8082
  withFlickingMethods: withFlickingMethods,
8036
8083
  sync: sync,
8037
8084
  getRenderingPanels: getRenderingPanels,
@@ -8099,6 +8146,7 @@ exports.IdleState = IdleState;
8099
8146
  exports.LinearCameraMode = LinearCameraMode;
8100
8147
  exports.MOVE_TYPE = MOVE_TYPE;
8101
8148
  exports.NormalRenderingStrategy = NormalRenderingStrategy;
8149
+ exports.ORDER = ORDER;
8102
8150
  exports.Panel = Panel;
8103
8151
  exports.Renderer = Renderer;
8104
8152
  exports.SnapControl = SnapControl;