@egjs/flicking-plugins 4.4.0 → 4.6.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/AutoPlay.d.ts +12 -1
- package/dist/plugins.esm.js +75 -32
- package/dist/plugins.esm.js.map +1 -1
- package/dist/plugins.js +75 -32
- package/dist/plugins.js.map +1 -1
- package/dist/plugins.min.js +2 -2
- package/dist/plugins.min.js.map +1 -1
- package/package.json +1 -1
- package/src/AutoPlay.ts +32 -10
|
@@ -1,28 +1,39 @@
|
|
|
1
1
|
import Flicking, { Plugin, DIRECTION } from "@egjs/flicking";
|
|
2
2
|
interface AutoPlayOptions {
|
|
3
3
|
duration: number;
|
|
4
|
+
animationDuration: number | undefined;
|
|
4
5
|
direction: typeof DIRECTION["NEXT"] | typeof DIRECTION["PREV"];
|
|
5
6
|
stopOnHover: boolean;
|
|
7
|
+
delayAfterHover: number;
|
|
6
8
|
}
|
|
7
9
|
declare class AutoPlay implements Plugin {
|
|
8
10
|
private _duration;
|
|
11
|
+
private _animationDuration;
|
|
9
12
|
private _direction;
|
|
10
13
|
private _stopOnHover;
|
|
14
|
+
private _delayAfterHover;
|
|
11
15
|
private _flicking;
|
|
12
16
|
private _timerId;
|
|
13
17
|
private _mouseEntered;
|
|
18
|
+
private _playing;
|
|
14
19
|
get duration(): number;
|
|
20
|
+
get animationDuration(): number | undefined;
|
|
15
21
|
get direction(): AutoPlayOptions["direction"];
|
|
16
22
|
get stopOnHover(): boolean;
|
|
23
|
+
get delayAfterHover(): number;
|
|
24
|
+
get playing(): boolean;
|
|
17
25
|
set duration(val: number);
|
|
26
|
+
set animationDuration(val: number | undefined);
|
|
18
27
|
set direction(val: AutoPlayOptions["direction"]);
|
|
19
28
|
set stopOnHover(val: boolean);
|
|
20
|
-
|
|
29
|
+
set delayAfterHover(val: number);
|
|
30
|
+
constructor({ duration, animationDuration, direction, stopOnHover, delayAfterHover }?: Partial<AutoPlayOptions>);
|
|
21
31
|
init(flicking: Flicking): void;
|
|
22
32
|
destroy(): void;
|
|
23
33
|
update(): void;
|
|
24
34
|
play: () => void;
|
|
25
35
|
stop: () => void;
|
|
36
|
+
private _movePanel;
|
|
26
37
|
private _onMouseEnter;
|
|
27
38
|
private _onMouseLeave;
|
|
28
39
|
}
|
package/dist/plugins.esm.js
CHANGED
|
@@ -4,7 +4,7 @@ name: @egjs/flicking-plugins
|
|
|
4
4
|
license: MIT
|
|
5
5
|
author: NAVER Corp.
|
|
6
6
|
repository: https://github.com/naver/egjs-flicking-plugins
|
|
7
|
-
version: 4.
|
|
7
|
+
version: 4.6.0
|
|
8
8
|
*/
|
|
9
9
|
import { EVENTS, DIRECTION, FlickingError, clamp } from '@egjs/flicking';
|
|
10
10
|
|
|
@@ -221,8 +221,10 @@ function () {
|
|
|
221
221
|
/**
|
|
222
222
|
* @param {AutoPlayOptions} options Options for the AutoPlay instance.<ko>AutoPlay 옵션</ko>
|
|
223
223
|
* @param {number} options.duration Time to wait before moving on to the next panel.<ko>다음 패널로 움직이기까지 대기 시간</ko>
|
|
224
|
+
* @param {number | undefined} options.animationDuration Duration of animation of moving to the next panel. If undefined, duration option of the Flicking instance is used instead.<ko>패널이 움직이는 애니메이션의 지속 시간, undefined라면 Flicking 인스턴스의 duration 값을 사용한다</ko>
|
|
224
225
|
* @param {"PREV" | "NEXT"} options.direction The direction in which the panel moves.<ko>패널이 움직이는 방향</ko>
|
|
225
226
|
* @param {boolean} options.stopOnHover Whether to stop when mouse hover upon the element.<ko>엘리먼트에 마우스를 올렸을 때 AutoPlay를 정지할지 여부</ko>
|
|
227
|
+
* @param {number} options.delayAfterHover If stopOnHover is true, the amount of time to wait before moving on to the next panel when mouse leaves the element.<ko>stopOnHover를 사용한다면 마우스가 엘리먼트로부터 나간 뒤 다음 패널로 움직이기까지 대기 시간</ko>
|
|
226
228
|
* @example
|
|
227
229
|
* ```ts
|
|
228
230
|
* flicking.addPlugins(new AutoPlay({ duration: 2000, direction: "NEXT" }));
|
|
@@ -234,47 +236,27 @@ function () {
|
|
|
234
236
|
var _b = _a === void 0 ? {} : _a,
|
|
235
237
|
_c = _b.duration,
|
|
236
238
|
duration = _c === void 0 ? 2000 : _c,
|
|
237
|
-
_d = _b.
|
|
238
|
-
|
|
239
|
-
_e = _b.
|
|
240
|
-
|
|
239
|
+
_d = _b.animationDuration,
|
|
240
|
+
animationDuration = _d === void 0 ? undefined : _d,
|
|
241
|
+
_e = _b.direction,
|
|
242
|
+
direction = _e === void 0 ? DIRECTION.NEXT : _e,
|
|
243
|
+
_f = _b.stopOnHover,
|
|
244
|
+
stopOnHover = _f === void 0 ? false : _f,
|
|
245
|
+
delayAfterHover = _b.delayAfterHover;
|
|
241
246
|
/* Internal Values */
|
|
242
247
|
|
|
243
248
|
|
|
244
249
|
this._flicking = null;
|
|
245
250
|
this._timerId = 0;
|
|
246
251
|
this._mouseEntered = false;
|
|
252
|
+
this._playing = false;
|
|
247
253
|
|
|
248
254
|
this.play = function () {
|
|
249
|
-
|
|
250
|
-
var direction = _this._direction;
|
|
251
|
-
|
|
252
|
-
if (!flicking) {
|
|
253
|
-
return;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
_this.stop();
|
|
257
|
-
|
|
258
|
-
if (_this._mouseEntered || flicking.animating) {
|
|
259
|
-
return;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
_this._timerId = window.setTimeout(function () {
|
|
263
|
-
if (direction === DIRECTION.NEXT) {
|
|
264
|
-
flicking.next().catch(function () {
|
|
265
|
-
return void 0;
|
|
266
|
-
});
|
|
267
|
-
} else {
|
|
268
|
-
flicking.prev().catch(function () {
|
|
269
|
-
return void 0;
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
_this.play();
|
|
274
|
-
}, _this._duration);
|
|
255
|
+
_this._movePanel(_this._duration);
|
|
275
256
|
};
|
|
276
257
|
|
|
277
258
|
this.stop = function () {
|
|
259
|
+
_this._playing = false;
|
|
278
260
|
clearTimeout(_this._timerId);
|
|
279
261
|
};
|
|
280
262
|
|
|
@@ -287,12 +269,14 @@ function () {
|
|
|
287
269
|
this._onMouseLeave = function () {
|
|
288
270
|
_this._mouseEntered = false;
|
|
289
271
|
|
|
290
|
-
_this.
|
|
272
|
+
_this._movePanel(_this._delayAfterHover);
|
|
291
273
|
};
|
|
292
274
|
|
|
293
275
|
this._duration = duration;
|
|
276
|
+
this._animationDuration = animationDuration;
|
|
294
277
|
this._direction = direction;
|
|
295
278
|
this._stopOnHover = stopOnHover;
|
|
279
|
+
this._delayAfterHover = delayAfterHover !== null && delayAfterHover !== void 0 ? delayAfterHover : duration;
|
|
296
280
|
}
|
|
297
281
|
|
|
298
282
|
var __proto = AutoPlay.prototype;
|
|
@@ -306,6 +290,16 @@ function () {
|
|
|
306
290
|
enumerable: false,
|
|
307
291
|
configurable: true
|
|
308
292
|
});
|
|
293
|
+
Object.defineProperty(__proto, "animationDuration", {
|
|
294
|
+
get: function () {
|
|
295
|
+
return this._animationDuration;
|
|
296
|
+
},
|
|
297
|
+
set: function (val) {
|
|
298
|
+
this._animationDuration = val;
|
|
299
|
+
},
|
|
300
|
+
enumerable: false,
|
|
301
|
+
configurable: true
|
|
302
|
+
});
|
|
309
303
|
Object.defineProperty(__proto, "direction", {
|
|
310
304
|
get: function () {
|
|
311
305
|
return this._direction;
|
|
@@ -326,6 +320,23 @@ function () {
|
|
|
326
320
|
enumerable: false,
|
|
327
321
|
configurable: true
|
|
328
322
|
});
|
|
323
|
+
Object.defineProperty(__proto, "delayAfterHover", {
|
|
324
|
+
get: function () {
|
|
325
|
+
return this._delayAfterHover;
|
|
326
|
+
},
|
|
327
|
+
set: function (val) {
|
|
328
|
+
this._delayAfterHover = val;
|
|
329
|
+
},
|
|
330
|
+
enumerable: false,
|
|
331
|
+
configurable: true
|
|
332
|
+
});
|
|
333
|
+
Object.defineProperty(__proto, "playing", {
|
|
334
|
+
get: function () {
|
|
335
|
+
return this._playing;
|
|
336
|
+
},
|
|
337
|
+
enumerable: false,
|
|
338
|
+
configurable: true
|
|
339
|
+
});
|
|
329
340
|
|
|
330
341
|
__proto.init = function (flicking) {
|
|
331
342
|
var _a;
|
|
@@ -368,6 +379,38 @@ function () {
|
|
|
368
379
|
__proto.update = function () {// DO-NOTHING
|
|
369
380
|
};
|
|
370
381
|
|
|
382
|
+
__proto._movePanel = function (duration) {
|
|
383
|
+
var _this = this;
|
|
384
|
+
|
|
385
|
+
var flicking = this._flicking;
|
|
386
|
+
var direction = this._direction;
|
|
387
|
+
|
|
388
|
+
if (!flicking) {
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
this.stop();
|
|
393
|
+
|
|
394
|
+
if (this._mouseEntered || flicking.animating) {
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
this._playing = true;
|
|
399
|
+
this._timerId = window.setTimeout(function () {
|
|
400
|
+
if (direction === DIRECTION.NEXT) {
|
|
401
|
+
flicking.next(_this._animationDuration).catch(function () {
|
|
402
|
+
return void 0;
|
|
403
|
+
});
|
|
404
|
+
} else {
|
|
405
|
+
flicking.prev(_this._animationDuration).catch(function () {
|
|
406
|
+
return void 0;
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
_this.play();
|
|
411
|
+
}, duration);
|
|
412
|
+
};
|
|
413
|
+
|
|
371
414
|
return AutoPlay;
|
|
372
415
|
}();
|
|
373
416
|
|