@egjs/flicking 4.9.3-beta.0 → 4.10.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.
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.9.3-beta.0
7
+ version: 4.10.0
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')) :
@@ -2212,10 +2212,6 @@ version: 4.9.3-beta.0
2212
2212
  return StateMachine;
2213
2213
  }();
2214
2214
 
2215
- /*
2216
- * Copyright (c) 2015 NAVER Corp.
2217
- * egjs projects are licensed under the MIT license
2218
- */
2219
2215
  /**
2220
2216
  * A controller that handles the {@link https://naver.github.io/egjs-axes/ @egjs/axes} events
2221
2217
  * @ko {@link https://naver.github.io/egjs-axes/ @egjs/axes}의 이벤트를 처리하는 컨트롤러 컴포넌트
@@ -2510,6 +2506,44 @@ version: 4.9.3-beta.0
2510
2506
  (_a = this._panInput) === null || _a === void 0 ? void 0 : _a.release();
2511
2507
  return this;
2512
2508
  };
2509
+ /**
2510
+ * Change the destination and duration of the animation currently playing
2511
+ * @ko 재생 중인 애니메이션의 목적지와 재생 시간을 변경합니다
2512
+ * @param {number} position A position to move<ko>이동할 좌표</ko>
2513
+ * @param {number} duration Duration of the animation (unit: ms)<ko>애니메이션 진행 시간 (단위: ms)</ko>
2514
+ * @chainable
2515
+ * @return {this}
2516
+ */
2517
+
2518
+
2519
+ __proto.updateAnimation = function (position, duration) {
2520
+ var _a;
2521
+
2522
+ var _b;
2523
+
2524
+ this._animatingContext = __assign(__assign({}, this._animatingContext), {
2525
+ end: position
2526
+ });
2527
+ (_b = this._axes) === null || _b === void 0 ? void 0 : _b.updateAnimation({
2528
+ destPos: (_a = {}, _a[POSITION_KEY] = position, _a),
2529
+ duration: duration
2530
+ });
2531
+ return this;
2532
+ };
2533
+ /**
2534
+ * Stops the animation currently playing
2535
+ * @ko 재생 중인 애니메이션을 중단시킵니다
2536
+ * @chainable
2537
+ * @return {this}
2538
+ */
2539
+
2540
+
2541
+ __proto.stopAnimation = function () {
2542
+ var _a;
2543
+
2544
+ (_a = this._axes) === null || _a === void 0 ? void 0 : _a.stopAnimation();
2545
+ return this;
2546
+ };
2513
2547
  /**
2514
2548
  * Update {@link https://naver.github.io/egjs-axes/ @egjs/axes}'s state
2515
2549
  * @ko {@link https://naver.github.io/egjs-axes/ @egjs/axes}의 상태를 갱신합니다
@@ -2834,6 +2868,47 @@ version: 4.9.3-beta.0
2834
2868
 
2835
2869
  return this;
2836
2870
  };
2871
+ /**
2872
+ * Change the destination and duration of the animation currently playing
2873
+ * @ko 재생 중인 애니메이션의 목적지와 재생 시간을 변경합니다
2874
+ * @param {Panel} panel The target panel to move<ko>이동할 패널</ko>
2875
+ * @param {number} duration Duration of the animation (unit: ms)<ko>애니메이션 진행 시간 (단위: ms)</ko>
2876
+ * @param {DIRECTION} direction Direction to move, only available in the {@link Flicking#circular circular} mode<ko>이동할 방향. {@link Flicking#circular circular} 옵션 활성화시에만 사용 가능합니다</ko>
2877
+ * @chainable
2878
+ * @throws {FlickingError}
2879
+ * {@link ERROR_CODE POSITION_NOT_REACHABLE} When the given panel is already removed or not in the Camera's {@link Camera#range range}
2880
+ * <ko>{@link ERROR_CODE POSITION_NOT_REACHABLE} 주어진 패널이 제거되었거나, Camera의 {@link Camera#range range} 밖에 있을 경우</ko>
2881
+ * @return {this}
2882
+ */
2883
+
2884
+
2885
+ __proto.updateAnimation = function (panel, duration, direction) {
2886
+ var state = this._controller.state;
2887
+
2888
+ var position = this._getPosition(panel, direction !== null && direction !== void 0 ? direction : DIRECTION.NONE);
2889
+
2890
+ state.targetPanel = panel;
2891
+
2892
+ this._controller.updateAnimation(position, duration);
2893
+
2894
+ return this;
2895
+ };
2896
+ /**
2897
+ * Stops the animation currently playing
2898
+ * @ko 재생 중인 애니메이션을 중단시킵니다
2899
+ * @chainable
2900
+ * @return {this}
2901
+ */
2902
+
2903
+
2904
+ __proto.stopAnimation = function () {
2905
+ var state = this._controller.state;
2906
+ state.targetPanel = null;
2907
+
2908
+ this._controller.stopAnimation();
2909
+
2910
+ return this;
2911
+ };
2837
2912
  /**
2838
2913
  * Update position after resizing
2839
2914
  * @ko resize 이후에 position을 업데이트합니다
@@ -2929,38 +3004,9 @@ version: 4.9.3-beta.0
2929
3004
  direction = _b === void 0 ? DIRECTION.NONE : _b,
2930
3005
  axesEvent = _a.axesEvent;
2931
3006
  return __awaiter(this, void 0, void 0, function () {
2932
- var flicking, camera, position, nearestAnchor, camPos_1, camRangeDiff, possiblePositions;
3007
+ var position;
2933
3008
  return __generator(this, function (_c) {
2934
- flicking = getFlickingAttached(this._flicking);
2935
- camera = flicking.camera;
2936
- position = panel.position;
2937
- nearestAnchor = camera.findNearestAnchor(position);
2938
-
2939
- if (panel.removed || !nearestAnchor) {
2940
- return [2
2941
- /*return*/
2942
- , Promise.reject(new FlickingError(MESSAGE.POSITION_NOT_REACHABLE(panel.position), CODE.POSITION_NOT_REACHABLE))];
2943
- }
2944
-
2945
- if (!camera.canReach(panel)) {
2946
- // Override position & panel if that panel is not reachable
2947
- position = nearestAnchor.position;
2948
- panel = nearestAnchor.panel;
2949
- } else if (flicking.circularEnabled) {
2950
- camPos_1 = this._controller.position;
2951
- camRangeDiff = camera.rangeDiff;
2952
- possiblePositions = [position, position + camRangeDiff, position - camRangeDiff].filter(function (pos) {
2953
- if (direction === DIRECTION.NONE) return true;
2954
- return direction === DIRECTION.PREV ? pos <= camPos_1 : pos >= camPos_1;
2955
- });
2956
- position = possiblePositions.reduce(function (nearestPosition, pos) {
2957
- if (Math.abs(camPos_1 - pos) < Math.abs(camPos_1 - nearestPosition)) {
2958
- return pos;
2959
- } else {
2960
- return nearestPosition;
2961
- }
2962
- }, Infinity);
2963
- }
3009
+ position = this._getPosition(panel, direction);
2964
3010
 
2965
3011
  this._triggerIndexChangeEvent(panel, panel.position, axesEvent);
2966
3012
 
@@ -3077,6 +3123,45 @@ version: 4.9.3-beta.0
3077
3123
  });
3078
3124
  };
3079
3125
 
3126
+ __proto._getPosition = function (panel, direction) {
3127
+ if (direction === void 0) {
3128
+ direction = DIRECTION.NONE;
3129
+ }
3130
+
3131
+ var flicking = getFlickingAttached(this._flicking);
3132
+ var camera = flicking.camera;
3133
+ var position = panel.position;
3134
+ var nearestAnchor = camera.findNearestAnchor(position);
3135
+
3136
+ if (panel.removed || !nearestAnchor) {
3137
+ throw new FlickingError(MESSAGE.POSITION_NOT_REACHABLE(panel.position), CODE.POSITION_NOT_REACHABLE);
3138
+ }
3139
+
3140
+ if (!camera.canReach(panel)) {
3141
+ // Override position & panel if that panel is not reachable
3142
+ position = nearestAnchor.position;
3143
+ panel = nearestAnchor.panel;
3144
+ } else if (flicking.circularEnabled) {
3145
+ // Circular mode is enabled, find nearest distance to panel
3146
+ var camPos_1 = this._controller.position; // Actual position of the Axes
3147
+
3148
+ var camRangeDiff = camera.rangeDiff;
3149
+ var possiblePositions = [position, position + camRangeDiff, position - camRangeDiff].filter(function (pos) {
3150
+ if (direction === DIRECTION.NONE) return true;
3151
+ return direction === DIRECTION.PREV ? pos <= camPos_1 : pos >= camPos_1;
3152
+ });
3153
+ position = possiblePositions.reduce(function (nearestPosition, pos) {
3154
+ if (Math.abs(camPos_1 - pos) < Math.abs(camPos_1 - nearestPosition)) {
3155
+ return pos;
3156
+ } else {
3157
+ return nearestPosition;
3158
+ }
3159
+ }, Infinity);
3160
+ }
3161
+
3162
+ return position;
3163
+ };
3164
+
3080
3165
  return Control;
3081
3166
  }();
3082
3167
 
@@ -8130,6 +8215,49 @@ version: 4.9.3-beta.0
8130
8215
  direction: direction
8131
8216
  });
8132
8217
  };
8218
+ /**
8219
+ * Change the destination and duration of the animation currently playing
8220
+ * @ko 재생 중인 애니메이션의 목적지와 재생 시간을 변경합니다
8221
+ * @param {number} index The index of the panel to move<ko>이동할 패널의 인덱스</ko>
8222
+ * @param {number} duration Duration of the animation (unit: ms)<ko>애니메이션 진행 시간 (단위: ms)</ko>
8223
+ * @param {DIRECTION} direction Direction to move, only available in the {@link Flicking#circular circular} mode<ko>이동할 방향. {@link Flicking#circular circular} 옵션 활성화시에만 사용 가능합니다</ko>
8224
+ * @throws {FlickingError}
8225
+ * {@link ERROR_CODE INDEX_OUT_OF_RANGE} When the root is not either string or HTMLElement
8226
+ * <ko>{@link ERROR_CODE INDEX_OUT_OF_RANGE} 해당 인덱스를 가진 패널이 존재하지 않을 경우</ko>
8227
+ * @return {void}
8228
+ */
8229
+
8230
+
8231
+ __proto.updateAnimation = function (index, duration, direction) {
8232
+ if (!this._control.animating) {
8233
+ return;
8234
+ }
8235
+
8236
+ var renderer = this._renderer;
8237
+ var panelCount = renderer.panelCount;
8238
+ var panel = renderer.getPanel(index);
8239
+
8240
+ if (!panel) {
8241
+ throw new FlickingError(MESSAGE.INDEX_OUT_OF_RANGE(index, 0, panelCount - 1), CODE.INDEX_OUT_OF_RANGE);
8242
+ }
8243
+
8244
+ this._control.updateAnimation(panel, duration, direction);
8245
+ };
8246
+ /**
8247
+ * Stops the animation currently playing
8248
+ * @ko 재생 중인 애니메이션을 중단시킵니다
8249
+ * @fires Flicking#moveEnd
8250
+ * @return {void}
8251
+ */
8252
+
8253
+
8254
+ __proto.stopAnimation = function () {
8255
+ if (!this._control.animating) {
8256
+ return;
8257
+ }
8258
+
8259
+ this._control.stopAnimation();
8260
+ };
8133
8261
  /**
8134
8262
  * Return the {@link Panel} at the given index. `null` if it doesn't exists.
8135
8263
  * @ko 주어진 인덱스에 해당하는 {@link Panel}을 반환합니다. 주어진 인덱스에 해당하는 패널이 존재하지 않을 경우 `null`을 반환합니다.
@@ -8673,7 +8801,7 @@ version: 4.9.3-beta.0
8673
8801
  */
8674
8802
 
8675
8803
 
8676
- Flicking.VERSION = "4.9.3-beta.0";
8804
+ Flicking.VERSION = "4.10.0";
8677
8805
  return Flicking;
8678
8806
  }(Component);
8679
8807