@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.
- 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 +166 -37
- package/dist/flicking.esm.js.map +1 -1
- package/dist/flicking.js +166 -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 +188 -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 +34 -0
- package/src/control/Control.ts +77 -35
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@egjs/flicking",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.10.1",
|
|
4
4
|
"description": "Everyday 30 million people experience. It's reliable, flexible and extendable carousel.",
|
|
5
5
|
"main": "dist/flicking.js",
|
|
6
6
|
"module": "dist/flicking.esm.js",
|
|
7
|
-
"sideEffects":
|
|
7
|
+
"sideEffects": [
|
|
8
|
+
"**/*.css",
|
|
9
|
+
"**/*.sass"
|
|
10
|
+
],
|
|
8
11
|
"es2015": "dist/flicking.esm.js",
|
|
9
12
|
"types": "declaration/index.d.ts",
|
|
10
13
|
"scripts": {
|
|
@@ -136,7 +139,7 @@
|
|
|
136
139
|
"typescript-transform-paths": "^2.2.3"
|
|
137
140
|
},
|
|
138
141
|
"dependencies": {
|
|
139
|
-
"@egjs/axes": "^3.8.
|
|
142
|
+
"@egjs/axes": "^3.8.1",
|
|
140
143
|
"@egjs/component": "^3.0.1",
|
|
141
144
|
"@egjs/imready": "^1.1.3",
|
|
142
145
|
"@egjs/list-differ": "^1.0.0"
|
package/src/Flicking.ts
CHANGED
|
@@ -1094,6 +1094,48 @@ class Flicking extends Component<FlickingEvents> {
|
|
|
1094
1094
|
});
|
|
1095
1095
|
}
|
|
1096
1096
|
|
|
1097
|
+
/**
|
|
1098
|
+
* Change the destination and duration of the animation currently playing
|
|
1099
|
+
* @ko 재생 중인 애니메이션의 목적지와 재생 시간을 변경합니다
|
|
1100
|
+
* @param {number} index The index of the panel to move<ko>이동할 패널의 인덱스</ko>
|
|
1101
|
+
* @param {number} duration Duration of the animation (unit: ms)<ko>애니메이션 진행 시간 (단위: ms)</ko>
|
|
1102
|
+
* @param {DIRECTION} direction Direction to move, only available in the {@link Flicking#circular circular} mode<ko>이동할 방향. {@link Flicking#circular circular} 옵션 활성화시에만 사용 가능합니다</ko>
|
|
1103
|
+
* @throws {FlickingError}
|
|
1104
|
+
* {@link ERROR_CODE INDEX_OUT_OF_RANGE} When the root is not either string or HTMLElement
|
|
1105
|
+
* <ko>{@link ERROR_CODE INDEX_OUT_OF_RANGE} 해당 인덱스를 가진 패널이 존재하지 않을 경우</ko>
|
|
1106
|
+
* @return {void}
|
|
1107
|
+
*/
|
|
1108
|
+
public updateAnimation(index: number, duration?: number, direction?: ValueOf<typeof DIRECTION>): void {
|
|
1109
|
+
if (!this._control.animating) {
|
|
1110
|
+
return;
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
const renderer = this._renderer;
|
|
1114
|
+
const panelCount = renderer.panelCount;
|
|
1115
|
+
|
|
1116
|
+
const panel = renderer.getPanel(index);
|
|
1117
|
+
|
|
1118
|
+
if (!panel) {
|
|
1119
|
+
throw new FlickingError(ERROR.MESSAGE.INDEX_OUT_OF_RANGE(index, 0, panelCount - 1), ERROR.CODE.INDEX_OUT_OF_RANGE);
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
this._control.updateAnimation(panel, duration, direction);
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
/**
|
|
1126
|
+
* Stops the animation currently playing
|
|
1127
|
+
* @ko 재생 중인 애니메이션을 중단시킵니다
|
|
1128
|
+
* @fires Flicking#moveEnd
|
|
1129
|
+
* @return {void}
|
|
1130
|
+
*/
|
|
1131
|
+
public stopAnimation(): void {
|
|
1132
|
+
if (!this._control.animating) {
|
|
1133
|
+
return;
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
this._control.stopAnimation();
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1097
1139
|
/**
|
|
1098
1140
|
* Return the {@link Panel} at the given index. `null` if it doesn't exists.
|
|
1099
1141
|
* @ko 주어진 인덱스에 해당하는 {@link Panel}을 반환합니다. 주어진 인덱스에 해당하는 패널이 존재하지 않을 경우 `null`을 반환합니다.
|
|
@@ -139,6 +139,7 @@ class AxesController {
|
|
|
139
139
|
});
|
|
140
140
|
this._panInput = new PanInput(flicking.viewport.element, {
|
|
141
141
|
inputType: flicking.inputType,
|
|
142
|
+
threshold: 1,
|
|
142
143
|
iOSEdgeSwipeThreshold: flicking.iOSEdgeSwipeThreshold,
|
|
143
144
|
scale: flicking.horizontal ? [-1, 0] : [0, -1],
|
|
144
145
|
releaseOnScroll: true
|
|
@@ -214,6 +215,39 @@ class AxesController {
|
|
|
214
215
|
return this;
|
|
215
216
|
}
|
|
216
217
|
|
|
218
|
+
/**
|
|
219
|
+
* Change the destination and duration of the animation currently playing
|
|
220
|
+
* @ko 재생 중인 애니메이션의 목적지와 재생 시간을 변경합니다
|
|
221
|
+
* @param {number} position A position to move<ko>이동할 좌표</ko>
|
|
222
|
+
* @param {number} duration Duration of the animation (unit: ms)<ko>애니메이션 진행 시간 (단위: ms)</ko>
|
|
223
|
+
* @chainable
|
|
224
|
+
* @return {this}
|
|
225
|
+
*/
|
|
226
|
+
public updateAnimation(position: number, duration?: number): this {
|
|
227
|
+
this._animatingContext = {
|
|
228
|
+
...this._animatingContext,
|
|
229
|
+
end: position
|
|
230
|
+
};
|
|
231
|
+
this._axes?.updateAnimation({
|
|
232
|
+
destPos: { [AXES.POSITION_KEY]: position },
|
|
233
|
+
duration
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
return this;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Stops the animation currently playing
|
|
241
|
+
* @ko 재생 중인 애니메이션을 중단시킵니다
|
|
242
|
+
* @chainable
|
|
243
|
+
* @return {this}
|
|
244
|
+
*/
|
|
245
|
+
public stopAnimation(): this {
|
|
246
|
+
this._axes?.stopAnimation();
|
|
247
|
+
|
|
248
|
+
return this;
|
|
249
|
+
}
|
|
250
|
+
|
|
217
251
|
/**
|
|
218
252
|
* Update {@link https://naver.github.io/egjs-axes/ @egjs/axes}'s state
|
|
219
253
|
* @ko {@link https://naver.github.io/egjs-axes/ @egjs/axes}의 상태를 갱신합니다
|
package/src/control/Control.ts
CHANGED
|
@@ -173,6 +173,43 @@ abstract class Control {
|
|
|
173
173
|
return this;
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
+
/**
|
|
177
|
+
* Change the destination and duration of the animation currently playing
|
|
178
|
+
* @ko 재생 중인 애니메이션의 목적지와 재생 시간을 변경합니다
|
|
179
|
+
* @param {Panel} panel The target panel to move<ko>이동할 패널</ko>
|
|
180
|
+
* @param {number} duration Duration of the animation (unit: ms)<ko>애니메이션 진행 시간 (단위: ms)</ko>
|
|
181
|
+
* @param {DIRECTION} direction Direction to move, only available in the {@link Flicking#circular circular} mode<ko>이동할 방향. {@link Flicking#circular circular} 옵션 활성화시에만 사용 가능합니다</ko>
|
|
182
|
+
* @chainable
|
|
183
|
+
* @throws {FlickingError}
|
|
184
|
+
* {@link ERROR_CODE POSITION_NOT_REACHABLE} When the given panel is already removed or not in the Camera's {@link Camera#range range}
|
|
185
|
+
* <ko>{@link ERROR_CODE POSITION_NOT_REACHABLE} 주어진 패널이 제거되었거나, Camera의 {@link Camera#range range} 밖에 있을 경우</ko>
|
|
186
|
+
* @return {this}
|
|
187
|
+
*/
|
|
188
|
+
public updateAnimation(panel: Panel, duration?: number, direction?: ValueOf<typeof DIRECTION>): this {
|
|
189
|
+
const state = this._controller.state;
|
|
190
|
+
const position = this._getPosition(panel, direction ?? DIRECTION.NONE);
|
|
191
|
+
|
|
192
|
+
state.targetPanel = panel;
|
|
193
|
+
this._controller.updateAnimation(position, duration);
|
|
194
|
+
|
|
195
|
+
return this;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Stops the animation currently playing
|
|
200
|
+
* @ko 재생 중인 애니메이션을 중단시킵니다
|
|
201
|
+
* @chainable
|
|
202
|
+
* @return {this}
|
|
203
|
+
*/
|
|
204
|
+
public stopAnimation(): this {
|
|
205
|
+
const state = this._controller.state;
|
|
206
|
+
|
|
207
|
+
state.targetPanel = null;
|
|
208
|
+
this._controller.stopAnimation();
|
|
209
|
+
|
|
210
|
+
return this;
|
|
211
|
+
}
|
|
212
|
+
|
|
176
213
|
/**
|
|
177
214
|
* Update position after resizing
|
|
178
215
|
* @ko resize 이후에 position을 업데이트합니다
|
|
@@ -267,41 +304,7 @@ abstract class Control {
|
|
|
267
304
|
direction?: ValueOf<typeof DIRECTION>;
|
|
268
305
|
axesEvent?: OnRelease;
|
|
269
306
|
}) {
|
|
270
|
-
const
|
|
271
|
-
const camera = flicking.camera;
|
|
272
|
-
|
|
273
|
-
let position = panel.position;
|
|
274
|
-
const nearestAnchor = camera.findNearestAnchor(position);
|
|
275
|
-
|
|
276
|
-
if (panel.removed || !nearestAnchor) {
|
|
277
|
-
return Promise.reject(new FlickingError(ERROR.MESSAGE.POSITION_NOT_REACHABLE(panel.position), ERROR.CODE.POSITION_NOT_REACHABLE));
|
|
278
|
-
}
|
|
279
|
-
if (!camera.canReach(panel)) {
|
|
280
|
-
// Override position & panel if that panel is not reachable
|
|
281
|
-
position = nearestAnchor.position;
|
|
282
|
-
panel = nearestAnchor.panel;
|
|
283
|
-
} else if (flicking.circularEnabled) {
|
|
284
|
-
// Circular mode is enabled, find nearest distance to panel
|
|
285
|
-
const camPos = this._controller.position; // Actual position of the Axes
|
|
286
|
-
const camRangeDiff = camera.rangeDiff;
|
|
287
|
-
const possiblePositions = [position, position + camRangeDiff, position - camRangeDiff]
|
|
288
|
-
.filter(pos => {
|
|
289
|
-
if (direction === DIRECTION.NONE) return true;
|
|
290
|
-
|
|
291
|
-
return direction === DIRECTION.PREV
|
|
292
|
-
? pos <= camPos
|
|
293
|
-
: pos >= camPos;
|
|
294
|
-
});
|
|
295
|
-
|
|
296
|
-
position = possiblePositions.reduce((nearestPosition, pos) => {
|
|
297
|
-
if (Math.abs(camPos - pos) < Math.abs(camPos - nearestPosition)) {
|
|
298
|
-
return pos;
|
|
299
|
-
} else {
|
|
300
|
-
return nearestPosition;
|
|
301
|
-
}
|
|
302
|
-
}, Infinity);
|
|
303
|
-
}
|
|
304
|
-
|
|
307
|
+
const position = this._getPosition(panel, direction);
|
|
305
308
|
this._triggerIndexChangeEvent(panel, panel.position, axesEvent);
|
|
306
309
|
|
|
307
310
|
return this._animateToPosition({ position, duration, newActivePanel: panel, axesEvent });
|
|
@@ -380,6 +383,45 @@ abstract class Control {
|
|
|
380
383
|
});
|
|
381
384
|
}
|
|
382
385
|
}
|
|
386
|
+
|
|
387
|
+
private _getPosition(panel: Panel, direction: ValueOf<typeof DIRECTION> = DIRECTION.NONE) {
|
|
388
|
+
const flicking = getFlickingAttached(this._flicking);
|
|
389
|
+
const camera = flicking.camera;
|
|
390
|
+
|
|
391
|
+
let position = panel.position;
|
|
392
|
+
const nearestAnchor = camera.findNearestAnchor(position);
|
|
393
|
+
|
|
394
|
+
if (panel.removed || !nearestAnchor) {
|
|
395
|
+
throw new FlickingError(ERROR.MESSAGE.POSITION_NOT_REACHABLE(panel.position), ERROR.CODE.POSITION_NOT_REACHABLE);
|
|
396
|
+
}
|
|
397
|
+
if (!camera.canReach(panel)) {
|
|
398
|
+
// Override position & panel if that panel is not reachable
|
|
399
|
+
position = nearestAnchor.position;
|
|
400
|
+
panel = nearestAnchor.panel;
|
|
401
|
+
} else if (flicking.circularEnabled) {
|
|
402
|
+
// Circular mode is enabled, find nearest distance to panel
|
|
403
|
+
const camPos = this._controller.position; // Actual position of the Axes
|
|
404
|
+
const camRangeDiff = camera.rangeDiff;
|
|
405
|
+
const possiblePositions = [position, position + camRangeDiff, position - camRangeDiff]
|
|
406
|
+
.filter(pos => {
|
|
407
|
+
if (direction === DIRECTION.NONE) return true;
|
|
408
|
+
|
|
409
|
+
return direction === DIRECTION.PREV
|
|
410
|
+
? pos <= camPos
|
|
411
|
+
: pos >= camPos;
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
position = possiblePositions.reduce((nearestPosition, pos) => {
|
|
415
|
+
if (Math.abs(camPos - pos) < Math.abs(camPos - nearestPosition)) {
|
|
416
|
+
return pos;
|
|
417
|
+
} else {
|
|
418
|
+
return nearestPosition;
|
|
419
|
+
}
|
|
420
|
+
}, Infinity);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
return position;
|
|
424
|
+
}
|
|
383
425
|
}
|
|
384
426
|
|
|
385
427
|
export default Control;
|