@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/declaration/Flicking.d.ts +2 -0
- package/declaration/control/AxesController.d.ts +2 -0
- package/declaration/control/Control.d.ts +3 -0
- package/dist/flicking.esm.js +165 -37
- package/dist/flicking.esm.js.map +1 -1
- package/dist/flicking.js +165 -37
- package/dist/flicking.js.map +1 -1
- package/dist/flicking.min.js +2 -2
- package/dist/flicking.min.js.map +1 -1
- package/dist/flicking.pkgd.js +187 -46
- package/dist/flicking.pkgd.js.map +1 -1
- package/dist/flicking.pkgd.min.js +2 -2
- package/dist/flicking.pkgd.min.js.map +1 -1
- package/package.json +6 -3
- package/src/Flicking.ts +42 -0
- package/src/control/AxesController.ts +33 -0
- package/src/control/Control.ts +77 -35
|
@@ -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;
|
package/dist/flicking.esm.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.
|
|
7
|
+
version: 4.10.0
|
|
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}의 이벤트를 처리하는 컨트롤러 컴포넌트
|
|
@@ -2464,6 +2460,44 @@ function () {
|
|
|
2464
2460
|
(_a = this._panInput) === null || _a === void 0 ? void 0 : _a.release();
|
|
2465
2461
|
return this;
|
|
2466
2462
|
};
|
|
2463
|
+
/**
|
|
2464
|
+
* Change the destination and duration of the animation currently playing
|
|
2465
|
+
* @ko 재생 중인 애니메이션의 목적지와 재생 시간을 변경합니다
|
|
2466
|
+
* @param {number} position A position to move<ko>이동할 좌표</ko>
|
|
2467
|
+
* @param {number} duration Duration of the animation (unit: ms)<ko>애니메이션 진행 시간 (단위: ms)</ko>
|
|
2468
|
+
* @chainable
|
|
2469
|
+
* @return {this}
|
|
2470
|
+
*/
|
|
2471
|
+
|
|
2472
|
+
|
|
2473
|
+
__proto.updateAnimation = function (position, duration) {
|
|
2474
|
+
var _a;
|
|
2475
|
+
|
|
2476
|
+
var _b;
|
|
2477
|
+
|
|
2478
|
+
this._animatingContext = __assign(__assign({}, this._animatingContext), {
|
|
2479
|
+
end: position
|
|
2480
|
+
});
|
|
2481
|
+
(_b = this._axes) === null || _b === void 0 ? void 0 : _b.updateAnimation({
|
|
2482
|
+
destPos: (_a = {}, _a[POSITION_KEY] = position, _a),
|
|
2483
|
+
duration: duration
|
|
2484
|
+
});
|
|
2485
|
+
return this;
|
|
2486
|
+
};
|
|
2487
|
+
/**
|
|
2488
|
+
* Stops the animation currently playing
|
|
2489
|
+
* @ko 재생 중인 애니메이션을 중단시킵니다
|
|
2490
|
+
* @chainable
|
|
2491
|
+
* @return {this}
|
|
2492
|
+
*/
|
|
2493
|
+
|
|
2494
|
+
|
|
2495
|
+
__proto.stopAnimation = function () {
|
|
2496
|
+
var _a;
|
|
2497
|
+
|
|
2498
|
+
(_a = this._axes) === null || _a === void 0 ? void 0 : _a.stopAnimation();
|
|
2499
|
+
return this;
|
|
2500
|
+
};
|
|
2467
2501
|
/**
|
|
2468
2502
|
* Update {@link https://naver.github.io/egjs-axes/ @egjs/axes}'s state
|
|
2469
2503
|
* @ko {@link https://naver.github.io/egjs-axes/ @egjs/axes}의 상태를 갱신합니다
|
|
@@ -2788,6 +2822,47 @@ function () {
|
|
|
2788
2822
|
|
|
2789
2823
|
return this;
|
|
2790
2824
|
};
|
|
2825
|
+
/**
|
|
2826
|
+
* Change the destination and duration of the animation currently playing
|
|
2827
|
+
* @ko 재생 중인 애니메이션의 목적지와 재생 시간을 변경합니다
|
|
2828
|
+
* @param {Panel} panel The target panel to move<ko>이동할 패널</ko>
|
|
2829
|
+
* @param {number} duration Duration of the animation (unit: ms)<ko>애니메이션 진행 시간 (단위: ms)</ko>
|
|
2830
|
+
* @param {DIRECTION} direction Direction to move, only available in the {@link Flicking#circular circular} mode<ko>이동할 방향. {@link Flicking#circular circular} 옵션 활성화시에만 사용 가능합니다</ko>
|
|
2831
|
+
* @chainable
|
|
2832
|
+
* @throws {FlickingError}
|
|
2833
|
+
* {@link ERROR_CODE POSITION_NOT_REACHABLE} When the given panel is already removed or not in the Camera's {@link Camera#range range}
|
|
2834
|
+
* <ko>{@link ERROR_CODE POSITION_NOT_REACHABLE} 주어진 패널이 제거되었거나, Camera의 {@link Camera#range range} 밖에 있을 경우</ko>
|
|
2835
|
+
* @return {this}
|
|
2836
|
+
*/
|
|
2837
|
+
|
|
2838
|
+
|
|
2839
|
+
__proto.updateAnimation = function (panel, duration, direction) {
|
|
2840
|
+
var state = this._controller.state;
|
|
2841
|
+
|
|
2842
|
+
var position = this._getPosition(panel, direction !== null && direction !== void 0 ? direction : DIRECTION.NONE);
|
|
2843
|
+
|
|
2844
|
+
state.targetPanel = panel;
|
|
2845
|
+
|
|
2846
|
+
this._controller.updateAnimation(position, duration);
|
|
2847
|
+
|
|
2848
|
+
return this;
|
|
2849
|
+
};
|
|
2850
|
+
/**
|
|
2851
|
+
* Stops the animation currently playing
|
|
2852
|
+
* @ko 재생 중인 애니메이션을 중단시킵니다
|
|
2853
|
+
* @chainable
|
|
2854
|
+
* @return {this}
|
|
2855
|
+
*/
|
|
2856
|
+
|
|
2857
|
+
|
|
2858
|
+
__proto.stopAnimation = function () {
|
|
2859
|
+
var state = this._controller.state;
|
|
2860
|
+
state.targetPanel = null;
|
|
2861
|
+
|
|
2862
|
+
this._controller.stopAnimation();
|
|
2863
|
+
|
|
2864
|
+
return this;
|
|
2865
|
+
};
|
|
2791
2866
|
/**
|
|
2792
2867
|
* Update position after resizing
|
|
2793
2868
|
* @ko resize 이후에 position을 업데이트합니다
|
|
@@ -2883,38 +2958,9 @@ function () {
|
|
|
2883
2958
|
direction = _b === void 0 ? DIRECTION.NONE : _b,
|
|
2884
2959
|
axesEvent = _a.axesEvent;
|
|
2885
2960
|
return __awaiter(this, void 0, void 0, function () {
|
|
2886
|
-
var
|
|
2961
|
+
var position;
|
|
2887
2962
|
return __generator(this, function (_c) {
|
|
2888
|
-
|
|
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
|
-
}
|
|
2963
|
+
position = this._getPosition(panel, direction);
|
|
2918
2964
|
|
|
2919
2965
|
this._triggerIndexChangeEvent(panel, panel.position, axesEvent);
|
|
2920
2966
|
|
|
@@ -3031,6 +3077,45 @@ function () {
|
|
|
3031
3077
|
});
|
|
3032
3078
|
};
|
|
3033
3079
|
|
|
3080
|
+
__proto._getPosition = function (panel, direction) {
|
|
3081
|
+
if (direction === void 0) {
|
|
3082
|
+
direction = DIRECTION.NONE;
|
|
3083
|
+
}
|
|
3084
|
+
|
|
3085
|
+
var flicking = getFlickingAttached(this._flicking);
|
|
3086
|
+
var camera = flicking.camera;
|
|
3087
|
+
var position = panel.position;
|
|
3088
|
+
var nearestAnchor = camera.findNearestAnchor(position);
|
|
3089
|
+
|
|
3090
|
+
if (panel.removed || !nearestAnchor) {
|
|
3091
|
+
throw new FlickingError(MESSAGE.POSITION_NOT_REACHABLE(panel.position), CODE.POSITION_NOT_REACHABLE);
|
|
3092
|
+
}
|
|
3093
|
+
|
|
3094
|
+
if (!camera.canReach(panel)) {
|
|
3095
|
+
// Override position & panel if that panel is not reachable
|
|
3096
|
+
position = nearestAnchor.position;
|
|
3097
|
+
panel = nearestAnchor.panel;
|
|
3098
|
+
} else if (flicking.circularEnabled) {
|
|
3099
|
+
// Circular mode is enabled, find nearest distance to panel
|
|
3100
|
+
var camPos_1 = this._controller.position; // Actual position of the Axes
|
|
3101
|
+
|
|
3102
|
+
var camRangeDiff = camera.rangeDiff;
|
|
3103
|
+
var possiblePositions = [position, position + camRangeDiff, position - camRangeDiff].filter(function (pos) {
|
|
3104
|
+
if (direction === DIRECTION.NONE) return true;
|
|
3105
|
+
return direction === DIRECTION.PREV ? pos <= camPos_1 : pos >= camPos_1;
|
|
3106
|
+
});
|
|
3107
|
+
position = possiblePositions.reduce(function (nearestPosition, pos) {
|
|
3108
|
+
if (Math.abs(camPos_1 - pos) < Math.abs(camPos_1 - nearestPosition)) {
|
|
3109
|
+
return pos;
|
|
3110
|
+
} else {
|
|
3111
|
+
return nearestPosition;
|
|
3112
|
+
}
|
|
3113
|
+
}, Infinity);
|
|
3114
|
+
}
|
|
3115
|
+
|
|
3116
|
+
return position;
|
|
3117
|
+
};
|
|
3118
|
+
|
|
3034
3119
|
return Control;
|
|
3035
3120
|
}();
|
|
3036
3121
|
|
|
@@ -8036,6 +8121,49 @@ function (_super) {
|
|
|
8036
8121
|
direction: direction
|
|
8037
8122
|
});
|
|
8038
8123
|
};
|
|
8124
|
+
/**
|
|
8125
|
+
* Change the destination and duration of the animation currently playing
|
|
8126
|
+
* @ko 재생 중인 애니메이션의 목적지와 재생 시간을 변경합니다
|
|
8127
|
+
* @param {number} index The index of the panel to move<ko>이동할 패널의 인덱스</ko>
|
|
8128
|
+
* @param {number} duration Duration of the animation (unit: ms)<ko>애니메이션 진행 시간 (단위: ms)</ko>
|
|
8129
|
+
* @param {DIRECTION} direction Direction to move, only available in the {@link Flicking#circular circular} mode<ko>이동할 방향. {@link Flicking#circular circular} 옵션 활성화시에만 사용 가능합니다</ko>
|
|
8130
|
+
* @throws {FlickingError}
|
|
8131
|
+
* {@link ERROR_CODE INDEX_OUT_OF_RANGE} When the root is not either string or HTMLElement
|
|
8132
|
+
* <ko>{@link ERROR_CODE INDEX_OUT_OF_RANGE} 해당 인덱스를 가진 패널이 존재하지 않을 경우</ko>
|
|
8133
|
+
* @return {void}
|
|
8134
|
+
*/
|
|
8135
|
+
|
|
8136
|
+
|
|
8137
|
+
__proto.updateAnimation = function (index, duration, direction) {
|
|
8138
|
+
if (!this._control.animating) {
|
|
8139
|
+
return;
|
|
8140
|
+
}
|
|
8141
|
+
|
|
8142
|
+
var renderer = this._renderer;
|
|
8143
|
+
var panelCount = renderer.panelCount;
|
|
8144
|
+
var panel = renderer.getPanel(index);
|
|
8145
|
+
|
|
8146
|
+
if (!panel) {
|
|
8147
|
+
throw new FlickingError(MESSAGE.INDEX_OUT_OF_RANGE(index, 0, panelCount - 1), CODE.INDEX_OUT_OF_RANGE);
|
|
8148
|
+
}
|
|
8149
|
+
|
|
8150
|
+
this._control.updateAnimation(panel, duration, direction);
|
|
8151
|
+
};
|
|
8152
|
+
/**
|
|
8153
|
+
* Stops the animation currently playing
|
|
8154
|
+
* @ko 재생 중인 애니메이션을 중단시킵니다
|
|
8155
|
+
* @fires Flicking#moveEnd
|
|
8156
|
+
* @return {void}
|
|
8157
|
+
*/
|
|
8158
|
+
|
|
8159
|
+
|
|
8160
|
+
__proto.stopAnimation = function () {
|
|
8161
|
+
if (!this._control.animating) {
|
|
8162
|
+
return;
|
|
8163
|
+
}
|
|
8164
|
+
|
|
8165
|
+
this._control.stopAnimation();
|
|
8166
|
+
};
|
|
8039
8167
|
/**
|
|
8040
8168
|
* Return the {@link Panel} at the given index. `null` if it doesn't exists.
|
|
8041
8169
|
* @ko 주어진 인덱스에 해당하는 {@link Panel}을 반환합니다. 주어진 인덱스에 해당하는 패널이 존재하지 않을 경우 `null`을 반환합니다.
|
|
@@ -8579,7 +8707,7 @@ function (_super) {
|
|
|
8579
8707
|
*/
|
|
8580
8708
|
|
|
8581
8709
|
|
|
8582
|
-
Flicking.VERSION = "4.
|
|
8710
|
+
Flicking.VERSION = "4.10.0";
|
|
8583
8711
|
return Flicking;
|
|
8584
8712
|
}(Component);
|
|
8585
8713
|
|