@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.
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
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')) :
@@ -12,7 +12,7 @@ version: 4.11.0-snapshot
12
12
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Flicking = factory(global.eg.Component, global.eg.Axes, global.eg.ImReady));
13
13
  })(this, (function (Component, Axes, ImReady) { '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 = function (d, b) {
32
32
  extendStatics = 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(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) 2015 NAVER Corp.
@@ -398,6 +402,17 @@ version: 4.11.0-snapshot
398
402
  LINEAR: "linear",
399
403
  BOUND: "bound"
400
404
  };
405
+ /**
406
+ * 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`)
407
+ * @ko 카메라 엘리먼트(`.flicking-camera`)에 적용된 {@link https://developer.mozilla.org/en-US/docs/Web/CSS/direction direction} CSS 속성을 구분하기 위한 객체
408
+ * @type {object}
409
+ * @property {string} LTR "ltr"
410
+ * @property {string} RTL "rtl"
411
+ */
412
+ var ORDER = {
413
+ LTR: "ltr",
414
+ RTL: "rtl"
415
+ };
401
416
 
402
417
  var Constants = {
403
418
  __proto__: null,
@@ -407,6 +422,7 @@ version: 4.11.0-snapshot
407
422
  MOVE_TYPE: MOVE_TYPE,
408
423
  CLASS: CLASS,
409
424
  CIRCULAR_FALLBACK: CIRCULAR_FALLBACK,
425
+ ORDER: ORDER,
410
426
  ERROR_CODE: CODE
411
427
  };
412
428
 
@@ -702,20 +718,22 @@ version: 4.11.0-snapshot
702
718
  useFractionalSize = _a.useFractionalSize,
703
719
  useOffset = _a.useOffset,
704
720
  style = _a.style;
721
+ var size = 0;
705
722
  if (useFractionalSize) {
706
- var baseSize = parseFloat(horizontal ? style.width : style.height);
723
+ var baseSize = parseFloat(horizontal ? style.width : style.height) || 0;
707
724
  var isBorderBoxSizing = style.boxSizing === "border-box";
708
725
  var border = horizontal ? parseFloat(style.borderLeftWidth || "0") + parseFloat(style.borderRightWidth || "0") : parseFloat(style.borderTopWidth || "0") + parseFloat(style.borderBottomWidth || "0");
709
726
  if (isBorderBoxSizing) {
710
- return useOffset ? baseSize : baseSize - border;
727
+ size = useOffset ? baseSize : baseSize - border;
711
728
  } else {
712
729
  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;
730
+ size = useOffset ? baseSize + padding + border : baseSize + padding;
714
731
  }
715
732
  } else {
716
733
  var sizeStr = horizontal ? "Width" : "Height";
717
- return useOffset ? el["offset" + sizeStr] : el["client" + sizeStr];
734
+ size = useOffset ? el["offset" + sizeStr] : el["client" + sizeStr];
718
735
  }
736
+ return Math.max(size, 0);
719
737
  };
720
738
  var setPrototypeOf = Object.setPrototypeOf || function (obj, proto) {
721
739
  obj.__proto__ = proto;
@@ -2132,7 +2150,7 @@ version: 4.11.0-snapshot
2132
2150
  threshold: 1,
2133
2151
  iOSEdgeSwipeThreshold: flicking.iOSEdgeSwipeThreshold,
2134
2152
  preventDefaultOnDrag: flicking.preventDefaultOnDrag,
2135
- scale: flicking.horizontal ? [-1, 0] : [0, -1],
2153
+ scale: flicking.horizontal ? [flicking.camera.panelOrder === ORDER.RTL ? 1 : -1, 0] : [0, -1],
2136
2154
  releaseOnScroll: true
2137
2155
  });
2138
2156
  var axes = this._axes;
@@ -2357,7 +2375,7 @@ version: 4.11.0-snapshot
2357
2375
  var panInput = this._panInput;
2358
2376
  axes.disconnect(panInput);
2359
2377
  axes.connect(flicking.horizontal ? [POSITION_KEY, ""] : ["", POSITION_KEY], panInput);
2360
- panInput.options.scale = flicking.horizontal ? [-1, 0] : [0, -1];
2378
+ panInput.options.scale = flicking.horizontal ? [flicking.camera.panelOrder === ORDER.RTL ? 1 : -1, 0] : [0, -1];
2361
2379
  };
2362
2380
  __proto._resetInternalValues = function () {
2363
2381
  this._flicking = null;
@@ -2622,7 +2640,7 @@ version: 4.11.0-snapshot
2622
2640
  var position;
2623
2641
  return __generator(this, function (_c) {
2624
2642
  position = this._getPosition(panel, direction);
2625
- this._triggerIndexChangeEvent(panel, panel.position, axesEvent);
2643
+ this._triggerIndexChangeEvent(panel, panel.position, axesEvent, direction);
2626
2644
  return [2 /*return*/, this._animateToPosition({
2627
2645
  position: position,
2628
2646
  duration: duration,
@@ -2639,6 +2657,7 @@ version: 4.11.0-snapshot
2639
2657
  var _a;
2640
2658
  var flicking = getFlickingAttached(this._flicking);
2641
2659
  this._activePanel = newActivePanel;
2660
+ this._nextPanel = null;
2642
2661
  flicking.camera.updateAdaptiveHeight();
2643
2662
  if (newActivePanel !== prevActivePanel) {
2644
2663
  flicking.trigger(new Component.ComponentEvent(EVENTS.CHANGED, {
@@ -2663,7 +2682,7 @@ version: 4.11.0-snapshot
2663
2682
  this._activePanel = control._activePanel;
2664
2683
  this._controller = control._controller;
2665
2684
  };
2666
- __proto._triggerIndexChangeEvent = function (panel, position, axesEvent) {
2685
+ __proto._triggerIndexChangeEvent = function (panel, position, axesEvent, direction) {
2667
2686
  var _a;
2668
2687
  var flicking = getFlickingAttached(this._flicking);
2669
2688
  var triggeringEvent = panel !== this._activePanel ? EVENTS.WILL_CHANGE : EVENTS.WILL_RESTORE;
@@ -2673,8 +2692,9 @@ version: 4.11.0-snapshot
2673
2692
  index: panel.index,
2674
2693
  panel: panel,
2675
2694
  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)
2695
+ 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
2696
  });
2697
+ this._nextPanel = panel;
2678
2698
  flicking.trigger(event);
2679
2699
  if (event.isCanceled()) {
2680
2700
  throw new FlickingError(MESSAGE.STOP_CALLED_BY_USER, CODE.STOP_CALLED_BY_USER);
@@ -2893,7 +2913,7 @@ version: 4.11.0-snapshot
2893
2913
  if (!activeAnchor || !anchorAtCamera) {
2894
2914
  return Promise.reject(new FlickingError(MESSAGE.POSITION_NOT_REACHABLE(position), CODE.POSITION_NOT_REACHABLE));
2895
2915
  }
2896
- var snapThreshold = this._calcSnapThreshold(position, activeAnchor);
2916
+ var snapThreshold = this._calcSnapThreshold(flicking.threshold, position, activeAnchor);
2897
2917
  var posDelta = flicking.animating ? state.delta : position - camera.position;
2898
2918
  var absPosDelta = Math.abs(posDelta);
2899
2919
  var snapDelta = axesEvent && axesEvent.delta[POSITION_KEY] !== 0 ? Math.abs(axesEvent.delta[POSITION_KEY]) : absPosDelta;
@@ -2980,7 +3000,7 @@ version: 4.11.0-snapshot
2980
3000
  var adjacentAnchor = (_a = posDelta > 0 ? camera.getNextAnchor(anchorAtCamera) : camera.getPrevAnchor(anchorAtCamera)) !== null && _a !== void 0 ? _a : anchorAtCamera;
2981
3001
  return adjacentAnchor;
2982
3002
  };
2983
- __proto._calcSnapThreshold = function (position, activeAnchor) {
3003
+ __proto._calcSnapThreshold = function (threshold, position, activeAnchor) {
2984
3004
  var isNextDirection = position > activeAnchor.position;
2985
3005
  var panel = activeAnchor.panel;
2986
3006
  var panelSize = panel.size;
@@ -2991,7 +3011,7 @@ version: 4.11.0-snapshot
2991
3011
  * |<------>|<------------>|
2992
3012
  * [ |<-Anchor ]
2993
3013
  */
2994
- return isNextDirection ? panelSize - alignPos + panel.margin.next : alignPos + panel.margin.prev;
3014
+ return Math.max(threshold, isNextDirection ? panelSize - alignPos + panel.margin.next : alignPos + panel.margin.prev);
2995
3015
  };
2996
3016
  return SnapControl;
2997
3017
  }(Control$1);
@@ -3262,19 +3282,20 @@ version: 4.11.0-snapshot
3262
3282
  * @return {Promise<void>} A Promise which will be resolved after reaching the target position<ko>해당 좌표 도달시에 resolve되는 Promise</ko>
3263
3283
  */
3264
3284
  __proto.moveToPosition = function (position, duration, axesEvent) {
3285
+ var _a;
3265
3286
  var flicking = getFlickingAttached(this._flicking);
3266
3287
  var camera = flicking.camera;
3267
- var activePanel = this._activePanel;
3288
+ var currentPanel = (_a = this._nextPanel) !== null && _a !== void 0 ? _a : this._activePanel;
3268
3289
  var axesRange = this._controller.range;
3269
3290
  var indexRange = this._indexRange;
3270
3291
  var cameraRange = camera.range;
3271
3292
  var state = this._controller.state;
3272
3293
  var clampedPosition = clamp(camera.clampToReachablePosition(position), axesRange[0], axesRange[1]);
3273
3294
  var anchorAtPosition = camera.findAnchorIncludePosition(clampedPosition);
3274
- if (!anchorAtPosition || !activePanel) {
3295
+ if (!anchorAtPosition || !currentPanel) {
3275
3296
  return Promise.reject(new FlickingError(MESSAGE.POSITION_NOT_REACHABLE(position), CODE.POSITION_NOT_REACHABLE));
3276
3297
  }
3277
- var prevPos = activePanel.position;
3298
+ var prevPos = currentPanel.position;
3278
3299
  var posDelta = flicking.animating ? state.delta : position - camera.position;
3279
3300
  var isOverThreshold = Math.abs(posDelta) >= flicking.threshold;
3280
3301
  var adjacentAnchor = position > prevPos ? camera.getNextAnchor(anchorAtPosition) : camera.getPrevAnchor(anchorAtPosition);
@@ -3291,7 +3312,7 @@ version: 4.11.0-snapshot
3291
3312
  var targetAnchor = position < cameraRange.min ? firstAnchor : lastAnchor;
3292
3313
  targetPanel = targetAnchor.panel;
3293
3314
  targetPos = targetAnchor.position;
3294
- } else if (isOverThreshold && anchorAtPosition.position !== activePanel.position) {
3315
+ } else if (isOverThreshold && anchorAtPosition.position !== currentPanel.position) {
3295
3316
  // Move to anchor at position
3296
3317
  targetPanel = anchorAtPosition.panel;
3297
3318
  targetPos = anchorAtPosition.position;
@@ -4050,6 +4071,19 @@ version: 4.11.0-snapshot
4050
4071
  enumerable: false,
4051
4072
  configurable: true
4052
4073
  });
4074
+ Object.defineProperty(__proto, "panelOrder", {
4075
+ /**
4076
+ * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/direction direction} CSS property applied to the camera element(`.flicking-camera`)
4077
+ * @ko 카메라 엘리먼트(`.flicking-camera`)에 적용된 {@link https://developer.mozilla.org/en-US/docs/Web/CSS/direction direction} CSS 속성
4078
+ * @type {string}
4079
+ * @readonly
4080
+ */
4081
+ get: function () {
4082
+ return this._panelOrder;
4083
+ },
4084
+ enumerable: false,
4085
+ configurable: true
4086
+ });
4053
4087
  Object.defineProperty(__proto, "align", {
4054
4088
  // Options Getter
4055
4089
  /**
@@ -4081,6 +4115,7 @@ version: 4.11.0-snapshot
4081
4115
  this._el = viewportEl.firstElementChild;
4082
4116
  this._checkTranslateSupport();
4083
4117
  this._updateMode();
4118
+ this.updatePanelOrder();
4084
4119
  return this;
4085
4120
  };
4086
4121
  /**
@@ -4202,11 +4237,13 @@ version: 4.11.0-snapshot
4202
4237
  * @return {AnchorPoint | null}
4203
4238
  */
4204
4239
  __proto.findActiveAnchor = function () {
4240
+ var _a;
4205
4241
  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
- });
4242
+ var activePanel = flicking.control.activePanel;
4243
+ if (!activePanel) return null;
4244
+ return (_a = find(this._anchors, function (anchor) {
4245
+ return anchor.panel.index === activePanel.index;
4246
+ })) !== null && _a !== void 0 ? _a : this.findNearestAnchor(activePanel.position);
4210
4247
  };
4211
4248
  /**
4212
4249
  * Clamp the given position between camera's range
@@ -4323,6 +4360,24 @@ version: 4.11.0-snapshot
4323
4360
  this.applyTransform();
4324
4361
  return this;
4325
4362
  };
4363
+ /**
4364
+ * Update direction to match the {@link https://developer.mozilla.org/en-US/docs/Web/CSS/direction direction} CSS property applied to the camera element
4365
+ * @ko 카메라 엘리먼트에 적용된 {@link https://developer.mozilla.org/en-US/docs/Web/CSS/direction direction} CSS 속성에 맞게 방향을 업데이트합니다
4366
+ * @return {this}
4367
+ */
4368
+ __proto.updatePanelOrder = function () {
4369
+ var flicking = getFlickingAttached(this._flicking);
4370
+ if (!flicking.horizontal) return this;
4371
+ var el = this._el;
4372
+ var direction = getStyle(el).direction;
4373
+ if (direction !== this._panelOrder) {
4374
+ this._panelOrder = direction === ORDER.RTL ? ORDER.RTL : ORDER.LTR;
4375
+ if (flicking.initialized) {
4376
+ flicking.control.controller.updateDirection();
4377
+ }
4378
+ }
4379
+ return this;
4380
+ };
4326
4381
  /**
4327
4382
  * Reset the history of {@link Flicking#event:needPanel needPanel} events so it can be triggered again
4328
4383
  * @ko 발생한 {@link Flicking#event:needPanel needPanel} 이벤트들을 초기화하여 다시 발생할 수 있도록 합니다
@@ -4347,7 +4402,7 @@ version: 4.11.0-snapshot
4347
4402
  var renderer = flicking.renderer;
4348
4403
  if (renderer.rendering || !flicking.initialized) return this;
4349
4404
  var actualPosition = this._position - this._alignPos - this._offset + this._circularOffset;
4350
- el.style[this._transform] = flicking.horizontal ? "translate(" + -actualPosition + "px)" : "translate(0, " + -actualPosition + "px)";
4405
+ el.style[this._transform] = flicking.horizontal ? "translate(" + (this._panelOrder === ORDER.RTL ? actualPosition : -actualPosition) + "px)" : "translate(0, " + -actualPosition + "px)";
4351
4406
  return this;
4352
4407
  };
4353
4408
  __proto._resetInternalValues = function () {
@@ -7622,15 +7677,24 @@ version: 4.11.0-snapshot
7622
7677
  return [4 /*yield*/, renderer.forceRenderAllPanels()];
7623
7678
  case 1:
7624
7679
  _a.sent(); // Render all panel elements, to update sizes
7680
+ if (!this._initialized) {
7681
+ return [2 /*return*/];
7682
+ }
7683
+
7625
7684
  renderer.updatePanelSize();
7626
7685
  camera.updateAlignPos();
7627
7686
  camera.updateRange();
7628
7687
  camera.updateAnchors();
7629
7688
  camera.updateAdaptiveHeight();
7689
+ camera.updatePanelOrder();
7630
7690
  camera.updateOffset();
7631
7691
  return [4 /*yield*/, renderer.render()];
7632
7692
  case 2:
7633
7693
  _a.sent();
7694
+ if (!this._initialized) {
7695
+ return [2 /*return*/];
7696
+ }
7697
+
7634
7698
  if (control.animating) ; else {
7635
7699
  control.updatePosition(prevProgressInPanel);
7636
7700
  control.updateInput();
@@ -7867,7 +7931,7 @@ version: 4.11.0-snapshot
7867
7931
  * Flicking.VERSION; // ex) 4.0.0
7868
7932
  * ```
7869
7933
  */
7870
- Flicking.VERSION = "4.11.0-snapshot";
7934
+ Flicking.VERSION = "4.11.3";
7871
7935
  return Flicking;
7872
7936
  }(Component);
7873
7937