@egjs/flicking 4.10.8 → 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.
@@ -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.10.8
7
+ version: 4.11.1
8
8
  */
9
9
  import Component, { ComponentEvent } from '@egjs/component';
10
10
  import Axes, { PanInput } from '@egjs/axes';
@@ -396,6 +396,17 @@ var CIRCULAR_FALLBACK = {
396
396
  LINEAR: "linear",
397
397
  BOUND: "bound"
398
398
  };
399
+ /**
400
+ * 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`)
401
+ * @ko 카메라 엘리먼트(`.flicking-camera`)에 적용된 {@link https://developer.mozilla.org/en-US/docs/Web/CSS/direction direction} CSS 속성을 구분하기 위한 객체
402
+ * @type {object}
403
+ * @property {string} LTR "ltr"
404
+ * @property {string} RTL "rtl"
405
+ */
406
+ var ORDER = {
407
+ LTR: "ltr",
408
+ RTL: "rtl"
409
+ };
399
410
 
400
411
  // eslint-disable-next-line @typescript-eslint/ban-types
401
412
  var merge = function (target) {
@@ -689,20 +700,22 @@ var getElementSize = function (_a) {
689
700
  useFractionalSize = _a.useFractionalSize,
690
701
  useOffset = _a.useOffset,
691
702
  style = _a.style;
703
+ var size = 0;
692
704
  if (useFractionalSize) {
693
- var baseSize = parseFloat(horizontal ? style.width : style.height);
705
+ var baseSize = parseFloat(horizontal ? style.width : style.height) || 0;
694
706
  var isBorderBoxSizing = style.boxSizing === "border-box";
695
707
  var border = horizontal ? parseFloat(style.borderLeftWidth || "0") + parseFloat(style.borderRightWidth || "0") : parseFloat(style.borderTopWidth || "0") + parseFloat(style.borderBottomWidth || "0");
696
708
  if (isBorderBoxSizing) {
697
- return useOffset ? baseSize : baseSize - border;
709
+ size = useOffset ? baseSize : baseSize - border;
698
710
  } else {
699
711
  var padding = horizontal ? parseFloat(style.paddingLeft || "0") + parseFloat(style.paddingRight || "0") : parseFloat(style.paddingTop || "0") + parseFloat(style.paddingBottom || "0");
700
- return useOffset ? baseSize + padding + border : baseSize + padding;
712
+ size = useOffset ? baseSize + padding + border : baseSize + padding;
701
713
  }
702
714
  } else {
703
715
  var sizeStr = horizontal ? "Width" : "Height";
704
- return useOffset ? el["offset" + sizeStr] : el["client" + sizeStr];
716
+ size = useOffset ? el["offset" + sizeStr] : el["client" + sizeStr];
705
717
  }
718
+ return Math.max(size, 0);
706
719
  };
707
720
  var setPrototypeOf = Object.setPrototypeOf || function (obj, proto) {
708
721
  obj.__proto__ = proto;
@@ -2085,7 +2098,8 @@ var AxesController = /*#__PURE__*/function () {
2085
2098
  inputType: flicking.inputType,
2086
2099
  threshold: 1,
2087
2100
  iOSEdgeSwipeThreshold: flicking.iOSEdgeSwipeThreshold,
2088
- scale: flicking.horizontal ? [-1, 0] : [0, -1],
2101
+ preventDefaultOnDrag: flicking.preventDefaultOnDrag,
2102
+ scale: flicking.horizontal ? [flicking.camera.panelOrder === ORDER.RTL ? 1 : -1, 0] : [0, -1],
2089
2103
  releaseOnScroll: true
2090
2104
  });
2091
2105
  var axes = this._axes;
@@ -2310,7 +2324,7 @@ var AxesController = /*#__PURE__*/function () {
2310
2324
  var panInput = this._panInput;
2311
2325
  axes.disconnect(panInput);
2312
2326
  axes.connect(flicking.horizontal ? [POSITION_KEY, ""] : ["", POSITION_KEY], panInput);
2313
- panInput.options.scale = flicking.horizontal ? [-1, 0] : [0, -1];
2327
+ panInput.options.scale = flicking.horizontal ? [flicking.camera.panelOrder === ORDER.RTL ? 1 : -1, 0] : [0, -1];
2314
2328
  };
2315
2329
  __proto._resetInternalValues = function () {
2316
2330
  this._flicking = null;
@@ -3982,6 +3996,19 @@ var Camera = /*#__PURE__*/function () {
3982
3996
  enumerable: false,
3983
3997
  configurable: true
3984
3998
  });
3999
+ Object.defineProperty(__proto, "panelOrder", {
4000
+ /**
4001
+ * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/direction direction} CSS property applied to the camera element(`.flicking-camera`)
4002
+ * @ko 카메라 엘리먼트(`.flicking-camera`)에 적용된 {@link https://developer.mozilla.org/en-US/docs/Web/CSS/direction direction} CSS 속성
4003
+ * @type {string}
4004
+ * @readonly
4005
+ */
4006
+ get: function () {
4007
+ return this._panelOrder;
4008
+ },
4009
+ enumerable: false,
4010
+ configurable: true
4011
+ });
3985
4012
  Object.defineProperty(__proto, "align", {
3986
4013
  // Options Getter
3987
4014
  /**
@@ -4013,6 +4040,7 @@ var Camera = /*#__PURE__*/function () {
4013
4040
  this._el = viewportEl.firstElementChild;
4014
4041
  this._checkTranslateSupport();
4015
4042
  this._updateMode();
4043
+ this.updatePanelOrder();
4016
4044
  return this;
4017
4045
  };
4018
4046
  /**
@@ -4255,6 +4283,24 @@ var Camera = /*#__PURE__*/function () {
4255
4283
  this.applyTransform();
4256
4284
  return this;
4257
4285
  };
4286
+ /**
4287
+ * Update direction to match the {@link https://developer.mozilla.org/en-US/docs/Web/CSS/direction direction} CSS property applied to the camera element
4288
+ * @ko 카메라 엘리먼트에 적용된 {@link https://developer.mozilla.org/en-US/docs/Web/CSS/direction direction} CSS 속성에 맞게 방향을 업데이트합니다
4289
+ * @return {this}
4290
+ */
4291
+ __proto.updatePanelOrder = function () {
4292
+ var flicking = getFlickingAttached(this._flicking);
4293
+ if (!flicking.horizontal) return this;
4294
+ var el = this._el;
4295
+ var direction = getStyle(el).direction;
4296
+ if (direction !== this._panelOrder) {
4297
+ this._panelOrder = direction === ORDER.RTL ? ORDER.RTL : ORDER.LTR;
4298
+ if (flicking.initialized) {
4299
+ flicking.control.controller.updateDirection();
4300
+ }
4301
+ }
4302
+ return this;
4303
+ };
4258
4304
  /**
4259
4305
  * Reset the history of {@link Flicking#event:needPanel needPanel} events so it can be triggered again
4260
4306
  * @ko 발생한 {@link Flicking#event:needPanel needPanel} 이벤트들을 초기화하여 다시 발생할 수 있도록 합니다
@@ -4279,7 +4325,7 @@ var Camera = /*#__PURE__*/function () {
4279
4325
  var renderer = flicking.renderer;
4280
4326
  if (renderer.rendering || !flicking.initialized) return this;
4281
4327
  var actualPosition = this._position - this._alignPos - this._offset + this._circularOffset;
4282
- el.style[this._transform] = flicking.horizontal ? "translate(" + -actualPosition + "px)" : "translate(0, " + -actualPosition + "px)";
4328
+ el.style[this._transform] = flicking.horizontal ? "translate(" + (this._panelOrder === ORDER.RTL ? actualPosition : -actualPosition) + "px)" : "translate(0, " + -actualPosition + "px)";
4283
4329
  return this;
4284
4330
  };
4285
4331
  __proto._resetInternalValues = function () {
@@ -5963,30 +6009,32 @@ var Flicking = /*#__PURE__*/function (_super) {
5963
6009
  iOSEdgeSwipeThreshold = _z === void 0 ? 30 : _z,
5964
6010
  _0 = _b.preventClickOnDrag,
5965
6011
  preventClickOnDrag = _0 === void 0 ? true : _0,
5966
- _1 = _b.disableOnInit,
5967
- disableOnInit = _1 === void 0 ? false : _1,
5968
- _2 = _b.changeOnHold,
5969
- changeOnHold = _2 === void 0 ? false : _2,
5970
- _3 = _b.renderOnlyVisible,
5971
- renderOnlyVisible = _3 === void 0 ? false : _3,
5972
- _4 = _b.virtual,
5973
- virtual = _4 === void 0 ? null : _4,
5974
- _5 = _b.autoInit,
5975
- autoInit = _5 === void 0 ? true : _5,
5976
- _6 = _b.autoResize,
5977
- autoResize = _6 === void 0 ? true : _6,
5978
- _7 = _b.useResizeObserver,
5979
- useResizeObserver = _7 === void 0 ? true : _7,
5980
- _8 = _b.resizeDebounce,
5981
- resizeDebounce = _8 === void 0 ? 0 : _8,
5982
- _9 = _b.maxResizeDebounce,
5983
- maxResizeDebounce = _9 === void 0 ? 100 : _9,
5984
- _10 = _b.useFractionalSize,
5985
- useFractionalSize = _10 === void 0 ? false : _10,
5986
- _11 = _b.externalRenderer,
5987
- externalRenderer = _11 === void 0 ? null : _11,
5988
- _12 = _b.renderExternal,
5989
- renderExternal = _12 === void 0 ? null : _12;
6012
+ _1 = _b.preventDefaultOnDrag,
6013
+ preventDefaultOnDrag = _1 === void 0 ? false : _1,
6014
+ _2 = _b.disableOnInit,
6015
+ disableOnInit = _2 === void 0 ? false : _2,
6016
+ _3 = _b.changeOnHold,
6017
+ changeOnHold = _3 === void 0 ? false : _3,
6018
+ _4 = _b.renderOnlyVisible,
6019
+ renderOnlyVisible = _4 === void 0 ? false : _4,
6020
+ _5 = _b.virtual,
6021
+ virtual = _5 === void 0 ? null : _5,
6022
+ _6 = _b.autoInit,
6023
+ autoInit = _6 === void 0 ? true : _6,
6024
+ _7 = _b.autoResize,
6025
+ autoResize = _7 === void 0 ? true : _7,
6026
+ _8 = _b.useResizeObserver,
6027
+ useResizeObserver = _8 === void 0 ? true : _8,
6028
+ _9 = _b.resizeDebounce,
6029
+ resizeDebounce = _9 === void 0 ? 0 : _9,
6030
+ _10 = _b.maxResizeDebounce,
6031
+ maxResizeDebounce = _10 === void 0 ? 100 : _10,
6032
+ _11 = _b.useFractionalSize,
6033
+ useFractionalSize = _11 === void 0 ? false : _11,
6034
+ _12 = _b.externalRenderer,
6035
+ externalRenderer = _12 === void 0 ? null : _12,
6036
+ _13 = _b.renderExternal,
6037
+ renderExternal = _13 === void 0 ? null : _13;
5990
6038
  var _this = _super.call(this) || this;
5991
6039
  // Internal states
5992
6040
  _this._initialized = false;
@@ -6016,6 +6064,7 @@ var Flicking = /*#__PURE__*/function (_super) {
6016
6064
  _this._bounce = bounce;
6017
6065
  _this._iOSEdgeSwipeThreshold = iOSEdgeSwipeThreshold;
6018
6066
  _this._preventClickOnDrag = preventClickOnDrag;
6067
+ _this._preventDefaultOnDrag = preventDefaultOnDrag;
6019
6068
  _this._disableOnInit = disableOnInit;
6020
6069
  _this._changeOnHold = changeOnHold;
6021
6070
  _this._renderOnlyVisible = renderOnlyVisible;
@@ -6814,6 +6863,27 @@ var Flicking = /*#__PURE__*/function (_super) {
6814
6863
  enumerable: false,
6815
6864
  configurable: true
6816
6865
  });
6866
+ Object.defineProperty(__proto, "preventDefaultOnDrag", {
6867
+ /**
6868
+ * Whether to use the {@link https://developer.mozilla.org/ko/docs/Web/API/Event/preventDefault preventDefault} when the user starts dragging
6869
+ * @ko 사용자가 드래그를 시작할 때 {@link https://developer.mozilla.org/ko/docs/Web/API/Event/preventDefault preventDefault} 실행 여부
6870
+ * @type {boolean}
6871
+ * @default false
6872
+ * @see {@link https://naver.github.io/egjs-flicking/Options#preventDefaultOnDrag preventDefaultOnDrag ( Options )}
6873
+ */
6874
+ get: function () {
6875
+ return this._preventDefaultOnDrag;
6876
+ },
6877
+ set: function (val) {
6878
+ this._preventDefaultOnDrag = val;
6879
+ var panInput = this._control.controller.panInput;
6880
+ if (panInput) {
6881
+ panInput.options.preventDefaultOnDrag = val;
6882
+ }
6883
+ },
6884
+ enumerable: false,
6885
+ configurable: true
6886
+ });
6817
6887
  Object.defineProperty(__proto, "disableOnInit", {
6818
6888
  /**
6819
6889
  * Automatically call {@link Flicking#disableInput disableInput()} on initialization
@@ -7508,6 +7578,7 @@ var Flicking = /*#__PURE__*/function (_super) {
7508
7578
  camera.updateRange();
7509
7579
  camera.updateAnchors();
7510
7580
  camera.updateAdaptiveHeight();
7581
+ camera.updatePanelOrder();
7511
7582
  camera.updateOffset();
7512
7583
  return [4 /*yield*/, renderer.render()];
7513
7584
  case 2:
@@ -7748,7 +7819,7 @@ var Flicking = /*#__PURE__*/function (_super) {
7748
7819
  * Flicking.VERSION; // ex) 4.0.0
7749
7820
  * ```
7750
7821
  */
7751
- Flicking.VERSION = "4.10.8";
7822
+ Flicking.VERSION = "4.11.1";
7752
7823
  return Flicking;
7753
7824
  }(Component);
7754
7825
 
@@ -7966,5 +8037,5 @@ var parseAlign = function (alignVal) {
7966
8037
  * egjs projects are licensed under the MIT license
7967
8038
  */
7968
8039
 
7969
- export { ALIGN, AnchorPoint, AnimatingState, AxesController, BoundCameraMode, CIRCULAR_FALLBACK, CLASS, Camera, CircularCameraMode, Control, DIRECTION, DisabledState, DraggingState, CODE as ERROR_CODE, EVENTS, ExternalRenderer, FlickingError, FreeControl, HoldingState, IdleState, LinearCameraMode, MOVE_TYPE, NormalRenderingStrategy, Panel, Renderer, SnapControl, State, StateMachine, StrictControl, VanillaElementProvider, VanillaRenderer, Viewport, VirtualElementProvider, VirtualManager, VirtualPanel, VirtualRenderingStrategy, checkExistence, circulateIndex, circulatePosition, clamp, Flicking as default, find, findIndex, findRight, getDefaultCameraTransform, getDirection, getElement, getElementSize, getFlickingAttached, getMinusCompensatedIndex, getProgress, getRenderingPanels, getStyle, includes, isBetween, isString, merge, parseAlign$1 as parseAlign, parseArithmeticExpression, parseArithmeticSize, parseBounce, parseCSSSizeValue, parseElement, parsePanelAlign, range, setPrototypeOf, setSize, sync, toArray, withFlickingMethods };
8040
+ export { ALIGN, AnchorPoint, AnimatingState, AxesController, BoundCameraMode, CIRCULAR_FALLBACK, CLASS, Camera, CircularCameraMode, Control, DIRECTION, DisabledState, DraggingState, CODE as ERROR_CODE, EVENTS, ExternalRenderer, FlickingError, FreeControl, HoldingState, IdleState, LinearCameraMode, MOVE_TYPE, NormalRenderingStrategy, ORDER, Panel, Renderer, SnapControl, State, StateMachine, StrictControl, VanillaElementProvider, VanillaRenderer, Viewport, VirtualElementProvider, VirtualManager, VirtualPanel, VirtualRenderingStrategy, checkExistence, circulateIndex, circulatePosition, clamp, Flicking as default, find, findIndex, findRight, getDefaultCameraTransform, getDirection, getElement, getElementSize, getFlickingAttached, getMinusCompensatedIndex, getProgress, getRenderingPanels, getStyle, includes, isBetween, isString, merge, parseAlign$1 as parseAlign, parseArithmeticExpression, parseArithmeticSize, parseBounce, parseCSSSizeValue, parseElement, parsePanelAlign, range, setPrototypeOf, setSize, sync, toArray, withFlickingMethods };
7970
8041
  //# sourceMappingURL=flicking.esm.js.map