@egjs/flicking 4.6.1 → 4.6.2

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.6.1
7
+ version: 4.6.2
8
8
  */
9
9
  (function (global, factory) {
10
10
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -8325,6 +8325,8 @@ version: 4.6.1
8325
8325
  };
8326
8326
 
8327
8327
  __proto.onRelease = function (ctx) {
8328
+ var _a;
8329
+
8328
8330
  var flicking = ctx.flicking,
8329
8331
  axesEvent = ctx.axesEvent,
8330
8332
  transitTo = ctx.transitTo; // Update last position to cope with Axes's animating behavior
@@ -8344,7 +8346,13 @@ version: 4.6.1
8344
8346
  var control = flicking.control;
8345
8347
  var position = axesEvent.destPos[POSITION_KEY];
8346
8348
  var duration = Math.max(axesEvent.duration, flicking.duration);
8347
- void control.moveToPosition(position, duration, axesEvent);
8349
+
8350
+ try {
8351
+ void control.moveToPosition(position, duration, axesEvent);
8352
+ } catch (err) {
8353
+ transitTo(STATE_TYPE.IDLE);
8354
+ axesEvent.setTo((_a = {}, _a[POSITION_KEY] = flicking.camera.position, _a), 0);
8355
+ }
8348
8356
  };
8349
8357
 
8350
8358
  return DraggingState;
@@ -8420,7 +8428,11 @@ version: 4.6.1
8420
8428
  direction: getDirection$1(animatingContext.start, animatingContext.end),
8421
8429
  axesEvent: axesEvent
8422
8430
  }));
8423
- control.setActive(this._targetPanel, control.activePanel, axesEvent.isTrusted);
8431
+ var targetPanel = this._targetPanel;
8432
+
8433
+ if (targetPanel) {
8434
+ control.setActive(targetPanel, control.activePanel, axesEvent.isTrusted);
8435
+ }
8424
8436
  };
8425
8437
 
8426
8438
  return AnimatingState;
@@ -9175,7 +9187,7 @@ version: 4.6.1
9175
9187
  */
9176
9188
 
9177
9189
 
9178
- __proto.updatePosition = function (_progressInPanel) {
9190
+ __proto.updatePosition = function (progressInPanel) {
9179
9191
  var flicking = getFlickingAttached(this._flicking);
9180
9192
  var camera = flicking.camera;
9181
9193
  var activePanel = this._activePanel;
@@ -9551,48 +9563,41 @@ version: 4.6.1
9551
9563
  */
9552
9564
 
9553
9565
  __proto.moveToPosition = function (position, duration, axesEvent) {
9554
- return __awaiter(this, void 0, void 0, function () {
9555
- var flicking, camera, activeAnchor, anchorAtCamera, state, snapThreshold, posDelta, absPosDelta, snapDelta, targetAnchor;
9556
- return __generator(this, function (_a) {
9557
- flicking = getFlickingAttached(this._flicking);
9558
- camera = flicking.camera;
9559
- activeAnchor = camera.findActiveAnchor();
9560
- anchorAtCamera = camera.findNearestAnchor(camera.position);
9561
- state = flicking.control.controller.state;
9566
+ var flicking = getFlickingAttached(this._flicking);
9567
+ var camera = flicking.camera;
9568
+ var activeAnchor = camera.findActiveAnchor();
9569
+ var anchorAtCamera = camera.findNearestAnchor(camera.position);
9570
+ var state = flicking.control.controller.state;
9562
9571
 
9563
- if (!activeAnchor || !anchorAtCamera) {
9564
- return [2
9565
- /*return*/
9566
- , Promise.reject(new FlickingError(MESSAGE.POSITION_NOT_REACHABLE(position), CODE.POSITION_NOT_REACHABLE))];
9567
- }
9572
+ if (!activeAnchor || !anchorAtCamera) {
9573
+ return Promise.reject(new FlickingError(MESSAGE.POSITION_NOT_REACHABLE(position), CODE.POSITION_NOT_REACHABLE));
9574
+ }
9568
9575
 
9569
- snapThreshold = this._calcSnapThreshold(position, activeAnchor);
9570
- posDelta = flicking.animating ? state.delta : position - camera.position;
9571
- absPosDelta = Math.abs(posDelta);
9572
- snapDelta = axesEvent && axesEvent.delta[POSITION_KEY] !== 0 ? Math.abs(axesEvent.delta[POSITION_KEY]) : absPosDelta;
9573
-
9574
- if (snapDelta >= snapThreshold && snapDelta > 0) {
9575
- // Move to anchor at position
9576
- targetAnchor = this._findSnappedAnchor(position, anchorAtCamera);
9577
- } else if (absPosDelta >= flicking.threshold && absPosDelta > 0) {
9578
- // Move to the adjacent panel
9579
- targetAnchor = this._findAdjacentAnchor(posDelta, anchorAtCamera);
9580
- } else {
9581
- // Restore to active panel
9582
- targetAnchor = anchorAtCamera;
9583
- }
9576
+ var snapThreshold = this._calcSnapThreshold(position, activeAnchor);
9584
9577
 
9585
- this._triggerIndexChangeEvent(targetAnchor.panel, position, axesEvent);
9578
+ var posDelta = flicking.animating ? state.delta : position - camera.position;
9579
+ var absPosDelta = Math.abs(posDelta);
9580
+ var snapDelta = axesEvent && axesEvent.delta[POSITION_KEY] !== 0 ? Math.abs(axesEvent.delta[POSITION_KEY]) : absPosDelta;
9581
+ var targetAnchor;
9586
9582
 
9587
- return [2
9588
- /*return*/
9589
- , this._animateToPosition({
9590
- position: camera.clampToReachablePosition(targetAnchor.position),
9591
- duration: duration,
9592
- newActivePanel: targetAnchor.panel,
9593
- axesEvent: axesEvent
9594
- })];
9595
- });
9583
+ if (snapDelta >= snapThreshold && snapDelta > 0) {
9584
+ // Move to anchor at position
9585
+ targetAnchor = this._findSnappedAnchor(position, anchorAtCamera);
9586
+ } else if (absPosDelta >= flicking.threshold && absPosDelta > 0) {
9587
+ // Move to the adjacent panel
9588
+ targetAnchor = this._findAdjacentAnchor(posDelta, anchorAtCamera);
9589
+ } else {
9590
+ // Restore to active panel
9591
+ targetAnchor = anchorAtCamera;
9592
+ }
9593
+
9594
+ this._triggerIndexChangeEvent(targetAnchor.panel, position, axesEvent);
9595
+
9596
+ return this._animateToPosition({
9597
+ position: camera.clampToReachablePosition(targetAnchor.position),
9598
+ duration: duration,
9599
+ newActivePanel: targetAnchor.panel,
9600
+ axesEvent: axesEvent
9596
9601
  });
9597
9602
  };
9598
9603
 
@@ -9781,35 +9786,26 @@ version: 4.6.1
9781
9786
 
9782
9787
 
9783
9788
  __proto.moveToPosition = function (position, duration, axesEvent) {
9784
- return __awaiter(this, void 0, void 0, function () {
9785
- var flicking, camera, targetPos, anchorAtPosition, targetPanel;
9786
- return __generator(this, function (_a) {
9787
- flicking = getFlickingAttached(this._flicking);
9788
- camera = flicking.camera;
9789
- targetPos = camera.clampToReachablePosition(position);
9790
- anchorAtPosition = camera.findAnchorIncludePosition(targetPos);
9789
+ var flicking = getFlickingAttached(this._flicking);
9790
+ var camera = flicking.camera;
9791
+ var targetPos = camera.clampToReachablePosition(position);
9792
+ var anchorAtPosition = camera.findAnchorIncludePosition(targetPos);
9791
9793
 
9792
- if (!anchorAtPosition) {
9793
- return [2
9794
- /*return*/
9795
- , Promise.reject(new FlickingError(MESSAGE.POSITION_NOT_REACHABLE(position), CODE.POSITION_NOT_REACHABLE))];
9796
- }
9794
+ if (!anchorAtPosition) {
9795
+ return Promise.reject(new FlickingError(MESSAGE.POSITION_NOT_REACHABLE(position), CODE.POSITION_NOT_REACHABLE));
9796
+ }
9797
9797
 
9798
- targetPanel = anchorAtPosition.panel; // Trigger only change event
9798
+ var targetPanel = anchorAtPosition.panel; // Trigger only change event
9799
9799
 
9800
- if (targetPanel !== this._activePanel) {
9801
- this._triggerIndexChangeEvent(targetPanel, position, axesEvent);
9802
- }
9800
+ if (targetPanel !== this._activePanel) {
9801
+ this._triggerIndexChangeEvent(targetPanel, position, axesEvent);
9802
+ }
9803
9803
 
9804
- return [2
9805
- /*return*/
9806
- , this._animateToPosition({
9807
- position: this._stopAtEdge ? targetPos : position,
9808
- duration: duration,
9809
- newActivePanel: targetPanel,
9810
- axesEvent: axesEvent
9811
- })];
9812
- });
9804
+ return this._animateToPosition({
9805
+ position: this._stopAtEdge ? targetPos : position,
9806
+ duration: duration,
9807
+ newActivePanel: targetPanel,
9808
+ axesEvent: axesEvent
9813
9809
  });
9814
9810
  };
9815
9811
 
@@ -10007,62 +10003,56 @@ version: 4.6.1
10007
10003
 
10008
10004
 
10009
10005
  __proto.moveToPosition = function (position, duration, axesEvent) {
10010
- return __awaiter(this, void 0, void 0, function () {
10011
- var flicking, camera, activePanel, axesRange, indexRange, cameraRange, clampedPosition, anchorAtPosition, prevPos, isOverThreshold, adjacentAnchor, targetPos, targetPanel, anchors, firstAnchor, lastAnchor, shouldBounceToFirst, shouldBounceToLast, targetAnchor;
10012
- return __generator(this, function (_a) {
10013
- flicking = getFlickingAttached(this._flicking);
10014
- camera = flicking.camera;
10015
- activePanel = this._activePanel;
10016
- axesRange = this._controller.range;
10017
- indexRange = this._indexRange;
10018
- cameraRange = camera.range;
10019
- clampedPosition = clamp(camera.clampToReachablePosition(position), axesRange[0], axesRange[1]);
10020
- anchorAtPosition = camera.findAnchorIncludePosition(clampedPosition);
10021
-
10022
- if (!anchorAtPosition || !activePanel) {
10023
- return [2
10024
- /*return*/
10025
- , Promise.reject(new FlickingError(MESSAGE.POSITION_NOT_REACHABLE(position), CODE.POSITION_NOT_REACHABLE))];
10026
- }
10006
+ var flicking = getFlickingAttached(this._flicking);
10007
+ var camera = flicking.camera;
10008
+ var activePanel = this._activePanel;
10009
+ var axesRange = this._controller.range;
10010
+ var indexRange = this._indexRange;
10011
+ var cameraRange = camera.range;
10012
+ var clampedPosition = clamp(camera.clampToReachablePosition(position), axesRange[0], axesRange[1]);
10013
+ var anchorAtPosition = camera.findAnchorIncludePosition(clampedPosition);
10027
10014
 
10028
- prevPos = activePanel.position;
10029
- isOverThreshold = Math.abs(position - prevPos) >= flicking.threshold;
10030
- adjacentAnchor = position > prevPos ? camera.getNextAnchor(anchorAtPosition) : camera.getPrevAnchor(anchorAtPosition);
10031
- anchors = camera.anchorPoints;
10032
- firstAnchor = anchors[0];
10033
- lastAnchor = anchors[anchors.length - 1];
10034
- shouldBounceToFirst = position <= cameraRange.min && isBetween(firstAnchor.panel.index, indexRange.min, indexRange.max);
10035
- shouldBounceToLast = position >= cameraRange.max && isBetween(lastAnchor.panel.index, indexRange.min, indexRange.max);
10036
-
10037
- if (shouldBounceToFirst || shouldBounceToLast) {
10038
- targetAnchor = position < cameraRange.min ? firstAnchor : lastAnchor;
10039
- targetPanel = targetAnchor.panel;
10040
- targetPos = targetAnchor.position;
10041
- } else if (isOverThreshold && anchorAtPosition.position !== activePanel.position) {
10042
- // Move to anchor at position
10043
- targetPanel = anchorAtPosition.panel;
10044
- targetPos = anchorAtPosition.position;
10045
- } else if (isOverThreshold && adjacentAnchor && isBetween(adjacentAnchor.index, indexRange.min, indexRange.max)) {
10046
- // Move to adjacent anchor
10047
- targetPanel = adjacentAnchor.panel;
10048
- targetPos = adjacentAnchor.position;
10049
- } else {
10050
- // Restore to active panel
10051
- targetPos = camera.clampToReachablePosition(activePanel.position);
10052
- targetPanel = activePanel;
10053
- }
10015
+ if (!anchorAtPosition || !activePanel) {
10016
+ return Promise.reject(new FlickingError(MESSAGE.POSITION_NOT_REACHABLE(position), CODE.POSITION_NOT_REACHABLE));
10017
+ }
10018
+
10019
+ var prevPos = activePanel.position;
10020
+ var isOverThreshold = Math.abs(position - prevPos) >= flicking.threshold;
10021
+ var adjacentAnchor = position > prevPos ? camera.getNextAnchor(anchorAtPosition) : camera.getPrevAnchor(anchorAtPosition);
10022
+ var targetPos;
10023
+ var targetPanel;
10024
+ var anchors = camera.anchorPoints;
10025
+ var firstAnchor = anchors[0];
10026
+ var lastAnchor = anchors[anchors.length - 1];
10027
+ var shouldBounceToFirst = position <= cameraRange.min && isBetween(firstAnchor.panel.index, indexRange.min, indexRange.max);
10028
+ var shouldBounceToLast = position >= cameraRange.max && isBetween(lastAnchor.panel.index, indexRange.min, indexRange.max);
10029
+
10030
+ if (shouldBounceToFirst || shouldBounceToLast) {
10031
+ // In bounce area
10032
+ var targetAnchor = position < cameraRange.min ? firstAnchor : lastAnchor;
10033
+ targetPanel = targetAnchor.panel;
10034
+ targetPos = targetAnchor.position;
10035
+ } else if (isOverThreshold && anchorAtPosition.position !== activePanel.position) {
10036
+ // Move to anchor at position
10037
+ targetPanel = anchorAtPosition.panel;
10038
+ targetPos = anchorAtPosition.position;
10039
+ } else if (isOverThreshold && adjacentAnchor && isBetween(adjacentAnchor.index, indexRange.min, indexRange.max)) {
10040
+ // Move to adjacent anchor
10041
+ targetPanel = adjacentAnchor.panel;
10042
+ targetPos = adjacentAnchor.position;
10043
+ } else {
10044
+ // Restore to active panel
10045
+ targetPos = camera.clampToReachablePosition(activePanel.position);
10046
+ targetPanel = activePanel;
10047
+ }
10054
10048
 
10055
- this._triggerIndexChangeEvent(targetPanel, position, axesEvent);
10049
+ this._triggerIndexChangeEvent(targetPanel, position, axesEvent);
10056
10050
 
10057
- return [2
10058
- /*return*/
10059
- , this._animateToPosition({
10060
- position: targetPos,
10061
- duration: duration,
10062
- newActivePanel: targetPanel,
10063
- axesEvent: axesEvent
10064
- })];
10065
- });
10051
+ return this._animateToPosition({
10052
+ position: targetPos,
10053
+ duration: duration,
10054
+ newActivePanel: targetPanel,
10055
+ axesEvent: axesEvent
10066
10056
  });
10067
10057
  };
10068
10058
 
@@ -12751,29 +12741,31 @@ version: 4.6.1
12751
12741
 
12752
12742
  void this.render();
12753
12743
 
12754
- if (!activePanel || activePanel.removed) {
12755
- if (panels.length <= 0) {
12756
- // All panels removed
12757
- camera.lookAt(0);
12758
- } else {
12759
- var targetIndex = (_a = activePanel === null || activePanel === void 0 ? void 0 : activePanel.index) !== null && _a !== void 0 ? _a : 0;
12744
+ if (!flicking.animating) {
12745
+ if (!activePanel || activePanel.removed) {
12746
+ if (panels.length <= 0) {
12747
+ // All panels removed
12748
+ camera.lookAt(0);
12749
+ } else {
12750
+ var targetIndex = (_a = activePanel === null || activePanel === void 0 ? void 0 : activePanel.index) !== null && _a !== void 0 ? _a : 0;
12760
12751
 
12761
- if (targetIndex > panels.length - 1) {
12762
- targetIndex = panels.length - 1;
12763
- }
12752
+ if (targetIndex > panels.length - 1) {
12753
+ targetIndex = panels.length - 1;
12754
+ }
12764
12755
 
12765
- void control.moveToPanel(panels[targetIndex], {
12756
+ void control.moveToPanel(panels[targetIndex], {
12757
+ duration: 0
12758
+ }).catch(function () {
12759
+ return void 0;
12760
+ });
12761
+ }
12762
+ } else {
12763
+ void control.moveToPanel(activePanel, {
12766
12764
  duration: 0
12767
12765
  }).catch(function () {
12768
12766
  return void 0;
12769
12767
  });
12770
12768
  }
12771
- } else {
12772
- void control.moveToPanel(control.activePanel, {
12773
- duration: 0
12774
- }).catch(function () {
12775
- return void 0;
12776
- });
12777
12769
  }
12778
12770
 
12779
12771
  flicking.camera.updateOffset();
@@ -15896,7 +15888,7 @@ version: 4.6.1
15896
15888
  */
15897
15889
 
15898
15890
 
15899
- Flicking.VERSION = "4.6.1";
15891
+ Flicking.VERSION = "4.6.2";
15900
15892
  return Flicking;
15901
15893
  }(Component$1);
15902
15894
 
@@ -16067,7 +16059,9 @@ version: 4.6.1
16067
16059
  }
16068
16060
  }
16069
16061
 
16070
- renderer.updateAfterPanelChange(added, removed);
16062
+ if (diffResult.added.length > 0 || diffResult.removed.length > 0) {
16063
+ renderer.updateAfterPanelChange(added, removed);
16064
+ }
16071
16065
  });
16072
16066
 
16073
16067
  var batchInsert = function (renderer, diffResult, addedElements, startIdx, endIdx) {