@egjs/flicking 4.6.2 → 4.7.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.
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.6.2
7
+ version: 4.7.1
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')) :
@@ -2306,7 +2306,7 @@ version: 4.6.2
2306
2306
  get: function () {
2307
2307
  var _a, _b;
2308
2308
 
2309
- return (_b = (_a = this._panInput) === null || _a === void 0 ? void 0 : _a.isEnable()) !== null && _b !== void 0 ? _b : false;
2309
+ return (_b = (_a = this._panInput) === null || _a === void 0 ? void 0 : _a.isEnabled()) !== null && _b !== void 0 ? _b : false;
2310
2310
  },
2311
2311
  enumerable: false,
2312
2312
  configurable: true
@@ -2377,6 +2377,7 @@ version: 4.6.2
2377
2377
  }, _a), {
2378
2378
  deceleration: flicking.deceleration,
2379
2379
  interruptable: flicking.interruptable,
2380
+ nested: flicking.nested,
2380
2381
  easing: flicking.easing
2381
2382
  });
2382
2383
  this._panInput = new Axes.PanInput(flicking.viewport.element, {
@@ -2473,7 +2474,7 @@ version: 4.6.2
2473
2474
  axis.circular = [controlParams.circular, controlParams.circular];
2474
2475
  axis.range = [controlParams.range.min, controlParams.range.max];
2475
2476
  axis.bounce = parseBounce(flicking.bounce, camera.size);
2476
- axes.axm.set((_a = {}, _a[POSITION_KEY] = controlParams.position, _a));
2477
+ axes.axisManager.set((_a = {}, _a[POSITION_KEY] = controlParams.position, _a));
2477
2478
  return this;
2478
2479
  };
2479
2480
  /**
@@ -2589,7 +2590,7 @@ version: 4.6.2
2589
2590
  var camera = flicking.camera;
2590
2591
  animate();
2591
2592
  var newPos = flicking.circularEnabled ? circulatePosition(position, camera.range.min, camera.range.max) : position;
2592
- axes.axm.set((_a = {}, _a[POSITION_KEY] = newPos, _a));
2593
+ axes.axisManager.set((_a = {}, _a[POSITION_KEY] = newPos, _a));
2593
2594
  return Promise.resolve();
2594
2595
  } else {
2595
2596
  return new Promise(function (resolve, reject) {
@@ -3614,6 +3615,7 @@ version: 4.6.2
3614
3615
  var lastAnchor = anchors[anchors.length - 1];
3615
3616
  var shouldBounceToFirst = position <= cameraRange.min && isBetween(firstAnchor.panel.index, indexRange.min, indexRange.max);
3616
3617
  var shouldBounceToLast = position >= cameraRange.max && isBetween(lastAnchor.panel.index, indexRange.min, indexRange.max);
3618
+ var isAdjacent = adjacentAnchor && (indexRange.min <= indexRange.max ? isBetween(adjacentAnchor.index, indexRange.min, indexRange.max) : adjacentAnchor.index >= indexRange.min || adjacentAnchor.index <= indexRange.max);
3617
3619
 
3618
3620
  if (shouldBounceToFirst || shouldBounceToLast) {
3619
3621
  // In bounce area
@@ -3624,7 +3626,7 @@ version: 4.6.2
3624
3626
  // Move to anchor at position
3625
3627
  targetPanel = anchorAtPosition.panel;
3626
3628
  targetPos = anchorAtPosition.position;
3627
- } else if (isOverThreshold && adjacentAnchor && isBetween(adjacentAnchor.index, indexRange.min, indexRange.max)) {
3629
+ } else if (isOverThreshold && isAdjacent) {
3628
3630
  // Move to adjacent anchor
3629
3631
  targetPanel = adjacentAnchor.panel;
3630
3632
  targetPos = adjacentAnchor.position;
@@ -3711,6 +3713,27 @@ version: 4.6.2
3711
3713
  }, null);
3712
3714
  };
3713
3715
 
3716
+ __proto.findNearestAnchor = function (position) {
3717
+ var anchors = this._flicking.camera.anchorPoints;
3718
+ if (anchors.length <= 0) return null;
3719
+ var prevDist = Infinity;
3720
+
3721
+ for (var anchorIdx = 0; anchorIdx < anchors.length; anchorIdx++) {
3722
+ var anchor = anchors[anchorIdx];
3723
+ var dist = Math.abs(anchor.position - position);
3724
+
3725
+ if (dist > prevDist) {
3726
+ // Return previous anchor
3727
+ return anchors[anchorIdx - 1];
3728
+ }
3729
+
3730
+ prevDist = dist;
3731
+ } // Return last anchor
3732
+
3733
+
3734
+ return anchors[anchors.length - 1];
3735
+ };
3736
+
3714
3737
  __proto.clampToReachablePosition = function (position) {
3715
3738
  var camera = this._flicking.camera;
3716
3739
  var range = camera.range;
@@ -3840,6 +3863,28 @@ version: 4.6.2
3840
3863
  });
3841
3864
  };
3842
3865
 
3866
+ __proto.findNearestAnchor = function (position) {
3867
+ var camera = this._flicking.camera;
3868
+ var anchors = camera.anchorPoints;
3869
+ if (anchors.length <= 0) return null;
3870
+ var camRange = camera.range;
3871
+ var minDist = Infinity;
3872
+ var minDistIndex = -1;
3873
+
3874
+ for (var anchorIdx = 0; anchorIdx < anchors.length; anchorIdx++) {
3875
+ var anchor = anchors[anchorIdx];
3876
+ var dist = Math.min(Math.abs(anchor.position - position), Math.abs(anchor.position - camRange.min + camRange.max - position), Math.abs(position - camRange.min + camRange.max - anchor.position));
3877
+
3878
+ if (dist < minDist) {
3879
+ minDist = dist;
3880
+ minDistIndex = anchorIdx;
3881
+ }
3882
+ } // Return last anchor
3883
+
3884
+
3885
+ return anchors[minDistIndex];
3886
+ };
3887
+
3843
3888
  __proto.findAnchorIncludePosition = function (position) {
3844
3889
  var camera = this._flicking.camera;
3845
3890
  var range = camera.range;
@@ -4608,24 +4653,7 @@ version: 4.6.2
4608
4653
 
4609
4654
 
4610
4655
  __proto.findNearestAnchor = function (position) {
4611
- var anchors = this._anchors;
4612
- if (anchors.length <= 0) return null;
4613
- var prevDist = Infinity;
4614
-
4615
- for (var anchorIdx = 0; anchorIdx < anchors.length; anchorIdx++) {
4616
- var anchor = anchors[anchorIdx];
4617
- var dist = Math.abs(anchor.position - position);
4618
-
4619
- if (dist > prevDist) {
4620
- // Return previous anchor
4621
- return anchors[anchorIdx - 1];
4622
- }
4623
-
4624
- prevDist = dist;
4625
- } // Return last anchor
4626
-
4627
-
4628
- return anchors[anchors.length - 1];
4656
+ return this._mode.findNearestAnchor(position);
4629
4657
  };
4630
4658
  /**
4631
4659
  * Return {@link AnchorPoint} that matches {@link Flicking#currentPanel}
@@ -5373,7 +5401,7 @@ version: 4.6.2
5373
5401
  if (!resizeOnContentsReady || flicking.virtualEnabled) return;
5374
5402
 
5375
5403
  var hasContents = function (panel) {
5376
- return !!panel.element.querySelector("img, video");
5404
+ return panel.element && !!panel.element.querySelector("img, video");
5377
5405
  };
5378
5406
 
5379
5407
  checkingPanels = checkingPanels.filter(function (panel) {
@@ -6697,52 +6725,54 @@ version: 4.6.2
6697
6725
  noPanelStyleOverride = _l === void 0 ? false : _l,
6698
6726
  _m = _b.resizeOnContentsReady,
6699
6727
  resizeOnContentsReady = _m === void 0 ? false : _m,
6700
- _o = _b.needPanelThreshold,
6701
- needPanelThreshold = _o === void 0 ? 0 : _o,
6702
- _p = _b.preventEventsBeforeInit,
6703
- preventEventsBeforeInit = _p === void 0 ? true : _p,
6704
- _q = _b.deceleration,
6705
- deceleration = _q === void 0 ? 0.0075 : _q,
6706
- _r = _b.duration,
6707
- duration = _r === void 0 ? 500 : _r,
6708
- _s = _b.easing,
6709
- easing = _s === void 0 ? function (x) {
6728
+ _o = _b.nested,
6729
+ nested = _o === void 0 ? false : _o,
6730
+ _p = _b.needPanelThreshold,
6731
+ needPanelThreshold = _p === void 0 ? 0 : _p,
6732
+ _q = _b.preventEventsBeforeInit,
6733
+ preventEventsBeforeInit = _q === void 0 ? true : _q,
6734
+ _r = _b.deceleration,
6735
+ deceleration = _r === void 0 ? 0.0075 : _r,
6736
+ _s = _b.duration,
6737
+ duration = _s === void 0 ? 500 : _s,
6738
+ _t = _b.easing,
6739
+ easing = _t === void 0 ? function (x) {
6710
6740
  return 1 - Math.pow(1 - x, 3);
6711
- } : _s,
6712
- _t = _b.inputType,
6713
- inputType = _t === void 0 ? ["mouse", "touch"] : _t,
6714
- _u = _b.moveType,
6715
- moveType = _u === void 0 ? "snap" : _u,
6716
- _v = _b.threshold,
6717
- threshold = _v === void 0 ? 40 : _v,
6718
- _w = _b.interruptable,
6719
- interruptable = _w === void 0 ? true : _w,
6720
- _x = _b.bounce,
6721
- bounce = _x === void 0 ? "20%" : _x,
6722
- _y = _b.iOSEdgeSwipeThreshold,
6723
- iOSEdgeSwipeThreshold = _y === void 0 ? 30 : _y,
6724
- _z = _b.preventClickOnDrag,
6725
- preventClickOnDrag = _z === void 0 ? true : _z,
6726
- _0 = _b.disableOnInit,
6727
- disableOnInit = _0 === void 0 ? false : _0,
6728
- _1 = _b.renderOnlyVisible,
6729
- renderOnlyVisible = _1 === void 0 ? false : _1,
6730
- _2 = _b.virtual,
6731
- virtual = _2 === void 0 ? null : _2,
6732
- _3 = _b.autoInit,
6733
- autoInit = _3 === void 0 ? true : _3,
6734
- _4 = _b.autoResize,
6735
- autoResize = _4 === void 0 ? true : _4,
6736
- _5 = _b.useResizeObserver,
6737
- useResizeObserver = _5 === void 0 ? true : _5,
6738
- _6 = _b.resizeDebounce,
6739
- resizeDebounce = _6 === void 0 ? 0 : _6,
6740
- _7 = _b.maxResizeDebounce,
6741
- maxResizeDebounce = _7 === void 0 ? 100 : _7,
6742
- _8 = _b.externalRenderer,
6743
- externalRenderer = _8 === void 0 ? null : _8,
6744
- _9 = _b.renderExternal,
6745
- renderExternal = _9 === void 0 ? null : _9;
6741
+ } : _t,
6742
+ _u = _b.inputType,
6743
+ inputType = _u === void 0 ? ["mouse", "touch"] : _u,
6744
+ _v = _b.moveType,
6745
+ moveType = _v === void 0 ? "snap" : _v,
6746
+ _w = _b.threshold,
6747
+ threshold = _w === void 0 ? 40 : _w,
6748
+ _x = _b.interruptable,
6749
+ interruptable = _x === void 0 ? true : _x,
6750
+ _y = _b.bounce,
6751
+ bounce = _y === void 0 ? "20%" : _y,
6752
+ _z = _b.iOSEdgeSwipeThreshold,
6753
+ iOSEdgeSwipeThreshold = _z === void 0 ? 30 : _z,
6754
+ _0 = _b.preventClickOnDrag,
6755
+ preventClickOnDrag = _0 === void 0 ? true : _0,
6756
+ _1 = _b.disableOnInit,
6757
+ disableOnInit = _1 === void 0 ? false : _1,
6758
+ _2 = _b.renderOnlyVisible,
6759
+ renderOnlyVisible = _2 === void 0 ? false : _2,
6760
+ _3 = _b.virtual,
6761
+ virtual = _3 === void 0 ? null : _3,
6762
+ _4 = _b.autoInit,
6763
+ autoInit = _4 === void 0 ? true : _4,
6764
+ _5 = _b.autoResize,
6765
+ autoResize = _5 === void 0 ? true : _5,
6766
+ _6 = _b.useResizeObserver,
6767
+ useResizeObserver = _6 === void 0 ? true : _6,
6768
+ _7 = _b.resizeDebounce,
6769
+ resizeDebounce = _7 === void 0 ? 0 : _7,
6770
+ _8 = _b.maxResizeDebounce,
6771
+ maxResizeDebounce = _8 === void 0 ? 100 : _8,
6772
+ _9 = _b.externalRenderer,
6773
+ externalRenderer = _9 === void 0 ? null : _9,
6774
+ _10 = _b.renderExternal,
6775
+ renderExternal = _10 === void 0 ? null : _10;
6746
6776
 
6747
6777
  var _this = _super.call(this) || this; // Internal states
6748
6778
 
@@ -6760,6 +6790,7 @@ version: 4.6.2
6760
6790
  _this._panelsPerView = panelsPerView;
6761
6791
  _this._noPanelStyleOverride = noPanelStyleOverride;
6762
6792
  _this._resizeOnContentsReady = resizeOnContentsReady;
6793
+ _this._nested = nested;
6763
6794
  _this._virtual = virtual;
6764
6795
  _this._needPanelThreshold = needPanelThreshold;
6765
6796
  _this._preventEventsBeforeInit = preventEventsBeforeInit;
@@ -7233,6 +7264,24 @@ version: 4.6.2
7233
7264
  enumerable: false,
7234
7265
  configurable: true
7235
7266
  });
7267
+ Object.defineProperty(__proto, "nested", {
7268
+ /**
7269
+ * If you enable this option on child Flicking when the Flicking is placed inside the Flicking, the parent Flicking will move in the same direction after the child Flicking reaches the first/last panel.
7270
+ * If the parent Flicking and child Flicking have different horizontal option, you do not need to set this option.
7271
+ * @ko Flicking 내부에 Flicking이 배치될 때 하위 Flicking에서 이 옵션을 활성화하면 하위 Flicking이 첫/마지막 패널에 도달한 뒤부터 같은 방향으로 상위 Flicking이 움직입니다.
7272
+ * 만약 상위 Flicking과 하위 Flicking이 서로 다른 horizontal 옵션을 가지고 있다면 이 옵션을 설정할 필요가 없습니다.
7273
+ * @type {boolean}
7274
+ * @default false
7275
+ */
7276
+ get: function () {
7277
+ return this._nested;
7278
+ },
7279
+ set: function (val) {
7280
+ this._nested = val;
7281
+ },
7282
+ enumerable: false,
7283
+ configurable: true
7284
+ });
7236
7285
  Object.defineProperty(__proto, "needPanelThreshold", {
7237
7286
  // EVENTS
7238
7287
 
@@ -8469,7 +8518,7 @@ version: 4.6.2
8469
8518
  */
8470
8519
 
8471
8520
 
8472
- Flicking.VERSION = "4.6.2";
8521
+ Flicking.VERSION = "4.7.1";
8473
8522
  return Flicking;
8474
8523
  }(Component);
8475
8524