@egjs/flicking 4.11.0 → 4.11.2-beta.0

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
7
+ version: 4.11.2-beta.0
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;
@@ -2086,7 +2099,7 @@ var AxesController = /*#__PURE__*/function () {
2086
2099
  threshold: 1,
2087
2100
  iOSEdgeSwipeThreshold: flicking.iOSEdgeSwipeThreshold,
2088
2101
  preventDefaultOnDrag: flicking.preventDefaultOnDrag,
2089
- scale: flicking.horizontal ? [-1, 0] : [0, -1],
2102
+ scale: flicking.horizontal ? [flicking.camera.panelOrder === ORDER.RTL ? 1 : -1, 0] : [0, -1],
2090
2103
  releaseOnScroll: true
2091
2104
  });
2092
2105
  var axes = this._axes;
@@ -2311,7 +2324,7 @@ var AxesController = /*#__PURE__*/function () {
2311
2324
  var panInput = this._panInput;
2312
2325
  axes.disconnect(panInput);
2313
2326
  axes.connect(flicking.horizontal ? [POSITION_KEY, ""] : ["", POSITION_KEY], panInput);
2314
- 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];
2315
2328
  };
2316
2329
  __proto._resetInternalValues = function () {
2317
2330
  this._flicking = null;
@@ -2593,6 +2606,7 @@ var Control = /*#__PURE__*/function () {
2593
2606
  var _a;
2594
2607
  var flicking = getFlickingAttached(this._flicking);
2595
2608
  this._activePanel = newActivePanel;
2609
+ this._nextPanel = null;
2596
2610
  flicking.camera.updateAdaptiveHeight();
2597
2611
  if (newActivePanel !== prevActivePanel) {
2598
2612
  flicking.trigger(new ComponentEvent(EVENTS.CHANGED, {
@@ -2629,6 +2643,7 @@ var Control = /*#__PURE__*/function () {
2629
2643
  isTrusted: (axesEvent === null || axesEvent === void 0 ? void 0 : axesEvent.isTrusted) || false,
2630
2644
  direction: getDirection((_a = activePanel === null || activePanel === void 0 ? void 0 : activePanel.position) !== null && _a !== void 0 ? _a : camera.position, position)
2631
2645
  });
2646
+ this._nextPanel = panel;
2632
2647
  flicking.trigger(event);
2633
2648
  if (event.isCanceled()) {
2634
2649
  throw new FlickingError(MESSAGE.STOP_CALLED_BY_USER, CODE.STOP_CALLED_BY_USER);
@@ -3216,19 +3231,20 @@ var StrictControl = /*#__PURE__*/function (_super) {
3216
3231
  * @return {Promise<void>} A Promise which will be resolved after reaching the target position<ko>해당 좌표 도달시에 resolve되는 Promise</ko>
3217
3232
  */
3218
3233
  __proto.moveToPosition = function (position, duration, axesEvent) {
3234
+ var _a;
3219
3235
  var flicking = getFlickingAttached(this._flicking);
3220
3236
  var camera = flicking.camera;
3221
- var activePanel = this._activePanel;
3237
+ var currentPanel = (_a = this._nextPanel) !== null && _a !== void 0 ? _a : this._activePanel;
3222
3238
  var axesRange = this._controller.range;
3223
3239
  var indexRange = this._indexRange;
3224
3240
  var cameraRange = camera.range;
3225
3241
  var state = this._controller.state;
3226
3242
  var clampedPosition = clamp(camera.clampToReachablePosition(position), axesRange[0], axesRange[1]);
3227
3243
  var anchorAtPosition = camera.findAnchorIncludePosition(clampedPosition);
3228
- if (!anchorAtPosition || !activePanel) {
3244
+ if (!anchorAtPosition || !currentPanel) {
3229
3245
  return Promise.reject(new FlickingError(MESSAGE.POSITION_NOT_REACHABLE(position), CODE.POSITION_NOT_REACHABLE));
3230
3246
  }
3231
- var prevPos = activePanel.position;
3247
+ var prevPos = currentPanel.position;
3232
3248
  var posDelta = flicking.animating ? state.delta : position - camera.position;
3233
3249
  var isOverThreshold = Math.abs(posDelta) >= flicking.threshold;
3234
3250
  var adjacentAnchor = position > prevPos ? camera.getNextAnchor(anchorAtPosition) : camera.getPrevAnchor(anchorAtPosition);
@@ -3245,7 +3261,7 @@ var StrictControl = /*#__PURE__*/function (_super) {
3245
3261
  var targetAnchor = position < cameraRange.min ? firstAnchor : lastAnchor;
3246
3262
  targetPanel = targetAnchor.panel;
3247
3263
  targetPos = targetAnchor.position;
3248
- } else if (isOverThreshold && anchorAtPosition.position !== activePanel.position) {
3264
+ } else if (isOverThreshold && anchorAtPosition.position !== currentPanel.position) {
3249
3265
  // Move to anchor at position
3250
3266
  targetPanel = anchorAtPosition.panel;
3251
3267
  targetPos = anchorAtPosition.position;
@@ -3983,6 +3999,19 @@ var Camera = /*#__PURE__*/function () {
3983
3999
  enumerable: false,
3984
4000
  configurable: true
3985
4001
  });
4002
+ Object.defineProperty(__proto, "panelOrder", {
4003
+ /**
4004
+ * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/direction direction} CSS property applied to the camera element(`.flicking-camera`)
4005
+ * @ko 카메라 엘리먼트(`.flicking-camera`)에 적용된 {@link https://developer.mozilla.org/en-US/docs/Web/CSS/direction direction} CSS 속성
4006
+ * @type {string}
4007
+ * @readonly
4008
+ */
4009
+ get: function () {
4010
+ return this._panelOrder;
4011
+ },
4012
+ enumerable: false,
4013
+ configurable: true
4014
+ });
3986
4015
  Object.defineProperty(__proto, "align", {
3987
4016
  // Options Getter
3988
4017
  /**
@@ -4014,6 +4043,7 @@ var Camera = /*#__PURE__*/function () {
4014
4043
  this._el = viewportEl.firstElementChild;
4015
4044
  this._checkTranslateSupport();
4016
4045
  this._updateMode();
4046
+ this.updatePanelOrder();
4017
4047
  return this;
4018
4048
  };
4019
4049
  /**
@@ -4256,6 +4286,24 @@ var Camera = /*#__PURE__*/function () {
4256
4286
  this.applyTransform();
4257
4287
  return this;
4258
4288
  };
4289
+ /**
4290
+ * Update direction to match the {@link https://developer.mozilla.org/en-US/docs/Web/CSS/direction direction} CSS property applied to the camera element
4291
+ * @ko 카메라 엘리먼트에 적용된 {@link https://developer.mozilla.org/en-US/docs/Web/CSS/direction direction} CSS 속성에 맞게 방향을 업데이트합니다
4292
+ * @return {this}
4293
+ */
4294
+ __proto.updatePanelOrder = function () {
4295
+ var flicking = getFlickingAttached(this._flicking);
4296
+ if (!flicking.horizontal) return this;
4297
+ var el = this._el;
4298
+ var direction = getStyle(el).direction;
4299
+ if (direction !== this._panelOrder) {
4300
+ this._panelOrder = direction === ORDER.RTL ? ORDER.RTL : ORDER.LTR;
4301
+ if (flicking.initialized) {
4302
+ flicking.control.controller.updateDirection();
4303
+ }
4304
+ }
4305
+ return this;
4306
+ };
4259
4307
  /**
4260
4308
  * Reset the history of {@link Flicking#event:needPanel needPanel} events so it can be triggered again
4261
4309
  * @ko 발생한 {@link Flicking#event:needPanel needPanel} 이벤트들을 초기화하여 다시 발생할 수 있도록 합니다
@@ -4280,7 +4328,7 @@ var Camera = /*#__PURE__*/function () {
4280
4328
  var renderer = flicking.renderer;
4281
4329
  if (renderer.rendering || !flicking.initialized) return this;
4282
4330
  var actualPosition = this._position - this._alignPos - this._offset + this._circularOffset;
4283
- el.style[this._transform] = flicking.horizontal ? "translate(" + -actualPosition + "px)" : "translate(0, " + -actualPosition + "px)";
4331
+ el.style[this._transform] = flicking.horizontal ? "translate(" + (this._panelOrder === ORDER.RTL ? actualPosition : -actualPosition) + "px)" : "translate(0, " + -actualPosition + "px)";
4284
4332
  return this;
4285
4333
  };
4286
4334
  __proto._resetInternalValues = function () {
@@ -7533,6 +7581,7 @@ var Flicking = /*#__PURE__*/function (_super) {
7533
7581
  camera.updateRange();
7534
7582
  camera.updateAnchors();
7535
7583
  camera.updateAdaptiveHeight();
7584
+ camera.updatePanelOrder();
7536
7585
  camera.updateOffset();
7537
7586
  return [4 /*yield*/, renderer.render()];
7538
7587
  case 2:
@@ -7773,7 +7822,7 @@ var Flicking = /*#__PURE__*/function (_super) {
7773
7822
  * Flicking.VERSION; // ex) 4.0.0
7774
7823
  * ```
7775
7824
  */
7776
- Flicking.VERSION = "4.11.0";
7825
+ Flicking.VERSION = "4.11.2-beta.0";
7777
7826
  return Flicking;
7778
7827
  }(Component);
7779
7828
 
@@ -7991,5 +8040,5 @@ var parseAlign = function (alignVal) {
7991
8040
  * egjs projects are licensed under the MIT license
7992
8041
  */
7993
8042
 
7994
- 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 };
8043
+ 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 };
7995
8044
  //# sourceMappingURL=flicking.esm.js.map