@egjs/flicking 4.9.3 → 4.10.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.
@@ -206,6 +206,8 @@ declare class Flicking extends Component<FlickingEvents> {
206
206
  prev(duration?: number): Promise<void>;
207
207
  next(duration?: number): Promise<void>;
208
208
  moveTo(index: number, duration?: number, direction?: ValueOf<typeof DIRECTION>): Promise<void>;
209
+ updateAnimation(index: number, duration?: number, direction?: ValueOf<typeof DIRECTION>): void;
210
+ stopAnimation(): void;
209
211
  getPanel(index: number): Panel | null;
210
212
  enableInput(): this;
211
213
  disableInput(): this;
@@ -28,6 +28,8 @@ declare class AxesController {
28
28
  enable(): this;
29
29
  disable(): this;
30
30
  release(): this;
31
+ updateAnimation(position: number, duration?: number): this;
32
+ stopAnimation(): this;
31
33
  update(controlParams: ControlParams): this;
32
34
  addPreventClickHandler(): this;
33
35
  removePreventClickHandler(): this;
@@ -20,6 +20,8 @@ declare abstract class Control {
20
20
  enable(): this;
21
21
  disable(): this;
22
22
  release(): this;
23
+ updateAnimation(panel: Panel, duration?: number, direction?: ValueOf<typeof DIRECTION>): this;
24
+ stopAnimation(): this;
23
25
  updatePosition(progressInPanel: number): void;
24
26
  updateInput(): this;
25
27
  resetActive(): this;
@@ -36,5 +38,6 @@ declare abstract class Control {
36
38
  newActivePanel: Panel;
37
39
  axesEvent?: OnRelease;
38
40
  }): Promise<void>;
41
+ private _getPosition;
39
42
  }
40
43
  export default Control;
@@ -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.9.3
7
+ version: 4.10.1
8
8
  */
9
9
  import Component, { ComponentEvent } from '@egjs/component';
10
10
  import Axes, { PanInput } from '@egjs/axes';
@@ -2166,10 +2166,6 @@ function () {
2166
2166
  return StateMachine;
2167
2167
  }();
2168
2168
 
2169
- /*
2170
- * Copyright (c) 2015 NAVER Corp.
2171
- * egjs projects are licensed under the MIT license
2172
- */
2173
2169
  /**
2174
2170
  * A controller that handles the {@link https://naver.github.io/egjs-axes/ @egjs/axes} events
2175
2171
  * @ko {@link https://naver.github.io/egjs-axes/ @egjs/axes}의 이벤트를 처리하는 컨트롤러 컴포넌트
@@ -2379,6 +2375,7 @@ function () {
2379
2375
  });
2380
2376
  this._panInput = new PanInput(flicking.viewport.element, {
2381
2377
  inputType: flicking.inputType,
2378
+ threshold: 1,
2382
2379
  iOSEdgeSwipeThreshold: flicking.iOSEdgeSwipeThreshold,
2383
2380
  scale: flicking.horizontal ? [-1, 0] : [0, -1],
2384
2381
  releaseOnScroll: true
@@ -2464,6 +2461,44 @@ function () {
2464
2461
  (_a = this._panInput) === null || _a === void 0 ? void 0 : _a.release();
2465
2462
  return this;
2466
2463
  };
2464
+ /**
2465
+ * Change the destination and duration of the animation currently playing
2466
+ * @ko 재생 중인 애니메이션의 목적지와 재생 시간을 변경합니다
2467
+ * @param {number} position A position to move<ko>이동할 좌표</ko>
2468
+ * @param {number} duration Duration of the animation (unit: ms)<ko>애니메이션 진행 시간 (단위: ms)</ko>
2469
+ * @chainable
2470
+ * @return {this}
2471
+ */
2472
+
2473
+
2474
+ __proto.updateAnimation = function (position, duration) {
2475
+ var _a;
2476
+
2477
+ var _b;
2478
+
2479
+ this._animatingContext = __assign(__assign({}, this._animatingContext), {
2480
+ end: position
2481
+ });
2482
+ (_b = this._axes) === null || _b === void 0 ? void 0 : _b.updateAnimation({
2483
+ destPos: (_a = {}, _a[POSITION_KEY] = position, _a),
2484
+ duration: duration
2485
+ });
2486
+ return this;
2487
+ };
2488
+ /**
2489
+ * Stops the animation currently playing
2490
+ * @ko 재생 중인 애니메이션을 중단시킵니다
2491
+ * @chainable
2492
+ * @return {this}
2493
+ */
2494
+
2495
+
2496
+ __proto.stopAnimation = function () {
2497
+ var _a;
2498
+
2499
+ (_a = this._axes) === null || _a === void 0 ? void 0 : _a.stopAnimation();
2500
+ return this;
2501
+ };
2467
2502
  /**
2468
2503
  * Update {@link https://naver.github.io/egjs-axes/ @egjs/axes}'s state
2469
2504
  * @ko {@link https://naver.github.io/egjs-axes/ @egjs/axes}의 상태를 갱신합니다
@@ -2788,6 +2823,47 @@ function () {
2788
2823
 
2789
2824
  return this;
2790
2825
  };
2826
+ /**
2827
+ * Change the destination and duration of the animation currently playing
2828
+ * @ko 재생 중인 애니메이션의 목적지와 재생 시간을 변경합니다
2829
+ * @param {Panel} panel The target panel to move<ko>이동할 패널</ko>
2830
+ * @param {number} duration Duration of the animation (unit: ms)<ko>애니메이션 진행 시간 (단위: ms)</ko>
2831
+ * @param {DIRECTION} direction Direction to move, only available in the {@link Flicking#circular circular} mode<ko>이동할 방향. {@link Flicking#circular circular} 옵션 활성화시에만 사용 가능합니다</ko>
2832
+ * @chainable
2833
+ * @throws {FlickingError}
2834
+ * {@link ERROR_CODE POSITION_NOT_REACHABLE} When the given panel is already removed or not in the Camera's {@link Camera#range range}
2835
+ * <ko>{@link ERROR_CODE POSITION_NOT_REACHABLE} 주어진 패널이 제거되었거나, Camera의 {@link Camera#range range} 밖에 있을 경우</ko>
2836
+ * @return {this}
2837
+ */
2838
+
2839
+
2840
+ __proto.updateAnimation = function (panel, duration, direction) {
2841
+ var state = this._controller.state;
2842
+
2843
+ var position = this._getPosition(panel, direction !== null && direction !== void 0 ? direction : DIRECTION.NONE);
2844
+
2845
+ state.targetPanel = panel;
2846
+
2847
+ this._controller.updateAnimation(position, duration);
2848
+
2849
+ return this;
2850
+ };
2851
+ /**
2852
+ * Stops the animation currently playing
2853
+ * @ko 재생 중인 애니메이션을 중단시킵니다
2854
+ * @chainable
2855
+ * @return {this}
2856
+ */
2857
+
2858
+
2859
+ __proto.stopAnimation = function () {
2860
+ var state = this._controller.state;
2861
+ state.targetPanel = null;
2862
+
2863
+ this._controller.stopAnimation();
2864
+
2865
+ return this;
2866
+ };
2791
2867
  /**
2792
2868
  * Update position after resizing
2793
2869
  * @ko resize 이후에 position을 업데이트합니다
@@ -2883,38 +2959,9 @@ function () {
2883
2959
  direction = _b === void 0 ? DIRECTION.NONE : _b,
2884
2960
  axesEvent = _a.axesEvent;
2885
2961
  return __awaiter(this, void 0, void 0, function () {
2886
- var flicking, camera, position, nearestAnchor, camPos_1, camRangeDiff, possiblePositions;
2962
+ var position;
2887
2963
  return __generator(this, function (_c) {
2888
- flicking = getFlickingAttached(this._flicking);
2889
- camera = flicking.camera;
2890
- position = panel.position;
2891
- nearestAnchor = camera.findNearestAnchor(position);
2892
-
2893
- if (panel.removed || !nearestAnchor) {
2894
- return [2
2895
- /*return*/
2896
- , Promise.reject(new FlickingError(MESSAGE.POSITION_NOT_REACHABLE(panel.position), CODE.POSITION_NOT_REACHABLE))];
2897
- }
2898
-
2899
- if (!camera.canReach(panel)) {
2900
- // Override position & panel if that panel is not reachable
2901
- position = nearestAnchor.position;
2902
- panel = nearestAnchor.panel;
2903
- } else if (flicking.circularEnabled) {
2904
- camPos_1 = this._controller.position;
2905
- camRangeDiff = camera.rangeDiff;
2906
- possiblePositions = [position, position + camRangeDiff, position - camRangeDiff].filter(function (pos) {
2907
- if (direction === DIRECTION.NONE) return true;
2908
- return direction === DIRECTION.PREV ? pos <= camPos_1 : pos >= camPos_1;
2909
- });
2910
- position = possiblePositions.reduce(function (nearestPosition, pos) {
2911
- if (Math.abs(camPos_1 - pos) < Math.abs(camPos_1 - nearestPosition)) {
2912
- return pos;
2913
- } else {
2914
- return nearestPosition;
2915
- }
2916
- }, Infinity);
2917
- }
2964
+ position = this._getPosition(panel, direction);
2918
2965
 
2919
2966
  this._triggerIndexChangeEvent(panel, panel.position, axesEvent);
2920
2967
 
@@ -3031,6 +3078,45 @@ function () {
3031
3078
  });
3032
3079
  };
3033
3080
 
3081
+ __proto._getPosition = function (panel, direction) {
3082
+ if (direction === void 0) {
3083
+ direction = DIRECTION.NONE;
3084
+ }
3085
+
3086
+ var flicking = getFlickingAttached(this._flicking);
3087
+ var camera = flicking.camera;
3088
+ var position = panel.position;
3089
+ var nearestAnchor = camera.findNearestAnchor(position);
3090
+
3091
+ if (panel.removed || !nearestAnchor) {
3092
+ throw new FlickingError(MESSAGE.POSITION_NOT_REACHABLE(panel.position), CODE.POSITION_NOT_REACHABLE);
3093
+ }
3094
+
3095
+ if (!camera.canReach(panel)) {
3096
+ // Override position & panel if that panel is not reachable
3097
+ position = nearestAnchor.position;
3098
+ panel = nearestAnchor.panel;
3099
+ } else if (flicking.circularEnabled) {
3100
+ // Circular mode is enabled, find nearest distance to panel
3101
+ var camPos_1 = this._controller.position; // Actual position of the Axes
3102
+
3103
+ var camRangeDiff = camera.rangeDiff;
3104
+ var possiblePositions = [position, position + camRangeDiff, position - camRangeDiff].filter(function (pos) {
3105
+ if (direction === DIRECTION.NONE) return true;
3106
+ return direction === DIRECTION.PREV ? pos <= camPos_1 : pos >= camPos_1;
3107
+ });
3108
+ position = possiblePositions.reduce(function (nearestPosition, pos) {
3109
+ if (Math.abs(camPos_1 - pos) < Math.abs(camPos_1 - nearestPosition)) {
3110
+ return pos;
3111
+ } else {
3112
+ return nearestPosition;
3113
+ }
3114
+ }, Infinity);
3115
+ }
3116
+
3117
+ return position;
3118
+ };
3119
+
3034
3120
  return Control;
3035
3121
  }();
3036
3122
 
@@ -8036,6 +8122,49 @@ function (_super) {
8036
8122
  direction: direction
8037
8123
  });
8038
8124
  };
8125
+ /**
8126
+ * Change the destination and duration of the animation currently playing
8127
+ * @ko 재생 중인 애니메이션의 목적지와 재생 시간을 변경합니다
8128
+ * @param {number} index The index of the panel to move<ko>이동할 패널의 인덱스</ko>
8129
+ * @param {number} duration Duration of the animation (unit: ms)<ko>애니메이션 진행 시간 (단위: ms)</ko>
8130
+ * @param {DIRECTION} direction Direction to move, only available in the {@link Flicking#circular circular} mode<ko>이동할 방향. {@link Flicking#circular circular} 옵션 활성화시에만 사용 가능합니다</ko>
8131
+ * @throws {FlickingError}
8132
+ * {@link ERROR_CODE INDEX_OUT_OF_RANGE} When the root is not either string or HTMLElement
8133
+ * <ko>{@link ERROR_CODE INDEX_OUT_OF_RANGE} 해당 인덱스를 가진 패널이 존재하지 않을 경우</ko>
8134
+ * @return {void}
8135
+ */
8136
+
8137
+
8138
+ __proto.updateAnimation = function (index, duration, direction) {
8139
+ if (!this._control.animating) {
8140
+ return;
8141
+ }
8142
+
8143
+ var renderer = this._renderer;
8144
+ var panelCount = renderer.panelCount;
8145
+ var panel = renderer.getPanel(index);
8146
+
8147
+ if (!panel) {
8148
+ throw new FlickingError(MESSAGE.INDEX_OUT_OF_RANGE(index, 0, panelCount - 1), CODE.INDEX_OUT_OF_RANGE);
8149
+ }
8150
+
8151
+ this._control.updateAnimation(panel, duration, direction);
8152
+ };
8153
+ /**
8154
+ * Stops the animation currently playing
8155
+ * @ko 재생 중인 애니메이션을 중단시킵니다
8156
+ * @fires Flicking#moveEnd
8157
+ * @return {void}
8158
+ */
8159
+
8160
+
8161
+ __proto.stopAnimation = function () {
8162
+ if (!this._control.animating) {
8163
+ return;
8164
+ }
8165
+
8166
+ this._control.stopAnimation();
8167
+ };
8039
8168
  /**
8040
8169
  * Return the {@link Panel} at the given index. `null` if it doesn't exists.
8041
8170
  * @ko 주어진 인덱스에 해당하는 {@link Panel}을 반환합니다. 주어진 인덱스에 해당하는 패널이 존재하지 않을 경우 `null`을 반환합니다.
@@ -8579,7 +8708,7 @@ function (_super) {
8579
8708
  */
8580
8709
 
8581
8710
 
8582
- Flicking.VERSION = "4.9.3";
8711
+ Flicking.VERSION = "4.10.1";
8583
8712
  return Flicking;
8584
8713
  }(Component);
8585
8714