@egjs/flicking-plugins 4.8.0-beta.1 → 4.8.1-beta.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/README.md +42 -51
- package/css/all.css +2 -0
- package/css/arrow.css +2 -2
- package/css/pagination.css +5 -3
- package/declaration/Arrow.d.ts +106 -51
- package/declaration/AutoPlay.d.ts +104 -44
- package/declaration/Fade.d.ts +41 -16
- package/declaration/Parallax.d.ts +41 -16
- package/declaration/Perspective.d.ts +71 -28
- package/declaration/Sync.d.ts +93 -37
- package/declaration/const.d.ts +31 -31
- package/declaration/event.d.ts +5 -5
- package/declaration/index.d.ts +13 -10
- package/declaration/pagination/Pagination.d.ts +141 -61
- package/declaration/pagination/index.d.ts +3 -3
- package/declaration/pagination/renderer/BulletRenderer.d.ts +11 -11
- package/declaration/pagination/renderer/FractionRenderer.d.ts +9 -9
- package/declaration/pagination/renderer/Renderer.d.ts +19 -19
- package/declaration/pagination/renderer/ScrollBulletRenderer.d.ts +12 -12
- package/declaration/tsdoc-metadata.json +11 -0
- package/declaration/type.d.ts +9 -9
- package/declaration/utils.d.ts +3 -3
- package/dist/arrow.css +2 -2
- package/dist/flicking-plugins.css +23 -8
- package/dist/flicking-plugins.min.css +1 -1
- package/dist/pagination.css +21 -6
- package/dist/pagination.min.css +1 -1
- package/dist/plugins.esm.js +1030 -1591
- package/dist/plugins.esm.js.map +1 -1
- package/dist/plugins.js +1047 -1620
- package/dist/plugins.js.map +1 -1
- package/dist/plugins.min.js +1 -9
- package/dist/plugins.min.js.map +1 -1
- package/package.json +49 -105
- package/src/Arrow.ts +133 -82
- package/src/AutoPlay.ts +105 -35
- package/src/Fade.ts +31 -11
- package/src/Parallax.ts +31 -11
- package/src/Perspective.ts +69 -22
- package/src/Sync.ts +69 -25
- package/src/index.ts +9 -22
- package/src/pagination/Pagination.ts +163 -40
- package/src/pagination/index.ts +2 -6
- package/src/pagination/renderer/BulletRenderer.ts +1 -4
- package/src/pagination/renderer/FractionRenderer.ts +1 -3
- package/src/pagination/renderer/Renderer.ts +14 -13
- package/src/pagination/renderer/ScrollBulletRenderer.ts +5 -12
- package/CONTRIBUTING +0 -58
- package/rollup.config.dev.js +0 -17
- package/rollup.config.js +0 -33
- package/tsconfig.declaration.json +0 -10
- package/tsconfig.eslint.json +0 -8
- package/tsconfig.json +0 -17
- package/tsconfig.test.json +0 -21
package/dist/plugins.js
CHANGED
|
@@ -1,503 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
repository: https://github.com/naver/egjs-flicking-plugins
|
|
7
|
-
version: 4.8.0-beta.1
|
|
8
|
-
*/
|
|
9
|
-
(function (global, factory) {
|
|
10
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@egjs/flicking')) :
|
|
11
|
-
typeof define === 'function' && define.amd ? define(['exports', '@egjs/flicking'], factory) :
|
|
12
|
-
(global = global || self, factory((global.Flicking = global.Flicking || {}, global.Flicking.Plugins = {}), global.Flicking));
|
|
13
|
-
}(this, function (exports, flicking) { 'use strict';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* You can apply parallax effect while panel is moving.
|
|
17
|
-
* @ko 패널들을 움직이면서 parallax 효과를 부여할 수 있습니다.
|
|
18
|
-
* @memberof Flicking.Plugins
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
var Parallax =
|
|
22
|
-
/*#__PURE__*/
|
|
23
|
-
function () {
|
|
24
|
-
/**
|
|
25
|
-
* @param {string} selector Selector of the element to apply parallax effect<ko> Parallax 효과를 적용할 엘리먼트의 선택자 </ko>
|
|
26
|
-
* @param {number} scale Effect amplication scale<ko>효과 증폭도</ko>
|
|
27
|
-
* @example
|
|
28
|
-
* ```ts
|
|
29
|
-
* flicking.addPlugins(new Parallax("img", 1));
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
function Parallax(selector, scale) {
|
|
33
|
-
var _this = this;
|
|
34
|
-
|
|
35
|
-
if (selector === void 0) {
|
|
36
|
-
selector = "";
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (scale === void 0) {
|
|
40
|
-
scale = 1;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
this.update = function () {
|
|
44
|
-
_this._onMove();
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
this._onMove = function () {
|
|
48
|
-
var flicking = _this._flicking;
|
|
49
|
-
if (!flicking) return;
|
|
50
|
-
var panels = flicking.visiblePanels;
|
|
51
|
-
panels.forEach(function (panel) {
|
|
52
|
-
var progress = panel.outsetProgress;
|
|
53
|
-
var el = panel.element;
|
|
54
|
-
var target = _this._selector ? el.querySelector(_this._selector) : el;
|
|
55
|
-
var parentTarget = target.parentNode;
|
|
56
|
-
var rect = target.getBoundingClientRect();
|
|
57
|
-
var parentRect = parentTarget.getBoundingClientRect();
|
|
58
|
-
var position = (parentRect.width - rect.width) / 2 * progress * _this._scale;
|
|
59
|
-
var transform = "translate(-50%) translate(" + position + "px)";
|
|
60
|
-
var style = target.style;
|
|
61
|
-
style.cssText += "transform: " + transform + ";-webkit-transform: " + transform + ";-ms-transform:" + transform;
|
|
62
|
-
});
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
this._flicking = null;
|
|
66
|
-
this._selector = selector;
|
|
67
|
-
this._scale = scale;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
var __proto = Parallax.prototype;
|
|
71
|
-
Object.defineProperty(__proto, "selector", {
|
|
72
|
-
get: function () {
|
|
73
|
-
return this._selector;
|
|
74
|
-
},
|
|
75
|
-
set: function (val) {
|
|
76
|
-
this._selector = val;
|
|
77
|
-
},
|
|
78
|
-
enumerable: false,
|
|
79
|
-
configurable: true
|
|
80
|
-
});
|
|
81
|
-
Object.defineProperty(__proto, "scale", {
|
|
82
|
-
get: function () {
|
|
83
|
-
return this._scale;
|
|
84
|
-
},
|
|
85
|
-
set: function (val) {
|
|
86
|
-
this._scale = val;
|
|
87
|
-
},
|
|
88
|
-
enumerable: false,
|
|
89
|
-
configurable: true
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
__proto.init = function (flicking$1) {
|
|
93
|
-
if (this._flicking) {
|
|
94
|
-
this.destroy();
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
this._flicking = flicking$1;
|
|
98
|
-
flicking$1.on(flicking.EVENTS.MOVE, this._onMove);
|
|
99
|
-
flicking$1.on(flicking.EVENTS.AFTER_RESIZE, this.update);
|
|
100
|
-
|
|
101
|
-
this._onMove();
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
__proto.destroy = function () {
|
|
105
|
-
if (!this._flicking) return;
|
|
106
|
-
|
|
107
|
-
this._flicking.off(flicking.EVENTS.MOVE, this._onMove);
|
|
108
|
-
|
|
109
|
-
this._flicking.off(flicking.EVENTS.AFTER_RESIZE, this.update);
|
|
110
|
-
|
|
111
|
-
this._flicking = null;
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
return Parallax;
|
|
115
|
-
}();
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* You can apply fade in / out effect while panel is moving.
|
|
119
|
-
* @ko 패널들을 움직이면서 fade in / out 효과를 부여할 수 있습니다.
|
|
120
|
-
* @memberof Flicking.Plugins
|
|
121
|
-
*/
|
|
122
|
-
|
|
123
|
-
var Fade =
|
|
124
|
-
/*#__PURE__*/
|
|
125
|
-
function () {
|
|
126
|
-
/**
|
|
127
|
-
* @param - The selector of the element to which the fade effect is to be applied. If the selector is blank, it applies to panel element. <ko>Fade 효과를 적용할 대상의 선택자. 선택자가 공백이면 패널 엘리먼트에 적용된다.</ko>
|
|
128
|
-
* @param - Effect amplication scale<ko>효과 증폭도</ko>
|
|
129
|
-
* @example
|
|
130
|
-
* ```ts
|
|
131
|
-
* flicking.addPlugins(new Fade("p", 1));
|
|
132
|
-
* ```
|
|
133
|
-
*/
|
|
134
|
-
function Fade(selector, scale) {
|
|
135
|
-
var _this = this;
|
|
136
|
-
|
|
137
|
-
if (selector === void 0) {
|
|
138
|
-
selector = "";
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
if (scale === void 0) {
|
|
142
|
-
scale = 1;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
this.update = function () {
|
|
146
|
-
_this._onMove();
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
this._onMove = function () {
|
|
150
|
-
var flicking = _this._flicking;
|
|
151
|
-
var selector = _this._selector;
|
|
152
|
-
var scale = _this._scale;
|
|
153
|
-
if (!flicking) return;
|
|
154
|
-
var panels = flicking.visiblePanels;
|
|
155
|
-
panels.forEach(function (panel) {
|
|
156
|
-
var progress = panel.outsetProgress;
|
|
157
|
-
var el = panel.element;
|
|
158
|
-
var target = selector ? el.querySelector(selector) : el;
|
|
159
|
-
|
|
160
|
-
if (target) {
|
|
161
|
-
var opacity = Math.min(1, Math.max(0, 1 - Math.abs(progress * scale)));
|
|
162
|
-
target.style.opacity = "" + opacity;
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
this._flicking = null;
|
|
168
|
-
this._selector = selector;
|
|
169
|
-
this._scale = scale;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
var __proto = Fade.prototype;
|
|
173
|
-
Object.defineProperty(__proto, "selector", {
|
|
174
|
-
get: function () {
|
|
175
|
-
return this._selector;
|
|
176
|
-
},
|
|
177
|
-
set: function (val) {
|
|
178
|
-
this._selector = val;
|
|
179
|
-
},
|
|
180
|
-
enumerable: false,
|
|
181
|
-
configurable: true
|
|
182
|
-
});
|
|
183
|
-
Object.defineProperty(__proto, "scale", {
|
|
184
|
-
get: function () {
|
|
185
|
-
return this._scale;
|
|
186
|
-
},
|
|
187
|
-
set: function (val) {
|
|
188
|
-
this._scale = val;
|
|
189
|
-
},
|
|
190
|
-
enumerable: false,
|
|
191
|
-
configurable: true
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
__proto.init = function (flicking$1) {
|
|
195
|
-
if (this._flicking) {
|
|
196
|
-
this.destroy();
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
this._flicking = flicking$1;
|
|
200
|
-
flicking$1.on(flicking.EVENTS.MOVE, this._onMove);
|
|
201
|
-
flicking$1.on(flicking.EVENTS.AFTER_RESIZE, this.update);
|
|
202
|
-
|
|
203
|
-
this._onMove();
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
__proto.destroy = function () {
|
|
207
|
-
if (!this._flicking) return;
|
|
208
|
-
|
|
209
|
-
this._flicking.off(flicking.EVENTS.MOVE, this._onMove);
|
|
210
|
-
|
|
211
|
-
this._flicking.off(flicking.EVENTS.AFTER_RESIZE, this.update);
|
|
212
|
-
|
|
213
|
-
this._flicking = null;
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
return Fade;
|
|
217
|
-
}();
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* Plugin that allow you to automatically move to the next/previous panel, on a specific time basis
|
|
221
|
-
* @ko 일정 시간마다, 자동으로 다음/이전 패널로 넘어가도록 할 수 있는 플러그인
|
|
222
|
-
* @memberof Flicking.Plugins
|
|
223
|
-
*/
|
|
224
|
-
|
|
225
|
-
var AutoPlay =
|
|
226
|
-
/*#__PURE__*/
|
|
227
|
-
function () {
|
|
228
|
-
/**
|
|
229
|
-
* @param {AutoPlayOptions} options Options for the AutoPlay instance.<ko>AutoPlay 옵션</ko>
|
|
230
|
-
* @param {number} options.duration Time to wait before moving on to the next panel.<ko>다음 패널로 움직이기까지 대기 시간</ko>
|
|
231
|
-
* @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>
|
|
232
|
-
* @param {"PREV" | "NEXT"} options.direction The direction in which the panel moves.<ko>패널이 움직이는 방향</ko>
|
|
233
|
-
* @param {boolean} options.stopOnHover Whether to stop when mouse hover upon the element.<ko>엘리먼트에 마우스를 올렸을 때 AutoPlay를 정지할지 여부</ko>
|
|
234
|
-
* @param {boolean} options.stopOnInit Whether to stop when mouse hover upon the element.<ko>엘리먼트에 마우스를 올렸을 때 AutoPlay를 정지할지 여부</ko>
|
|
235
|
-
* @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>
|
|
236
|
-
* @example
|
|
237
|
-
* ```ts
|
|
238
|
-
* flicking.addPlugins(new AutoPlay({ duration: 2000, direction: "NEXT" }));
|
|
239
|
-
* ```
|
|
240
|
-
*/
|
|
241
|
-
function AutoPlay(_a) {
|
|
242
|
-
var _this = this;
|
|
243
|
-
|
|
244
|
-
var _b = _a === void 0 ? {} : _a,
|
|
245
|
-
_c = _b.duration,
|
|
246
|
-
duration = _c === void 0 ? 2000 : _c,
|
|
247
|
-
_d = _b.animationDuration,
|
|
248
|
-
animationDuration = _d === void 0 ? undefined : _d,
|
|
249
|
-
_e = _b.direction,
|
|
250
|
-
direction = _e === void 0 ? flicking.DIRECTION.NEXT : _e,
|
|
251
|
-
_f = _b.stopOnHover,
|
|
252
|
-
stopOnHover = _f === void 0 ? false : _f,
|
|
253
|
-
_g = _b.stopOnInit,
|
|
254
|
-
stopOnInit = _g === void 0 ? false : _g,
|
|
255
|
-
delayAfterHover = _b.delayAfterHover;
|
|
256
|
-
/* Internal Values */
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
this._flicking = null;
|
|
260
|
-
this._timerId = 0;
|
|
261
|
-
this._mouseEntered = false;
|
|
262
|
-
this._playing = false;
|
|
263
|
-
|
|
264
|
-
this.play = function () {
|
|
265
|
-
_this._movePanel(_this._duration);
|
|
266
|
-
};
|
|
267
|
-
|
|
268
|
-
this.stop = function () {
|
|
269
|
-
_this._playing = false;
|
|
270
|
-
clearTimeout(_this._timerId);
|
|
271
|
-
};
|
|
272
|
-
|
|
273
|
-
this._onMouseEnter = function () {
|
|
274
|
-
_this._mouseEntered = true;
|
|
275
|
-
|
|
276
|
-
_this.stop();
|
|
277
|
-
};
|
|
278
|
-
|
|
279
|
-
this._onMouseLeave = function () {
|
|
280
|
-
_this._mouseEntered = false;
|
|
281
|
-
|
|
282
|
-
_this._movePanel(_this._delayAfterHover);
|
|
283
|
-
};
|
|
284
|
-
|
|
285
|
-
this._duration = duration;
|
|
286
|
-
this._animationDuration = animationDuration;
|
|
287
|
-
this._direction = direction;
|
|
288
|
-
this._stopOnHover = stopOnHover;
|
|
289
|
-
this._stopOnInit = stopOnInit;
|
|
290
|
-
this._delayAfterHover = delayAfterHover !== null && delayAfterHover !== void 0 ? delayAfterHover : duration;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
var __proto = AutoPlay.prototype;
|
|
294
|
-
Object.defineProperty(__proto, "duration", {
|
|
295
|
-
get: function () {
|
|
296
|
-
return this._duration;
|
|
297
|
-
},
|
|
298
|
-
set: function (val) {
|
|
299
|
-
this._duration = val;
|
|
300
|
-
},
|
|
301
|
-
enumerable: false,
|
|
302
|
-
configurable: true
|
|
303
|
-
});
|
|
304
|
-
Object.defineProperty(__proto, "animationDuration", {
|
|
305
|
-
get: function () {
|
|
306
|
-
return this._animationDuration;
|
|
307
|
-
},
|
|
308
|
-
set: function (val) {
|
|
309
|
-
this._animationDuration = val;
|
|
310
|
-
},
|
|
311
|
-
enumerable: false,
|
|
312
|
-
configurable: true
|
|
313
|
-
});
|
|
314
|
-
Object.defineProperty(__proto, "direction", {
|
|
315
|
-
get: function () {
|
|
316
|
-
return this._direction;
|
|
317
|
-
},
|
|
318
|
-
set: function (val) {
|
|
319
|
-
this._direction = val;
|
|
320
|
-
},
|
|
321
|
-
enumerable: false,
|
|
322
|
-
configurable: true
|
|
323
|
-
});
|
|
324
|
-
Object.defineProperty(__proto, "stopOnHover", {
|
|
325
|
-
get: function () {
|
|
326
|
-
return this._stopOnHover;
|
|
327
|
-
},
|
|
328
|
-
set: function (val) {
|
|
329
|
-
this._stopOnHover = val;
|
|
330
|
-
},
|
|
331
|
-
enumerable: false,
|
|
332
|
-
configurable: true
|
|
333
|
-
});
|
|
334
|
-
Object.defineProperty(__proto, "stopOnInit", {
|
|
335
|
-
get: function () {
|
|
336
|
-
return this._stopOnInit;
|
|
337
|
-
},
|
|
338
|
-
set: function (val) {
|
|
339
|
-
this._stopOnInit = val;
|
|
340
|
-
},
|
|
341
|
-
enumerable: false,
|
|
342
|
-
configurable: true
|
|
343
|
-
});
|
|
344
|
-
Object.defineProperty(__proto, "delayAfterHover", {
|
|
345
|
-
get: function () {
|
|
346
|
-
return this._delayAfterHover;
|
|
347
|
-
},
|
|
348
|
-
set: function (val) {
|
|
349
|
-
this._delayAfterHover = val;
|
|
350
|
-
},
|
|
351
|
-
enumerable: false,
|
|
352
|
-
configurable: true
|
|
353
|
-
});
|
|
354
|
-
Object.defineProperty(__proto, "playing", {
|
|
355
|
-
get: function () {
|
|
356
|
-
return this._playing;
|
|
357
|
-
},
|
|
358
|
-
enumerable: false,
|
|
359
|
-
configurable: true
|
|
360
|
-
});
|
|
361
|
-
|
|
362
|
-
__proto.init = function (flicking$1) {
|
|
363
|
-
var _a;
|
|
364
|
-
|
|
365
|
-
if (this._flicking) {
|
|
366
|
-
this.destroy();
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
flicking$1.on((_a = {}, _a[flicking.EVENTS.MOVE_START] = this.stop, _a[flicking.EVENTS.HOLD_START] = this.stop, _a[flicking.EVENTS.MOVE_END] = this.play, _a[flicking.EVENTS.SELECT] = this.play, _a));
|
|
370
|
-
this._flicking = flicking$1;
|
|
371
|
-
|
|
372
|
-
if (this._stopOnHover) {
|
|
373
|
-
var targetEl = this._flicking.element;
|
|
374
|
-
targetEl.addEventListener("mouseenter", this._onMouseEnter, false);
|
|
375
|
-
targetEl.addEventListener("mouseleave", this._onMouseLeave, false);
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
if (!this._stopOnInit) {
|
|
379
|
-
this.play();
|
|
380
|
-
}
|
|
381
|
-
};
|
|
382
|
-
|
|
383
|
-
__proto.destroy = function () {
|
|
384
|
-
var flicking$1 = this._flicking;
|
|
385
|
-
this._mouseEntered = false;
|
|
386
|
-
this.stop();
|
|
387
|
-
|
|
388
|
-
if (!flicking$1) {
|
|
389
|
-
return;
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
flicking$1.off(flicking.EVENTS.MOVE_START, this.stop);
|
|
393
|
-
flicking$1.off(flicking.EVENTS.HOLD_START, this.stop);
|
|
394
|
-
flicking$1.off(flicking.EVENTS.MOVE_END, this.play);
|
|
395
|
-
flicking$1.off(flicking.EVENTS.SELECT, this.play);
|
|
396
|
-
var targetEl = flicking$1.element;
|
|
397
|
-
targetEl.removeEventListener("mouseenter", this._onMouseEnter, false);
|
|
398
|
-
targetEl.removeEventListener("mouseleave", this._onMouseLeave, false);
|
|
399
|
-
this._flicking = null;
|
|
400
|
-
};
|
|
401
|
-
|
|
402
|
-
__proto.update = function () {// DO-NOTHING
|
|
403
|
-
};
|
|
404
|
-
|
|
405
|
-
__proto._movePanel = function (duration) {
|
|
406
|
-
var _this = this;
|
|
407
|
-
|
|
408
|
-
var flicking$1 = this._flicking;
|
|
409
|
-
var direction = this._direction;
|
|
410
|
-
|
|
411
|
-
if (!flicking$1) {
|
|
412
|
-
return;
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
this.stop();
|
|
416
|
-
|
|
417
|
-
if (this._mouseEntered || flicking$1.animating) {
|
|
418
|
-
return;
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
this._playing = true;
|
|
422
|
-
this._timerId = window.setTimeout(function () {
|
|
423
|
-
var _a, _b;
|
|
424
|
-
|
|
425
|
-
var animationDuration = _this._animationDuration || flicking$1.duration;
|
|
426
|
-
var moveType = flicking$1.moveType; // for freeScroll
|
|
427
|
-
|
|
428
|
-
if (moveType === flicking.MOVE_TYPE.FREE_SCROLL || (moveType === null || moveType === void 0 ? void 0 : moveType[0]) === flicking.MOVE_TYPE.FREE_SCROLL) {
|
|
429
|
-
var range = flicking$1.camera.range;
|
|
430
|
-
var cameraPosition = flicking$1.camera.position;
|
|
431
|
-
var currentPanel = flicking$1.currentPanel;
|
|
432
|
-
var prevPanel = currentPanel.prev();
|
|
433
|
-
var nextPanel = currentPanel.next();
|
|
434
|
-
var currentPosition = currentPanel.position;
|
|
435
|
-
var nextPosition = (_a = nextPanel === null || nextPanel === void 0 ? void 0 : nextPanel.position) !== null && _a !== void 0 ? _a : range.max;
|
|
436
|
-
var prevPosition = (_b = prevPanel === null || prevPanel === void 0 ? void 0 : prevPanel.position) !== null && _b !== void 0 ? _b : range.min; // circular: prev (last) > cur (0) => prev(-1) < cur(0)
|
|
437
|
-
|
|
438
|
-
if (prevPosition > currentPosition) {
|
|
439
|
-
prevPosition = range.min - (range.max - prevPosition);
|
|
440
|
-
} // current (last) > next (0)
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
if (nextPosition < currentPosition) {
|
|
444
|
-
nextPosition += range.max;
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
if (direction === flicking.DIRECTION.NEXT) {
|
|
448
|
-
// prev - cur - camera - next
|
|
449
|
-
var size = nextPosition - currentPosition;
|
|
450
|
-
var restSize = nextPosition - cameraPosition;
|
|
451
|
-
|
|
452
|
-
if (cameraPosition < currentPosition) {
|
|
453
|
-
// prev - camera - cur - next
|
|
454
|
-
restSize = nextPosition - cameraPosition;
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
animationDuration *= restSize / size;
|
|
458
|
-
} else {
|
|
459
|
-
// prev - caemra - cur - next
|
|
460
|
-
var size = currentPosition - prevPosition;
|
|
461
|
-
var restSize = cameraPosition - prevPosition;
|
|
462
|
-
|
|
463
|
-
if (cameraPosition > currentPosition) {
|
|
464
|
-
// prev - cur - camera - next
|
|
465
|
-
restSize = cameraPosition - prevPosition;
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
animationDuration *= restSize / size;
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
if (direction === flicking.DIRECTION.NEXT) {
|
|
473
|
-
flicking$1.next(animationDuration).catch(function () {
|
|
474
|
-
return void 0;
|
|
475
|
-
});
|
|
476
|
-
} else {
|
|
477
|
-
flicking$1.prev(animationDuration).catch(function () {
|
|
478
|
-
return void 0;
|
|
479
|
-
});
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
_this.play();
|
|
483
|
-
}, duration);
|
|
484
|
-
};
|
|
485
|
-
|
|
486
|
-
return AutoPlay;
|
|
487
|
-
}();
|
|
488
|
-
|
|
489
|
-
var BROWSER = {
|
|
490
|
-
CLICK: "click",
|
|
491
|
-
MOUSE_DOWN: "mousedown",
|
|
492
|
-
TOUCH_START: "touchstart"
|
|
493
|
-
};
|
|
494
|
-
|
|
495
|
-
var ARROW = {
|
|
1
|
+
(function(global, factory) {
|
|
2
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("@egjs/flicking")) : typeof define === "function" && define.amd ? define(["exports", "@egjs/flicking"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory((global.Flicking = global.Flicking || {}, global.Flicking.Plugins = {}), global.Flicking));
|
|
3
|
+
})(this, (function(exports2, flicking) {
|
|
4
|
+
"use strict";
|
|
5
|
+
const ARROW = {
|
|
496
6
|
PREV_SELECTOR: ".flicking-arrow-prev",
|
|
497
7
|
NEXT_SELECTOR: ".flicking-arrow-next",
|
|
498
8
|
DISABLED_CLASS: "flicking-arrow-disabled"
|
|
499
9
|
};
|
|
500
|
-
|
|
10
|
+
const PAGINATION = {
|
|
501
11
|
SELECTOR: ".flicking-pagination",
|
|
502
12
|
PREFIX: "flicking-pagination",
|
|
503
13
|
BULLET_WRAPPER_SUFFIX: "bullets",
|
|
@@ -517,496 +27,794 @@ version: 4.8.0-beta.1
|
|
|
517
27
|
SCROLL: "scroll"
|
|
518
28
|
}
|
|
519
29
|
};
|
|
520
|
-
|
|
30
|
+
const SYNC = {
|
|
521
31
|
TYPE: {
|
|
522
32
|
CAMERA: "camera",
|
|
523
33
|
INDEX: "index"
|
|
524
34
|
}
|
|
525
35
|
};
|
|
526
|
-
|
|
527
|
-
|
|
36
|
+
const BROWSER = {
|
|
37
|
+
CLICK: "click",
|
|
38
|
+
MOUSE_DOWN: "mousedown",
|
|
39
|
+
TOUCH_START: "touchstart"
|
|
40
|
+
};
|
|
41
|
+
const addClass = (el, className) => {
|
|
528
42
|
if (!el) return;
|
|
529
|
-
|
|
530
43
|
if (el.classList) {
|
|
531
44
|
el.classList.add(className);
|
|
532
45
|
} else {
|
|
533
|
-
|
|
534
|
-
|
|
46
|
+
const classes = el.className.split(" ");
|
|
535
47
|
if (classes.indexOf(className) < 0) {
|
|
536
|
-
el.className = el.className
|
|
48
|
+
el.className = `${el.className} ${className}`;
|
|
537
49
|
}
|
|
538
50
|
}
|
|
539
51
|
};
|
|
540
|
-
|
|
52
|
+
const removeClass = (el, className) => {
|
|
541
53
|
if (!el) return;
|
|
542
|
-
|
|
543
54
|
if (el.classList) {
|
|
544
55
|
el.classList.remove(className);
|
|
545
56
|
} else {
|
|
546
|
-
|
|
57
|
+
const classRegex = new RegExp(`( |^)${className}( |$)`, "g");
|
|
547
58
|
el.className.replace(classRegex, " ");
|
|
548
59
|
}
|
|
549
60
|
};
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
61
|
+
const getElement = (selector, parent, pluginName) => {
|
|
62
|
+
const el = parent.querySelector(selector);
|
|
553
63
|
if (!el) {
|
|
554
|
-
throw new Error(
|
|
64
|
+
throw new Error(`[Flicking-${pluginName}] Couldn't find element with the given selector: ${selector}`);
|
|
555
65
|
}
|
|
556
|
-
|
|
557
66
|
return el;
|
|
558
67
|
};
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
function () {
|
|
569
|
-
function Arrow(_a) {
|
|
570
|
-
var _this = this;
|
|
571
|
-
|
|
572
|
-
var _b = _a === void 0 ? {} : _a,
|
|
573
|
-
_c = _b.parentEl,
|
|
574
|
-
parentEl = _c === void 0 ? null : _c,
|
|
575
|
-
_d = _b.prevElSelector,
|
|
576
|
-
prevElSelector = _d === void 0 ? ARROW.PREV_SELECTOR : _d,
|
|
577
|
-
_e = _b.nextElSelector,
|
|
578
|
-
nextElSelector = _e === void 0 ? ARROW.NEXT_SELECTOR : _e,
|
|
579
|
-
_f = _b.disabledClass,
|
|
580
|
-
disabledClass = _f === void 0 ? ARROW.DISABLED_CLASS : _f,
|
|
581
|
-
_g = _b.moveCount,
|
|
582
|
-
moveCount = _g === void 0 ? 1 : _g,
|
|
583
|
-
_h = _b.moveByViewportSize,
|
|
584
|
-
moveByViewportSize = _h === void 0 ? false : _h,
|
|
585
|
-
_j = _b.interruptable,
|
|
586
|
-
interruptable = _j === void 0 ? false : _j;
|
|
587
|
-
/* Internal Values */
|
|
588
|
-
|
|
589
|
-
|
|
68
|
+
class Arrow {
|
|
69
|
+
/**
|
|
70
|
+
* @param options - Options for the Arrow instance
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* flicking.addPlugins(new Arrow({ parentEl: null, prevElSelector: ".flicking-arrow-prev", nextElSelector: ".flicking-arrow-next" }));
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
constructor(options = {}) {
|
|
590
77
|
this._flicking = null;
|
|
591
|
-
|
|
592
|
-
this._preventInputPropagation = function (e) {
|
|
78
|
+
this._preventInputPropagation = (e) => {
|
|
593
79
|
e.stopPropagation();
|
|
594
80
|
};
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
if (
|
|
603
|
-
|
|
604
|
-
if (flicking.animating) {
|
|
605
|
-
flicking.stopAnimation();
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
var firstAnchor = anchorPoints[0];
|
|
609
|
-
var moveCount = _this._moveCount;
|
|
610
|
-
|
|
611
|
-
if (_this._moveByViewportSize) {
|
|
612
|
-
flicking.control.moveToPosition(camera.position - camera.size, flicking.duration).catch(_this._onCatch);
|
|
81
|
+
this._onPrevClick = () => {
|
|
82
|
+
const flicking2 = this._flicking;
|
|
83
|
+
const camera = flicking2.camera;
|
|
84
|
+
const anchorPoints = camera.anchorPoints;
|
|
85
|
+
if (flicking2.animating || anchorPoints.length <= 0) return;
|
|
86
|
+
const firstAnchor = anchorPoints[0];
|
|
87
|
+
const moveCount2 = this._moveCount;
|
|
88
|
+
if (this._moveByViewportSize) {
|
|
89
|
+
flicking2.control.moveToPosition(camera.position - camera.size, flicking2.duration).catch(this._onCatch);
|
|
613
90
|
} else {
|
|
614
|
-
if (
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
for (var i = 0; i < moveCount; i++) {
|
|
91
|
+
if (flicking2.circularEnabled) {
|
|
92
|
+
let targetPanel = flicking2.currentPanel;
|
|
93
|
+
for (let i = 0; i < moveCount2; i++) {
|
|
618
94
|
targetPanel = targetPanel.prev();
|
|
619
95
|
}
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
flicking.moveTo(Math.max(index - moveCount, firstAnchor.panel.index)).catch(_this._onCatch);
|
|
96
|
+
targetPanel.focus().catch(this._onCatch);
|
|
97
|
+
} else if (flicking2.index > firstAnchor.panel.index) {
|
|
98
|
+
flicking2.moveTo(Math.max(flicking2.index - moveCount2, firstAnchor.panel.index)).catch(this._onCatch);
|
|
624
99
|
} else if (camera.position > camera.range.min) {
|
|
625
|
-
|
|
100
|
+
flicking2.moveTo(flicking2.index).catch(this._onCatch);
|
|
626
101
|
}
|
|
627
102
|
}
|
|
628
103
|
};
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
if (
|
|
637
|
-
|
|
638
|
-
if (flicking.animating) {
|
|
639
|
-
flicking.stopAnimation();
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
var lastAnchor = anchorPoints[anchorPoints.length - 1];
|
|
643
|
-
var moveCount = _this._moveCount;
|
|
644
|
-
|
|
645
|
-
if (_this._moveByViewportSize) {
|
|
646
|
-
flicking.control.moveToPosition(camera.position + camera.size, flicking.duration).catch(_this._onCatch);
|
|
104
|
+
this._onNextClick = () => {
|
|
105
|
+
const flicking2 = this._flicking;
|
|
106
|
+
const camera = flicking2.camera;
|
|
107
|
+
const anchorPoints = camera.anchorPoints;
|
|
108
|
+
if (flicking2.animating || anchorPoints.length <= 0) return;
|
|
109
|
+
const lastAnchor = anchorPoints[anchorPoints.length - 1];
|
|
110
|
+
const moveCount2 = this._moveCount;
|
|
111
|
+
if (this._moveByViewportSize) {
|
|
112
|
+
flicking2.control.moveToPosition(camera.position + camera.size, flicking2.duration).catch(this._onCatch);
|
|
647
113
|
} else {
|
|
648
|
-
if (
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
for (var i = 0; i < moveCount; i++) {
|
|
114
|
+
if (flicking2.circularEnabled) {
|
|
115
|
+
let targetPanel = flicking2.currentPanel;
|
|
116
|
+
for (let i = 0; i < moveCount2; i++) {
|
|
652
117
|
targetPanel = targetPanel.next();
|
|
653
118
|
}
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
flicking.moveTo(Math.min(index + moveCount, lastAnchor.panel.index)).catch(_this._onCatch);
|
|
119
|
+
targetPanel.focus().catch(this._onCatch);
|
|
120
|
+
} else if (flicking2.index < lastAnchor.panel.index) {
|
|
121
|
+
flicking2.moveTo(Math.min(flicking2.index + moveCount2, lastAnchor.panel.index)).catch(this._onCatch);
|
|
658
122
|
} else if (camera.position > camera.range.min) {
|
|
659
|
-
|
|
123
|
+
flicking2.moveTo(flicking2.index).catch(this._onCatch);
|
|
660
124
|
}
|
|
661
125
|
}
|
|
662
126
|
};
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
if (flicking.holding) {
|
|
670
|
-
_this._updateClass(camera.position);
|
|
127
|
+
this._onAnimation = () => {
|
|
128
|
+
const flicking2 = this._flicking;
|
|
129
|
+
const camera = flicking2.camera;
|
|
130
|
+
const controller = flicking2.control.controller;
|
|
131
|
+
if (flicking2.holding) {
|
|
132
|
+
this._updateClass(camera.position);
|
|
671
133
|
} else {
|
|
672
|
-
|
|
134
|
+
this._updateClass(controller.animatingContext.end);
|
|
673
135
|
}
|
|
674
136
|
};
|
|
675
|
-
|
|
676
|
-
this._onWillChange = function (e) {
|
|
677
|
-
_this._nextIndex = e.index;
|
|
678
|
-
};
|
|
679
|
-
|
|
680
|
-
this._onCatch = function (err) {
|
|
137
|
+
this._onCatch = (err) => {
|
|
681
138
|
if (err instanceof flicking.FlickingError) return;
|
|
682
139
|
throw err;
|
|
683
140
|
};
|
|
684
|
-
|
|
141
|
+
const {
|
|
142
|
+
parentEl = null,
|
|
143
|
+
prevElSelector = ARROW.PREV_SELECTOR,
|
|
144
|
+
nextElSelector = ARROW.NEXT_SELECTOR,
|
|
145
|
+
disabledClass = ARROW.DISABLED_CLASS,
|
|
146
|
+
moveCount = 1,
|
|
147
|
+
moveByViewportSize = false
|
|
148
|
+
} = options;
|
|
685
149
|
this._parentEl = parentEl;
|
|
686
150
|
this._prevElSelector = prevElSelector;
|
|
687
151
|
this._nextElSelector = nextElSelector;
|
|
688
152
|
this._disabledClass = disabledClass;
|
|
689
153
|
this._moveCount = moveCount;
|
|
690
154
|
this._moveByViewportSize = moveByViewportSize;
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
enumerable: false,
|
|
757
|
-
configurable: true
|
|
758
|
-
});
|
|
759
|
-
Object.defineProperty(__proto, "moveByViewportSize", {
|
|
760
|
-
get: function () {
|
|
761
|
-
return this._moveByViewportSize;
|
|
762
|
-
},
|
|
763
|
-
set: function (val) {
|
|
764
|
-
this._moveByViewportSize = val;
|
|
765
|
-
},
|
|
766
|
-
enumerable: false,
|
|
767
|
-
configurable: true
|
|
768
|
-
});
|
|
769
|
-
Object.defineProperty(__proto, "interruptable", {
|
|
770
|
-
get: function () {
|
|
771
|
-
return this._interruptable;
|
|
772
|
-
},
|
|
773
|
-
set: function (val) {
|
|
774
|
-
this._interruptable = val;
|
|
775
|
-
},
|
|
776
|
-
enumerable: false,
|
|
777
|
-
configurable: true
|
|
778
|
-
});
|
|
779
|
-
|
|
780
|
-
__proto.init = function (flicking$1) {
|
|
781
|
-
var _this = this;
|
|
782
|
-
|
|
155
|
+
}
|
|
156
|
+
/** The "previous" arrow HTMLElement
|
|
157
|
+
* @readonly
|
|
158
|
+
*/
|
|
159
|
+
get prevEl() {
|
|
160
|
+
return this._prevEl;
|
|
161
|
+
}
|
|
162
|
+
/** The "next" arrow HTMLElement
|
|
163
|
+
* @readonly
|
|
164
|
+
*/
|
|
165
|
+
get nextEl() {
|
|
166
|
+
return this._nextEl;
|
|
167
|
+
}
|
|
168
|
+
/** Current value of the {@link ArrowOptions.parentEl | parentEl} option. */
|
|
169
|
+
get parentEl() {
|
|
170
|
+
return this._parentEl;
|
|
171
|
+
}
|
|
172
|
+
/** Current value of the {@link ArrowOptions.prevElSelector | prevElSelector} option. */
|
|
173
|
+
get prevElSelector() {
|
|
174
|
+
return this._prevElSelector;
|
|
175
|
+
}
|
|
176
|
+
/** Current value of the {@link ArrowOptions.nextElSelector | nextElSelector} option. */
|
|
177
|
+
get nextElSelector() {
|
|
178
|
+
return this._nextElSelector;
|
|
179
|
+
}
|
|
180
|
+
/** Current value of the {@link ArrowOptions.disabledClass | disabledClass} option. */
|
|
181
|
+
get disabledClass() {
|
|
182
|
+
return this._disabledClass;
|
|
183
|
+
}
|
|
184
|
+
/** Current value of the {@link ArrowOptions.moveCount | moveCount} option. */
|
|
185
|
+
get moveCount() {
|
|
186
|
+
return this._moveCount;
|
|
187
|
+
}
|
|
188
|
+
/** Current value of the {@link ArrowOptions.moveByViewportSize | moveByViewportSize} option. */
|
|
189
|
+
get moveByViewportSize() {
|
|
190
|
+
return this._moveByViewportSize;
|
|
191
|
+
}
|
|
192
|
+
/** Sets {@link ArrowOptions.parentEl | parentEl}. */
|
|
193
|
+
set parentEl(val) {
|
|
194
|
+
this._parentEl = val;
|
|
195
|
+
}
|
|
196
|
+
/** Sets {@link ArrowOptions.prevElSelector | prevElSelector}. */
|
|
197
|
+
set prevElSelector(val) {
|
|
198
|
+
this._prevElSelector = val;
|
|
199
|
+
}
|
|
200
|
+
/** Sets {@link ArrowOptions.nextElSelector | nextElSelector}. */
|
|
201
|
+
set nextElSelector(val) {
|
|
202
|
+
this._nextElSelector = val;
|
|
203
|
+
}
|
|
204
|
+
/** Sets {@link ArrowOptions.disabledClass | disabledClass}. */
|
|
205
|
+
set disabledClass(val) {
|
|
206
|
+
this._disabledClass = val;
|
|
207
|
+
}
|
|
208
|
+
/** Sets {@link ArrowOptions.moveCount | moveCount}. */
|
|
209
|
+
set moveCount(val) {
|
|
210
|
+
this._moveCount = val;
|
|
211
|
+
}
|
|
212
|
+
/** Sets {@link ArrowOptions.moveByViewportSize | moveByViewportSize}. */
|
|
213
|
+
set moveByViewportSize(val) {
|
|
214
|
+
this._moveByViewportSize = val;
|
|
215
|
+
}
|
|
216
|
+
/** Initialize the plugin and attach arrow event listeners to the Flicking instance.
|
|
217
|
+
* @param flicking - The Flicking instance to attach this plugin to
|
|
218
|
+
*/
|
|
219
|
+
init(flicking$1) {
|
|
783
220
|
if (this._flicking) {
|
|
784
221
|
this.destroy();
|
|
785
222
|
}
|
|
786
|
-
|
|
787
223
|
this._flicking = flicking$1;
|
|
788
224
|
flicking$1.on(flicking.EVENTS.MOVE, this._onAnimation);
|
|
789
|
-
flicking$1.
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
passive: true
|
|
796
|
-
});
|
|
797
|
-
nextEl.addEventListener(evt, _this._preventInputPropagation, {
|
|
798
|
-
passive: true
|
|
799
|
-
});
|
|
225
|
+
const parentEl = this._parentEl ? this._parentEl : flicking$1.element;
|
|
226
|
+
const prevEl = getElement(this._prevElSelector, parentEl, "Arrow");
|
|
227
|
+
const nextEl = getElement(this._nextElSelector, parentEl, "Arrow");
|
|
228
|
+
[BROWSER.MOUSE_DOWN, BROWSER.TOUCH_START].forEach((evt) => {
|
|
229
|
+
prevEl.addEventListener(evt, this._preventInputPropagation, { passive: true });
|
|
230
|
+
nextEl.addEventListener(evt, this._preventInputPropagation, { passive: true });
|
|
800
231
|
});
|
|
801
232
|
prevEl.addEventListener(BROWSER.CLICK, this._onPrevClick);
|
|
802
233
|
nextEl.addEventListener(BROWSER.CLICK, this._onNextClick);
|
|
803
234
|
this._prevEl = prevEl;
|
|
804
235
|
this._nextEl = nextEl;
|
|
805
236
|
this.update();
|
|
806
|
-
}
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
var flicking$1 = this._flicking;
|
|
812
|
-
|
|
237
|
+
}
|
|
238
|
+
/** Destroy the plugin and remove all arrow event listeners. */
|
|
239
|
+
destroy() {
|
|
240
|
+
const flicking$1 = this._flicking;
|
|
813
241
|
if (!flicking$1) {
|
|
814
242
|
return;
|
|
815
243
|
}
|
|
816
|
-
|
|
817
244
|
flicking$1.off(flicking.EVENTS.MOVE, this._onAnimation);
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
nextEl.removeEventListener(evt, _this._preventInputPropagation);
|
|
245
|
+
const prevEl = this._prevEl;
|
|
246
|
+
const nextEl = this._nextEl;
|
|
247
|
+
[BROWSER.MOUSE_DOWN, BROWSER.TOUCH_START].forEach((evt) => {
|
|
248
|
+
prevEl.removeEventListener(evt, this._preventInputPropagation);
|
|
249
|
+
nextEl.removeEventListener(evt, this._preventInputPropagation);
|
|
824
250
|
});
|
|
825
251
|
prevEl.removeEventListener(BROWSER.CLICK, this._onPrevClick);
|
|
826
252
|
nextEl.removeEventListener(BROWSER.CLICK, this._onNextClick);
|
|
827
253
|
this._flicking = null;
|
|
828
|
-
}
|
|
829
|
-
|
|
830
|
-
|
|
254
|
+
}
|
|
255
|
+
/** Update the arrow disabled/enabled state based on the current camera position. */
|
|
256
|
+
update() {
|
|
831
257
|
this._updateClass(this._flicking.camera.position);
|
|
832
|
-
}
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
var stopAtNextEdge = flicking.circularEnabled ? false : pos >= cameraRange.max;
|
|
842
|
-
|
|
258
|
+
}
|
|
259
|
+
_updateClass(pos) {
|
|
260
|
+
const flicking2 = this._flicking;
|
|
261
|
+
const disabledClass = this._disabledClass;
|
|
262
|
+
const prevEl = this._prevEl;
|
|
263
|
+
const nextEl = this._nextEl;
|
|
264
|
+
const cameraRange = flicking2.camera.range;
|
|
265
|
+
const stopAtPrevEdge = flicking2.circularEnabled ? false : pos <= cameraRange.min;
|
|
266
|
+
const stopAtNextEdge = flicking2.circularEnabled ? false : pos >= cameraRange.max;
|
|
843
267
|
if (stopAtPrevEdge) {
|
|
844
268
|
addClass(prevEl, disabledClass);
|
|
845
269
|
} else {
|
|
846
270
|
removeClass(prevEl, disabledClass);
|
|
847
271
|
}
|
|
848
|
-
|
|
849
272
|
if (stopAtNextEdge) {
|
|
850
273
|
addClass(nextEl, disabledClass);
|
|
851
274
|
} else {
|
|
852
275
|
removeClass(nextEl, disabledClass);
|
|
853
276
|
}
|
|
854
|
-
}
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
class AutoPlay {
|
|
280
|
+
/**
|
|
281
|
+
* @param options - Options for the AutoPlay instance
|
|
282
|
+
* @example
|
|
283
|
+
* ```ts
|
|
284
|
+
* flicking.addPlugins(new AutoPlay({ duration: 2000, direction: "NEXT" }));
|
|
285
|
+
* ```
|
|
286
|
+
*/
|
|
287
|
+
constructor(options = {}) {
|
|
288
|
+
this._flicking = null;
|
|
289
|
+
this._timerId = 0;
|
|
290
|
+
this._mouseEntered = false;
|
|
291
|
+
this._playing = false;
|
|
292
|
+
this.play = () => {
|
|
293
|
+
this._movePanel(this._duration);
|
|
294
|
+
};
|
|
295
|
+
this.stop = () => {
|
|
296
|
+
this._playing = false;
|
|
297
|
+
clearTimeout(this._timerId);
|
|
298
|
+
};
|
|
299
|
+
this._onMouseEnter = () => {
|
|
300
|
+
this._mouseEntered = true;
|
|
301
|
+
this.stop();
|
|
302
|
+
};
|
|
303
|
+
this._onMouseLeave = () => {
|
|
304
|
+
this._mouseEntered = false;
|
|
305
|
+
this._movePanel(this._delayAfterHover);
|
|
306
|
+
};
|
|
307
|
+
const {
|
|
308
|
+
duration = 2e3,
|
|
309
|
+
animationDuration = void 0,
|
|
310
|
+
direction = flicking.DIRECTION.NEXT,
|
|
311
|
+
stopOnHover = false,
|
|
312
|
+
stopOnInit = false,
|
|
313
|
+
delayAfterHover
|
|
314
|
+
} = options;
|
|
315
|
+
this._duration = duration;
|
|
316
|
+
this._animationDuration = animationDuration;
|
|
317
|
+
this._direction = direction;
|
|
318
|
+
this._stopOnHover = stopOnHover;
|
|
319
|
+
this._stopOnInit = stopOnInit;
|
|
320
|
+
this._delayAfterHover = delayAfterHover != null ? delayAfterHover : duration;
|
|
321
|
+
}
|
|
322
|
+
/** Current value of the {@link AutoPlayOptions.duration | duration} option. */
|
|
323
|
+
get duration() {
|
|
324
|
+
return this._duration;
|
|
325
|
+
}
|
|
326
|
+
/** Current value of the {@link AutoPlayOptions.animationDuration | animationDuration} option. */
|
|
327
|
+
get animationDuration() {
|
|
328
|
+
return this._animationDuration;
|
|
329
|
+
}
|
|
330
|
+
/** Current value of the {@link AutoPlayOptions.direction | direction} option. */
|
|
331
|
+
get direction() {
|
|
332
|
+
return this._direction;
|
|
333
|
+
}
|
|
334
|
+
/** Current value of the {@link AutoPlayOptions.stopOnHover | stopOnHover} option. */
|
|
335
|
+
get stopOnHover() {
|
|
336
|
+
return this._stopOnHover;
|
|
337
|
+
}
|
|
338
|
+
/** Current value of the {@link AutoPlayOptions.stopOnInit | stopOnInit} option. */
|
|
339
|
+
get stopOnInit() {
|
|
340
|
+
return this._stopOnInit;
|
|
341
|
+
}
|
|
342
|
+
/** Current value of the {@link AutoPlayOptions.delayAfterHover | delayAfterHover} option. */
|
|
343
|
+
get delayAfterHover() {
|
|
344
|
+
return this._delayAfterHover;
|
|
345
|
+
}
|
|
346
|
+
/** Whether the autoplay is currently active
|
|
347
|
+
* @readonly
|
|
348
|
+
*/
|
|
349
|
+
get playing() {
|
|
350
|
+
return this._playing;
|
|
351
|
+
}
|
|
352
|
+
/** Sets {@link AutoPlayOptions.duration | duration}. */
|
|
353
|
+
set duration(val) {
|
|
354
|
+
this._duration = val;
|
|
355
|
+
}
|
|
356
|
+
/** Sets {@link AutoPlayOptions.animationDuration | animationDuration}. */
|
|
357
|
+
set animationDuration(val) {
|
|
358
|
+
this._animationDuration = val;
|
|
359
|
+
}
|
|
360
|
+
/** Sets {@link AutoPlayOptions.direction | direction}. */
|
|
361
|
+
set direction(val) {
|
|
362
|
+
this._direction = val;
|
|
363
|
+
}
|
|
364
|
+
/** Sets {@link AutoPlayOptions.stopOnHover | stopOnHover}. */
|
|
365
|
+
set stopOnHover(val) {
|
|
366
|
+
this._stopOnHover = val;
|
|
367
|
+
}
|
|
368
|
+
/** Sets {@link AutoPlayOptions.stopOnInit | stopOnInit}. */
|
|
369
|
+
set stopOnInit(val) {
|
|
370
|
+
this._stopOnInit = val;
|
|
371
|
+
}
|
|
372
|
+
/** Sets {@link AutoPlayOptions.delayAfterHover | delayAfterHover}. */
|
|
373
|
+
set delayAfterHover(val) {
|
|
374
|
+
this._delayAfterHover = val;
|
|
375
|
+
}
|
|
376
|
+
/** Initialize the plugin and start autoplay on the given Flicking instance.
|
|
377
|
+
* @param flicking - The Flicking instance to attach this plugin to
|
|
378
|
+
*/
|
|
379
|
+
init(flicking$1) {
|
|
380
|
+
if (this._flicking) {
|
|
381
|
+
this.destroy();
|
|
382
|
+
}
|
|
383
|
+
flicking$1.on({
|
|
384
|
+
[flicking.EVENTS.MOVE_START]: this.stop,
|
|
385
|
+
[flicking.EVENTS.HOLD_START]: this.stop,
|
|
386
|
+
[flicking.EVENTS.MOVE_END]: this.play,
|
|
387
|
+
[flicking.EVENTS.SELECT]: this.play
|
|
388
|
+
});
|
|
389
|
+
this._flicking = flicking$1;
|
|
390
|
+
if (this._stopOnHover) {
|
|
391
|
+
const targetEl = this._flicking.element;
|
|
392
|
+
targetEl.addEventListener("mouseenter", this._onMouseEnter, false);
|
|
393
|
+
targetEl.addEventListener("mouseleave", this._onMouseLeave, false);
|
|
394
|
+
}
|
|
395
|
+
if (!this._stopOnInit) {
|
|
396
|
+
this.play();
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
/** Destroy the plugin, stop autoplay, and remove all event listeners. */
|
|
400
|
+
destroy() {
|
|
401
|
+
const flicking$1 = this._flicking;
|
|
402
|
+
this._mouseEntered = false;
|
|
403
|
+
this.stop();
|
|
404
|
+
if (!flicking$1) {
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
flicking$1.off(flicking.EVENTS.MOVE_START, this.stop);
|
|
408
|
+
flicking$1.off(flicking.EVENTS.HOLD_START, this.stop);
|
|
409
|
+
flicking$1.off(flicking.EVENTS.MOVE_END, this.play);
|
|
410
|
+
flicking$1.off(flicking.EVENTS.SELECT, this.play);
|
|
411
|
+
const targetEl = flicking$1.element;
|
|
412
|
+
targetEl.removeEventListener("mouseenter", this._onMouseEnter, false);
|
|
413
|
+
targetEl.removeEventListener("mouseleave", this._onMouseLeave, false);
|
|
414
|
+
this._flicking = null;
|
|
415
|
+
}
|
|
416
|
+
/** Update the plugin state. This is a no-op for AutoPlay. */
|
|
417
|
+
update() {
|
|
418
|
+
}
|
|
419
|
+
_movePanel(duration) {
|
|
420
|
+
const flicking$1 = this._flicking;
|
|
421
|
+
const direction = this._direction;
|
|
422
|
+
if (!flicking$1) {
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
this.stop();
|
|
426
|
+
if (this._mouseEntered || flicking$1.animating) {
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
this._playing = true;
|
|
430
|
+
this._timerId = window.setTimeout(() => {
|
|
431
|
+
var _a, _b;
|
|
432
|
+
let animationDuration = this._animationDuration || flicking$1.duration;
|
|
433
|
+
const moveType = flicking$1.moveType;
|
|
434
|
+
if (moveType === flicking.MOVE_TYPE.FREE_SCROLL || (moveType == null ? void 0 : moveType[0]) === flicking.MOVE_TYPE.FREE_SCROLL) {
|
|
435
|
+
const range = flicking$1.camera.range;
|
|
436
|
+
const cameraPosition = flicking$1.camera.position;
|
|
437
|
+
const currentPanel = flicking$1.currentPanel;
|
|
438
|
+
const prevPanel = currentPanel.prev();
|
|
439
|
+
const nextPanel = currentPanel.next();
|
|
440
|
+
const currentPosition = currentPanel.position;
|
|
441
|
+
let nextPosition = (_a = nextPanel == null ? void 0 : nextPanel.position) != null ? _a : range.max;
|
|
442
|
+
let prevPosition = (_b = prevPanel == null ? void 0 : prevPanel.position) != null ? _b : range.min;
|
|
443
|
+
if (prevPosition > currentPosition) {
|
|
444
|
+
prevPosition = range.min - (range.max - prevPosition);
|
|
445
|
+
}
|
|
446
|
+
if (nextPosition < currentPosition) {
|
|
447
|
+
nextPosition += range.max;
|
|
448
|
+
}
|
|
449
|
+
if (direction === flicking.DIRECTION.NEXT) {
|
|
450
|
+
const size = nextPosition - currentPosition;
|
|
451
|
+
let restSize = nextPosition - cameraPosition;
|
|
452
|
+
if (cameraPosition < currentPosition) {
|
|
453
|
+
restSize = nextPosition - cameraPosition;
|
|
454
|
+
}
|
|
455
|
+
animationDuration *= restSize / size;
|
|
456
|
+
} else {
|
|
457
|
+
const size = currentPosition - prevPosition;
|
|
458
|
+
let restSize = cameraPosition - prevPosition;
|
|
459
|
+
if (cameraPosition > currentPosition) {
|
|
460
|
+
restSize = cameraPosition - prevPosition;
|
|
461
|
+
}
|
|
462
|
+
animationDuration *= restSize / size;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
if (direction === flicking.DIRECTION.NEXT) {
|
|
466
|
+
flicking$1.next(animationDuration).catch(() => void 0);
|
|
467
|
+
} else {
|
|
468
|
+
flicking$1.prev(animationDuration).catch(() => void 0);
|
|
469
|
+
}
|
|
470
|
+
this.play();
|
|
471
|
+
}, duration);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
class Fade {
|
|
475
|
+
/**
|
|
476
|
+
* @param selector - CSS selector for the element to apply the fade effect. If empty, the panel element itself is used
|
|
477
|
+
* @param scale - Effect amplification scale
|
|
478
|
+
* @example
|
|
479
|
+
* ```ts
|
|
480
|
+
* flicking.addPlugins(new Fade("p", 1));
|
|
481
|
+
* ```
|
|
482
|
+
*/
|
|
483
|
+
constructor(selector = "", scale = 1) {
|
|
484
|
+
this.update = () => {
|
|
485
|
+
this._onMove();
|
|
486
|
+
};
|
|
487
|
+
this._onMove = () => {
|
|
488
|
+
const flicking2 = this._flicking;
|
|
489
|
+
const selector2 = this._selector;
|
|
490
|
+
const scale2 = this._scale;
|
|
491
|
+
if (!flicking2) return;
|
|
492
|
+
const panels = flicking2.visiblePanels;
|
|
493
|
+
panels.forEach((panel) => {
|
|
494
|
+
const progress = panel.outsetProgress;
|
|
495
|
+
const el = panel.element;
|
|
496
|
+
const target = selector2 ? el.querySelector(selector2) : el;
|
|
497
|
+
if (target) {
|
|
498
|
+
const opacity = Math.min(1, Math.max(0, 1 - Math.abs(progress * scale2)));
|
|
499
|
+
target.style.opacity = `${opacity}`;
|
|
500
|
+
}
|
|
501
|
+
});
|
|
502
|
+
};
|
|
503
|
+
this._flicking = null;
|
|
504
|
+
this._selector = selector;
|
|
505
|
+
this._scale = scale;
|
|
506
|
+
}
|
|
507
|
+
/** CSS selector for the element to apply the fade effect. If empty, the panel element itself is used
|
|
508
|
+
* @readonly
|
|
509
|
+
*/
|
|
510
|
+
get selector() {
|
|
511
|
+
return this._selector;
|
|
512
|
+
}
|
|
513
|
+
/** Effect amplification scale
|
|
514
|
+
* @readonly
|
|
515
|
+
*/
|
|
516
|
+
get scale() {
|
|
517
|
+
return this._scale;
|
|
518
|
+
}
|
|
519
|
+
/** Sets the CSS selector for the target fade element. */
|
|
520
|
+
set selector(val) {
|
|
521
|
+
this._selector = val;
|
|
522
|
+
}
|
|
523
|
+
/** Sets the effect amplification scale. */
|
|
524
|
+
set scale(val) {
|
|
525
|
+
this._scale = val;
|
|
526
|
+
}
|
|
527
|
+
/** Initialize the plugin and apply the fade effect to the Flicking instance.
|
|
528
|
+
* @param flicking - The Flicking instance to attach this plugin to
|
|
529
|
+
*/
|
|
530
|
+
init(flicking$1) {
|
|
531
|
+
if (this._flicking) {
|
|
532
|
+
this.destroy();
|
|
533
|
+
}
|
|
534
|
+
this._flicking = flicking$1;
|
|
535
|
+
flicking$1.on(flicking.EVENTS.MOVE, this._onMove);
|
|
536
|
+
flicking$1.on(flicking.EVENTS.AFTER_RESIZE, this.update);
|
|
537
|
+
this._onMove();
|
|
538
|
+
}
|
|
539
|
+
/** Destroy the plugin and remove all event listeners. */
|
|
540
|
+
destroy() {
|
|
541
|
+
if (!this._flicking) return;
|
|
542
|
+
this._flicking.off(flicking.EVENTS.MOVE, this._onMove);
|
|
543
|
+
this._flicking.off(flicking.EVENTS.AFTER_RESIZE, this.update);
|
|
544
|
+
this._flicking = null;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
class Parallax {
|
|
548
|
+
/**
|
|
549
|
+
* @param selector - CSS selector for the element to apply the parallax effect. If empty, the panel element itself is used
|
|
550
|
+
* @param scale - Effect amplification scale
|
|
551
|
+
* @example
|
|
552
|
+
* ```ts
|
|
553
|
+
* flicking.addPlugins(new Parallax("img", 1));
|
|
554
|
+
* ```
|
|
555
|
+
*/
|
|
556
|
+
constructor(selector = "", scale = 1) {
|
|
557
|
+
this.update = () => {
|
|
558
|
+
this._onMove();
|
|
559
|
+
};
|
|
560
|
+
this._onMove = () => {
|
|
561
|
+
const flicking2 = this._flicking;
|
|
562
|
+
if (!flicking2) return;
|
|
563
|
+
const panels = flicking2.visiblePanels;
|
|
564
|
+
panels.forEach((panel) => {
|
|
565
|
+
const progress = panel.outsetProgress;
|
|
566
|
+
const el = panel.element;
|
|
567
|
+
const target = this._selector ? el.querySelector(this._selector) : el;
|
|
568
|
+
const parentTarget = target.parentNode;
|
|
569
|
+
const rect = target.getBoundingClientRect();
|
|
570
|
+
const parentRect = parentTarget.getBoundingClientRect();
|
|
571
|
+
const position = (parentRect.width - rect.width) / 2 * progress * this._scale;
|
|
572
|
+
const transform = `translate(-50%) translate(${position}px)`;
|
|
573
|
+
const style = target.style;
|
|
574
|
+
style.cssText += `transform: ${transform};-webkit-transform: ${transform};-ms-transform:${transform}`;
|
|
575
|
+
});
|
|
576
|
+
};
|
|
577
|
+
this._flicking = null;
|
|
578
|
+
this._selector = selector;
|
|
579
|
+
this._scale = scale;
|
|
580
|
+
}
|
|
581
|
+
/** CSS selector for the element to apply the parallax effect. If empty, the panel element itself is used
|
|
582
|
+
* @readonly
|
|
583
|
+
*/
|
|
584
|
+
get selector() {
|
|
585
|
+
return this._selector;
|
|
586
|
+
}
|
|
587
|
+
/** Effect amplification scale
|
|
588
|
+
* @readonly
|
|
589
|
+
*/
|
|
590
|
+
get scale() {
|
|
591
|
+
return this._scale;
|
|
592
|
+
}
|
|
593
|
+
/** Sets the CSS selector for the target parallax element. */
|
|
594
|
+
set selector(val) {
|
|
595
|
+
this._selector = val;
|
|
596
|
+
}
|
|
597
|
+
/** Sets the effect amplification scale. */
|
|
598
|
+
set scale(val) {
|
|
599
|
+
this._scale = val;
|
|
600
|
+
}
|
|
601
|
+
/** Initialize the plugin and apply the parallax effect to the Flicking instance.
|
|
602
|
+
* @param flicking - The Flicking instance to attach this plugin to
|
|
603
|
+
*/
|
|
604
|
+
init(flicking$1) {
|
|
605
|
+
if (this._flicking) {
|
|
606
|
+
this.destroy();
|
|
607
|
+
}
|
|
608
|
+
this._flicking = flicking$1;
|
|
609
|
+
flicking$1.on(flicking.EVENTS.MOVE, this._onMove);
|
|
610
|
+
flicking$1.on(flicking.EVENTS.AFTER_RESIZE, this.update);
|
|
611
|
+
this._onMove();
|
|
612
|
+
}
|
|
613
|
+
/** Destroy the plugin and remove all event listeners. */
|
|
614
|
+
destroy() {
|
|
615
|
+
if (!this._flicking) return;
|
|
616
|
+
this._flicking.off(flicking.EVENTS.MOVE, this._onMove);
|
|
617
|
+
this._flicking.off(flicking.EVENTS.AFTER_RESIZE, this.update);
|
|
618
|
+
this._flicking = null;
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
class Perspective {
|
|
622
|
+
/**
|
|
623
|
+
* @param options - Options for the Perspective instance
|
|
624
|
+
* @example
|
|
625
|
+
* ```ts
|
|
626
|
+
* flicking.addPlugins(new Perspective({ selector: "p", scale: 1, rotate: 1, perspective: 1000 }));
|
|
627
|
+
* ```
|
|
628
|
+
*/
|
|
629
|
+
constructor(options = {}) {
|
|
630
|
+
this.update = () => {
|
|
631
|
+
this._onMove();
|
|
632
|
+
};
|
|
633
|
+
this._onMove = () => {
|
|
634
|
+
const flicking2 = this._flicking;
|
|
635
|
+
const selector2 = this._selector;
|
|
636
|
+
const scale2 = this._scale;
|
|
637
|
+
const rotate2 = this._rotate;
|
|
638
|
+
const perspective2 = this._perspective;
|
|
639
|
+
if (!flicking2) return;
|
|
640
|
+
const horizontal = flicking2.horizontal;
|
|
641
|
+
const panels = flicking2.visiblePanels;
|
|
642
|
+
panels.forEach((panel) => {
|
|
643
|
+
const progress = panel.outsetProgress;
|
|
644
|
+
const el = panel.element;
|
|
645
|
+
const target = selector2 ? el.querySelector(selector2) : el;
|
|
646
|
+
const panelScale = 1 / (Math.abs(progress * scale2) + 1);
|
|
647
|
+
const rotateDegree = progress > 0 ? Math.min(90, progress * 100 * rotate2) : Math.max(-90, progress * 100 * rotate2);
|
|
648
|
+
const [rotateX, rotateY] = horizontal ? [0, rotateDegree] : [rotateDegree, 0];
|
|
649
|
+
target.style.transform = `perspective(${perspective2}px) rotateX(${rotateX}deg) rotateY(${rotateY}deg) scale(${panelScale})`;
|
|
650
|
+
});
|
|
651
|
+
};
|
|
652
|
+
const { selector = "", scale = 1, rotate = 1, perspective = 1e3 } = options;
|
|
880
653
|
this._flicking = null;
|
|
881
|
-
|
|
882
|
-
this.
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
654
|
+
this._selector = selector;
|
|
655
|
+
this._scale = scale;
|
|
656
|
+
this._rotate = rotate;
|
|
657
|
+
this._perspective = perspective;
|
|
658
|
+
}
|
|
659
|
+
/** Current value of the {@link PerspectiveOptions.selector | selector} option. */
|
|
660
|
+
get selector() {
|
|
661
|
+
return this._selector;
|
|
662
|
+
}
|
|
663
|
+
/** Current value of the {@link PerspectiveOptions.scale | scale} option. */
|
|
664
|
+
get scale() {
|
|
665
|
+
return this._scale;
|
|
666
|
+
}
|
|
667
|
+
/** Current value of the {@link PerspectiveOptions.rotate | rotate} option. */
|
|
668
|
+
get rotate() {
|
|
669
|
+
return this._rotate;
|
|
670
|
+
}
|
|
671
|
+
/** Current value of the {@link PerspectiveOptions.perspective | perspective} option. */
|
|
672
|
+
get perspective() {
|
|
673
|
+
return this._perspective;
|
|
674
|
+
}
|
|
675
|
+
/** Sets {@link PerspectiveOptions.selector | selector}. */
|
|
676
|
+
set selector(val) {
|
|
677
|
+
this._selector = val;
|
|
678
|
+
}
|
|
679
|
+
/** Sets {@link PerspectiveOptions.scale | scale}. */
|
|
680
|
+
set scale(val) {
|
|
681
|
+
this._scale = val;
|
|
682
|
+
}
|
|
683
|
+
/** Sets {@link PerspectiveOptions.rotate | rotate}. */
|
|
684
|
+
set rotate(val) {
|
|
685
|
+
this._rotate = val;
|
|
686
|
+
}
|
|
687
|
+
/** Sets {@link PerspectiveOptions.perspective | perspective}. */
|
|
688
|
+
set perspective(val) {
|
|
689
|
+
this._perspective = val;
|
|
690
|
+
}
|
|
691
|
+
/** Initialize the plugin and apply the perspective effect to the Flicking instance.
|
|
692
|
+
* @param flicking - The Flicking instance to attach this plugin to
|
|
693
|
+
*/
|
|
694
|
+
init(flicking$1) {
|
|
695
|
+
if (this._flicking) {
|
|
696
|
+
this.destroy();
|
|
697
|
+
}
|
|
698
|
+
this._flicking = flicking$1;
|
|
699
|
+
flicking$1.on(flicking.EVENTS.MOVE, this._onMove);
|
|
700
|
+
flicking$1.on(flicking.EVENTS.AFTER_RESIZE, this.update);
|
|
701
|
+
this._onMove();
|
|
702
|
+
}
|
|
703
|
+
/** Destroy the plugin and remove all event listeners. */
|
|
704
|
+
destroy() {
|
|
705
|
+
if (!this._flicking) return;
|
|
706
|
+
this._flicking.off(flicking.EVENTS.MOVE, this._onMove);
|
|
707
|
+
this._flicking.off(flicking.EVENTS.AFTER_RESIZE, this.update);
|
|
708
|
+
this._flicking = null;
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
class Sync {
|
|
712
|
+
/**
|
|
713
|
+
* @param options - Options for the Sync instance
|
|
714
|
+
* @example
|
|
715
|
+
* ```ts
|
|
716
|
+
* flicking.addPlugins(new Sync({
|
|
717
|
+
* type: "camera",
|
|
718
|
+
* synchronizedFlickingOptions: [
|
|
719
|
+
* { flicking: flicking1 },
|
|
720
|
+
* { flicking: flicking2, isClickable: true }
|
|
721
|
+
* ]
|
|
722
|
+
* }));
|
|
723
|
+
* ```
|
|
724
|
+
*/
|
|
725
|
+
constructor(options = {}) {
|
|
726
|
+
this._flicking = null;
|
|
727
|
+
this._disabledIndex = [];
|
|
728
|
+
this._addEvents = () => {
|
|
729
|
+
const type2 = this._type;
|
|
730
|
+
const synced = this._synchronizedFlickingOptions;
|
|
731
|
+
synced.forEach(({ flicking: flicking$1, isSlidable, isClickable }) => {
|
|
732
|
+
if (type2 === SYNC.TYPE.CAMERA) {
|
|
733
|
+
flicking$1.on(flicking.EVENTS.MOVE, this._onMove);
|
|
734
|
+
flicking$1.on(flicking.EVENTS.MOVE_START, this._onMoveStart);
|
|
735
|
+
flicking$1.on(flicking.EVENTS.MOVE_END, this._onMoveEnd);
|
|
894
736
|
}
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
flicking$1.on(flicking.EVENTS.
|
|
898
|
-
flicking$1.on(flicking.EVENTS.WILL_RESTORE, _this._onIndexChange);
|
|
737
|
+
if (type2 === SYNC.TYPE.INDEX && isSlidable) {
|
|
738
|
+
flicking$1.on(flicking.EVENTS.WILL_CHANGE, this._onIndexChange);
|
|
739
|
+
flicking$1.on(flicking.EVENTS.WILL_RESTORE, this._onIndexChange);
|
|
899
740
|
}
|
|
900
|
-
|
|
901
741
|
if (isClickable) {
|
|
902
|
-
flicking$1.on(flicking.EVENTS.SELECT,
|
|
742
|
+
flicking$1.on(flicking.EVENTS.SELECT, this._onSelect);
|
|
903
743
|
}
|
|
904
744
|
});
|
|
905
745
|
};
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
if (type === SYNC.TYPE.CAMERA) {
|
|
916
|
-
flicking$1.off(flicking.EVENTS.MOVE, _this._onMove);
|
|
917
|
-
flicking$1.off(flicking.EVENTS.MOVE_START, _this._onMoveStart);
|
|
918
|
-
flicking$1.off(flicking.EVENTS.MOVE_END, _this._onMoveEnd);
|
|
746
|
+
this._removeEvents = () => {
|
|
747
|
+
const type2 = this._type;
|
|
748
|
+
const synced = this._synchronizedFlickingOptions;
|
|
749
|
+
synced.forEach(({ flicking: flicking$1, isSlidable, isClickable }) => {
|
|
750
|
+
if (type2 === SYNC.TYPE.CAMERA) {
|
|
751
|
+
flicking$1.off(flicking.EVENTS.MOVE, this._onMove);
|
|
752
|
+
flicking$1.off(flicking.EVENTS.MOVE_START, this._onMoveStart);
|
|
753
|
+
flicking$1.off(flicking.EVENTS.MOVE_END, this._onMoveEnd);
|
|
919
754
|
}
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
flicking$1.off(flicking.EVENTS.
|
|
923
|
-
flicking$1.off(flicking.EVENTS.WILL_RESTORE, _this._onIndexChange);
|
|
755
|
+
if (type2 === SYNC.TYPE.INDEX && isSlidable) {
|
|
756
|
+
flicking$1.off(flicking.EVENTS.WILL_CHANGE, this._onIndexChange);
|
|
757
|
+
flicking$1.off(flicking.EVENTS.WILL_RESTORE, this._onIndexChange);
|
|
924
758
|
}
|
|
925
|
-
|
|
926
759
|
if (isClickable) {
|
|
927
|
-
flicking$1.off(flicking.EVENTS.SELECT,
|
|
760
|
+
flicking$1.off(flicking.EVENTS.SELECT, this._onSelect);
|
|
928
761
|
}
|
|
929
762
|
});
|
|
930
763
|
};
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
if (!flicking.initialized) {
|
|
764
|
+
this._onIndexChange = (e) => {
|
|
765
|
+
const flicking2 = e.currentTarget;
|
|
766
|
+
if (!flicking2.initialized) {
|
|
936
767
|
return;
|
|
937
768
|
}
|
|
938
|
-
|
|
939
|
-
_this._synchronizeByIndex(flicking, e.index);
|
|
769
|
+
this._synchronizeByIndex(flicking2, e.index);
|
|
940
770
|
};
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
var flicking = _a.flicking;
|
|
948
|
-
if (flicking === e.currentTarget) return;
|
|
949
|
-
var targetPosition = 0;
|
|
950
|
-
|
|
771
|
+
this._onMove = (e) => {
|
|
772
|
+
const camera = e.currentTarget.camera;
|
|
773
|
+
const progress = (camera.position - camera.range.min) / camera.rangeDiff;
|
|
774
|
+
this._synchronizedFlickingOptions.forEach(({ flicking: flicking2 }) => {
|
|
775
|
+
if (flicking2 === e.currentTarget) return;
|
|
776
|
+
let targetPosition = 0;
|
|
951
777
|
if (camera.position < camera.range.min) {
|
|
952
778
|
targetPosition = camera.position;
|
|
953
779
|
} else if (camera.position > camera.range.max) {
|
|
954
|
-
targetPosition =
|
|
780
|
+
targetPosition = flicking2.camera.range.max + camera.position - camera.range.max;
|
|
955
781
|
} else {
|
|
956
|
-
targetPosition =
|
|
782
|
+
targetPosition = flicking2.camera.range.min + flicking2.camera.rangeDiff * progress;
|
|
957
783
|
}
|
|
958
|
-
|
|
959
|
-
void flicking.camera.lookAt(targetPosition);
|
|
784
|
+
void flicking2.camera.lookAt(targetPosition);
|
|
960
785
|
});
|
|
961
786
|
};
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
flicking.disableInput();
|
|
787
|
+
this._onMoveStart = (e) => {
|
|
788
|
+
this._disabledIndex = [];
|
|
789
|
+
this._synchronizedFlickingOptions.forEach(({ flicking: flicking2 }, i) => {
|
|
790
|
+
if (flicking2 !== e.currentTarget && flicking2.control.controller.enabled) {
|
|
791
|
+
this._disabledIndex.push(i);
|
|
792
|
+
flicking2.disableInput();
|
|
969
793
|
}
|
|
970
794
|
});
|
|
971
795
|
};
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
if (flicking !== e.currentTarget) {
|
|
978
|
-
flicking.enableInput();
|
|
979
|
-
flicking.control.updateInput();
|
|
980
|
-
}
|
|
796
|
+
this._onMoveEnd = (e) => {
|
|
797
|
+
this._disabledIndex.forEach((i) => {
|
|
798
|
+
const flicking2 = this._synchronizedFlickingOptions[i].flicking;
|
|
799
|
+
flicking2.enableInput();
|
|
800
|
+
flicking2.control.updateInput();
|
|
981
801
|
});
|
|
982
802
|
};
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
return void 0;
|
|
987
|
-
});
|
|
988
|
-
|
|
989
|
-
_this._synchronizeByIndex(e.currentTarget, e.index);
|
|
803
|
+
this._onSelect = (e) => {
|
|
804
|
+
void e.currentTarget.moveTo(e.index).catch(() => void 0);
|
|
805
|
+
this._synchronizeByIndex(e.currentTarget, e.index);
|
|
990
806
|
};
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
// Active class should be applied same to the Flicking which triggered event
|
|
998
|
-
_this._updateClass(options, index);
|
|
999
|
-
|
|
1000
|
-
var flicking$1 = options.flicking;
|
|
807
|
+
this._synchronizeByIndex = (activeFlicking, index) => {
|
|
808
|
+
const synchronizedFlickingOptions2 = this._synchronizedFlickingOptions;
|
|
809
|
+
this._preventEvent(() => {
|
|
810
|
+
synchronizedFlickingOptions2.forEach((options2) => {
|
|
811
|
+
this._updateClass(options2, index);
|
|
812
|
+
const { flicking: flicking$1 } = options2;
|
|
1001
813
|
if (flicking$1 === activeFlicking) return;
|
|
1002
|
-
|
|
1003
|
-
|
|
814
|
+
const targetIndex = flicking.clamp(index, 0, flicking$1.panels.length);
|
|
1004
815
|
if (flicking$1.animating) {
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
void flicking$1.moveTo(targetIndex).catch(function () {
|
|
1008
|
-
return void 0;
|
|
1009
|
-
});
|
|
816
|
+
flicking$1.once(flicking.EVENTS.MOVE_END, () => {
|
|
817
|
+
void flicking$1.moveTo(targetIndex).catch(() => void 0);
|
|
1010
818
|
});
|
|
1011
819
|
} else {
|
|
1012
820
|
void flicking$1.moveTo(targetIndex);
|
|
@@ -1014,12 +822,9 @@ version: 4.8.0-beta.1
|
|
|
1014
822
|
});
|
|
1015
823
|
});
|
|
1016
824
|
};
|
|
1017
|
-
|
|
1018
|
-
this._updateClass = function (_a, index) {
|
|
1019
|
-
var flicking = _a.flicking,
|
|
1020
|
-
activeClass = _a.activeClass;
|
|
825
|
+
this._updateClass = ({ flicking: flicking2, activeClass }, index) => {
|
|
1021
826
|
if (!activeClass) return;
|
|
1022
|
-
|
|
827
|
+
flicking2.panels.forEach((panel) => {
|
|
1023
828
|
if (panel.index === index) {
|
|
1024
829
|
addClass(panel.element, activeClass);
|
|
1025
830
|
} else {
|
|
@@ -1027,617 +832,318 @@ version: 4.8.0-beta.1
|
|
|
1027
832
|
}
|
|
1028
833
|
});
|
|
1029
834
|
};
|
|
1030
|
-
|
|
835
|
+
const { type = SYNC.TYPE.CAMERA, synchronizedFlickingOptions = [] } = options;
|
|
1031
836
|
this._type = type;
|
|
1032
837
|
this._synchronizedFlickingOptions = synchronizedFlickingOptions;
|
|
1033
838
|
}
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
}
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
});
|
|
1056
|
-
|
|
1057
|
-
__proto.init = function (flicking) {
|
|
1058
|
-
var _this = this;
|
|
1059
|
-
|
|
1060
|
-
var synced = this._synchronizedFlickingOptions;
|
|
1061
|
-
|
|
839
|
+
/** Current value of the {@link SyncOptions.type | type} option. */
|
|
840
|
+
get type() {
|
|
841
|
+
return this._type;
|
|
842
|
+
}
|
|
843
|
+
/** Current value of the {@link SyncOptions.synchronizedFlickingOptions | synchronizedFlickingOptions} option. */
|
|
844
|
+
get synchronizedFlickingOptions() {
|
|
845
|
+
return this._synchronizedFlickingOptions;
|
|
846
|
+
}
|
|
847
|
+
/** Sets {@link SyncOptions.type | type}. */
|
|
848
|
+
set type(val) {
|
|
849
|
+
this._type = val;
|
|
850
|
+
}
|
|
851
|
+
/** Sets {@link SyncOptions.synchronizedFlickingOptions | synchronizedFlickingOptions}. */
|
|
852
|
+
set synchronizedFlickingOptions(val) {
|
|
853
|
+
this._synchronizedFlickingOptions = val;
|
|
854
|
+
}
|
|
855
|
+
/** Initialize the plugin and set up synchronization event listeners between Flicking instances.
|
|
856
|
+
* @param flicking - The Flicking instance to attach this plugin to
|
|
857
|
+
*/
|
|
858
|
+
init(flicking2) {
|
|
859
|
+
const synced = this._synchronizedFlickingOptions;
|
|
1062
860
|
if (this._flicking) {
|
|
1063
861
|
this.destroy();
|
|
1064
862
|
}
|
|
1065
|
-
|
|
1066
|
-
this._flicking = flicking;
|
|
1067
|
-
|
|
863
|
+
this._flicking = flicking2;
|
|
1068
864
|
this._addEvents();
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
_this._updateClass(options, syncedFlicking.defaultIndex);
|
|
865
|
+
synced.forEach((options) => {
|
|
866
|
+
const { flicking: syncedFlicking } = options;
|
|
867
|
+
this._updateClass(options, syncedFlicking.defaultIndex);
|
|
1074
868
|
});
|
|
1075
|
-
}
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
if (!flicking) {
|
|
869
|
+
}
|
|
870
|
+
/** Destroy the plugin and remove all synchronization event listeners. */
|
|
871
|
+
destroy() {
|
|
872
|
+
const flicking2 = this._flicking;
|
|
873
|
+
if (!flicking2) {
|
|
1081
874
|
return;
|
|
1082
875
|
}
|
|
1083
|
-
|
|
1084
876
|
this._removeEvents();
|
|
1085
|
-
|
|
1086
877
|
this._flicking = null;
|
|
1087
|
-
}
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
this._synchronizedFlickingOptions.forEach(function (options) {
|
|
1093
|
-
_this._updateClass(options, options.flicking.index);
|
|
878
|
+
}
|
|
879
|
+
/** Update the active class state for all synchronized Flicking instances. */
|
|
880
|
+
update() {
|
|
881
|
+
this._synchronizedFlickingOptions.forEach((options) => {
|
|
882
|
+
this._updateClass(options, options.flicking.index);
|
|
1094
883
|
});
|
|
1095
|
-
}
|
|
1096
|
-
|
|
1097
|
-
__proto._preventEvent = function (fn) {
|
|
884
|
+
}
|
|
885
|
+
_preventEvent(fn) {
|
|
1098
886
|
this._removeEvents();
|
|
1099
|
-
|
|
1100
887
|
fn();
|
|
1101
|
-
|
|
1102
888
|
this._addEvents();
|
|
1103
|
-
};
|
|
1104
|
-
|
|
1105
|
-
return Sync;
|
|
1106
|
-
}();
|
|
1107
|
-
|
|
1108
|
-
/* eslint-disable no-underscore-dangle */
|
|
1109
|
-
/**
|
|
1110
|
-
* You can apply perspective effect while panel is moving.
|
|
1111
|
-
* @ko 패널들을 움직이면서 입체감을 부여할 수 있습니다.
|
|
1112
|
-
* @memberof Flicking.Plugins
|
|
1113
|
-
*/
|
|
1114
|
-
|
|
1115
|
-
var Perspective =
|
|
1116
|
-
/*#__PURE__*/
|
|
1117
|
-
function () {
|
|
1118
|
-
/**
|
|
1119
|
-
* @param - The selector of the element to which the perspective effect is to be applied. If the selector is blank, it applies to panel element. <ko>입체 효과를 적용할 대상의 선택자. 선택자가 공백이면 패널 엘리먼트에 적용된다.</ko>
|
|
1120
|
-
* @param - Effect amplication scale.<ko>효과 증폭도</ko>
|
|
1121
|
-
* @param - Effect amplication rotate.<ko>회전 증폭도</ko>
|
|
1122
|
-
* @param - The value of perspective CSS property. <ko>css perspective 속성 값</ko>
|
|
1123
|
-
* @example
|
|
1124
|
-
* ```ts
|
|
1125
|
-
* flicking.addPlugins(new Perspective({ selector: "p", scale: 1, rotate: 1, perspective = 1000 }));
|
|
1126
|
-
* ```
|
|
1127
|
-
*/
|
|
1128
|
-
function Perspective(_a) {
|
|
1129
|
-
var _this = this;
|
|
1130
|
-
|
|
1131
|
-
var _b = _a === void 0 ? {} : _a,
|
|
1132
|
-
_c = _b.selector,
|
|
1133
|
-
selector = _c === void 0 ? "" : _c,
|
|
1134
|
-
_d = _b.scale,
|
|
1135
|
-
scale = _d === void 0 ? 1 : _d,
|
|
1136
|
-
_e = _b.rotate,
|
|
1137
|
-
rotate = _e === void 0 ? 1 : _e,
|
|
1138
|
-
_f = _b.perspective,
|
|
1139
|
-
perspective = _f === void 0 ? 1000 : _f;
|
|
1140
|
-
|
|
1141
|
-
this.update = function () {
|
|
1142
|
-
_this._onMove();
|
|
1143
|
-
};
|
|
1144
|
-
|
|
1145
|
-
this._onMove = function () {
|
|
1146
|
-
var flicking = _this._flicking;
|
|
1147
|
-
var selector = _this._selector;
|
|
1148
|
-
var scale = _this._scale;
|
|
1149
|
-
var rotate = _this._rotate;
|
|
1150
|
-
var perspective = _this._perspective;
|
|
1151
|
-
if (!flicking) return;
|
|
1152
|
-
var horizontal = flicking.horizontal;
|
|
1153
|
-
var panels = flicking.visiblePanels;
|
|
1154
|
-
panels.forEach(function (panel) {
|
|
1155
|
-
var progress = panel.outsetProgress;
|
|
1156
|
-
var el = panel.element;
|
|
1157
|
-
var target = selector ? el.querySelector(selector) : el;
|
|
1158
|
-
var panelScale = 1 / (Math.abs(progress * scale) + 1);
|
|
1159
|
-
var rotateDegree = progress > 0 ? Math.min(90, progress * 100 * rotate) : Math.max(-90, progress * 100 * rotate);
|
|
1160
|
-
|
|
1161
|
-
var _a = horizontal ? [0, rotateDegree] : [rotateDegree, 0],
|
|
1162
|
-
rotateX = _a[0],
|
|
1163
|
-
rotateY = _a[1];
|
|
1164
|
-
|
|
1165
|
-
target.style.transform = "perspective(" + perspective + "px) rotateX(" + rotateX + "deg) rotateY(" + rotateY + "deg) scale(" + panelScale + ")";
|
|
1166
|
-
});
|
|
1167
|
-
};
|
|
1168
|
-
|
|
1169
|
-
this._flicking = null;
|
|
1170
|
-
this._selector = selector;
|
|
1171
|
-
this._scale = scale;
|
|
1172
|
-
this._rotate = rotate;
|
|
1173
|
-
this._perspective = perspective;
|
|
1174
889
|
}
|
|
1175
|
-
|
|
1176
|
-
var __proto = Perspective.prototype;
|
|
1177
|
-
Object.defineProperty(__proto, "selector", {
|
|
1178
|
-
get: function () {
|
|
1179
|
-
return this._selector;
|
|
1180
|
-
},
|
|
1181
|
-
set: function (val) {
|
|
1182
|
-
this._selector = val;
|
|
1183
|
-
},
|
|
1184
|
-
enumerable: false,
|
|
1185
|
-
configurable: true
|
|
1186
|
-
});
|
|
1187
|
-
Object.defineProperty(__proto, "scale", {
|
|
1188
|
-
get: function () {
|
|
1189
|
-
return this._scale;
|
|
1190
|
-
},
|
|
1191
|
-
set: function (val) {
|
|
1192
|
-
this._scale = val;
|
|
1193
|
-
},
|
|
1194
|
-
enumerable: false,
|
|
1195
|
-
configurable: true
|
|
1196
|
-
});
|
|
1197
|
-
Object.defineProperty(__proto, "rotate", {
|
|
1198
|
-
get: function () {
|
|
1199
|
-
return this._rotate;
|
|
1200
|
-
},
|
|
1201
|
-
set: function (val) {
|
|
1202
|
-
this._rotate = val;
|
|
1203
|
-
},
|
|
1204
|
-
enumerable: false,
|
|
1205
|
-
configurable: true
|
|
1206
|
-
});
|
|
1207
|
-
Object.defineProperty(__proto, "perspective", {
|
|
1208
|
-
get: function () {
|
|
1209
|
-
return this._perspective;
|
|
1210
|
-
},
|
|
1211
|
-
set: function (val) {
|
|
1212
|
-
this._perspective = val;
|
|
1213
|
-
},
|
|
1214
|
-
enumerable: false,
|
|
1215
|
-
configurable: true
|
|
1216
|
-
});
|
|
1217
|
-
|
|
1218
|
-
__proto.init = function (flicking$1) {
|
|
1219
|
-
if (this._flicking) {
|
|
1220
|
-
this.destroy();
|
|
1221
|
-
}
|
|
1222
|
-
|
|
1223
|
-
this._flicking = flicking$1;
|
|
1224
|
-
flicking$1.on(flicking.EVENTS.MOVE, this._onMove);
|
|
1225
|
-
flicking$1.on(flicking.EVENTS.AFTER_RESIZE, this.update);
|
|
1226
|
-
|
|
1227
|
-
this._onMove();
|
|
1228
|
-
};
|
|
1229
|
-
|
|
1230
|
-
__proto.destroy = function () {
|
|
1231
|
-
if (!this._flicking) return;
|
|
1232
|
-
|
|
1233
|
-
this._flicking.off(flicking.EVENTS.MOVE, this._onMove);
|
|
1234
|
-
|
|
1235
|
-
this._flicking.off(flicking.EVENTS.AFTER_RESIZE, this.update);
|
|
1236
|
-
|
|
1237
|
-
this._flicking = null;
|
|
1238
|
-
};
|
|
1239
|
-
|
|
1240
|
-
return Perspective;
|
|
1241
|
-
}();
|
|
1242
|
-
|
|
1243
|
-
/*! *****************************************************************************
|
|
1244
|
-
Copyright (c) Microsoft Corporation.
|
|
1245
|
-
|
|
1246
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
1247
|
-
purpose with or without fee is hereby granted.
|
|
1248
|
-
|
|
1249
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
1250
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
1251
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
1252
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
1253
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
1254
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
1255
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
1256
|
-
***************************************************************************** */
|
|
1257
|
-
|
|
1258
|
-
/* global Reflect, Promise */
|
|
1259
|
-
var extendStatics = function (d, b) {
|
|
1260
|
-
extendStatics = Object.setPrototypeOf || {
|
|
1261
|
-
__proto__: []
|
|
1262
|
-
} instanceof Array && function (d, b) {
|
|
1263
|
-
d.__proto__ = b;
|
|
1264
|
-
} || function (d, b) {
|
|
1265
|
-
for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
|
1266
|
-
};
|
|
1267
|
-
|
|
1268
|
-
return extendStatics(d, b);
|
|
1269
|
-
};
|
|
1270
|
-
|
|
1271
|
-
function __extends(d, b) {
|
|
1272
|
-
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
1273
|
-
extendStatics(d, b);
|
|
1274
|
-
|
|
1275
|
-
function __() {
|
|
1276
|
-
this.constructor = d;
|
|
1277
|
-
}
|
|
1278
|
-
|
|
1279
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1280
890
|
}
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
ar[i] = from[i];
|
|
1286
|
-
}
|
|
1287
|
-
}
|
|
1288
|
-
return to.concat(ar || from);
|
|
1289
|
-
}
|
|
1290
|
-
|
|
1291
|
-
var Renderer =
|
|
1292
|
-
/*#__PURE__*/
|
|
1293
|
-
function () {
|
|
1294
|
-
function Renderer(_a) {
|
|
1295
|
-
var flicking = _a.flicking,
|
|
1296
|
-
pagination = _a.pagination,
|
|
1297
|
-
wrapper = _a.wrapper;
|
|
1298
|
-
this._flicking = flicking;
|
|
891
|
+
class Renderer {
|
|
892
|
+
constructor(options) {
|
|
893
|
+
const { flicking: flicking2, pagination, wrapper } = options;
|
|
894
|
+
this._flicking = flicking2;
|
|
1299
895
|
this._pagination = pagination;
|
|
1300
896
|
this._wrapper = wrapper;
|
|
1301
897
|
}
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
var range = document.createRange();
|
|
1307
|
-
var frag = range.createContextualFragment(html);
|
|
1308
|
-
var bullet = frag.firstChild;
|
|
1309
|
-
|
|
898
|
+
_createBulletFromString(html, index) {
|
|
899
|
+
const range = document.createRange();
|
|
900
|
+
const frag = range.createContextualFragment(html);
|
|
901
|
+
const bullet = frag.firstChild;
|
|
1310
902
|
this._addBulletEvents(bullet, index);
|
|
1311
|
-
|
|
1312
903
|
return bullet;
|
|
1313
|
-
}
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
var anchorPoints = this._flicking.camera.anchorPoints;
|
|
1319
|
-
var panelIndex = anchorPoints[index].panel.index;
|
|
1320
|
-
bullet.addEventListener(BROWSER.MOUSE_DOWN, function (e) {
|
|
1321
|
-
e.stopPropagation();
|
|
1322
|
-
});
|
|
1323
|
-
bullet.addEventListener(BROWSER.TOUCH_START, function (e) {
|
|
904
|
+
}
|
|
905
|
+
_addBulletEvents(bullet, index) {
|
|
906
|
+
const anchorPoints = this._flicking.camera.anchorPoints;
|
|
907
|
+
const panelIndex = anchorPoints[index].panel.index;
|
|
908
|
+
bullet.addEventListener(BROWSER.MOUSE_DOWN, (e) => {
|
|
1324
909
|
e.stopPropagation();
|
|
1325
|
-
}, {
|
|
1326
|
-
passive: true
|
|
1327
910
|
});
|
|
1328
|
-
bullet.addEventListener(
|
|
1329
|
-
|
|
911
|
+
bullet.addEventListener(
|
|
912
|
+
BROWSER.TOUCH_START,
|
|
913
|
+
(e) => {
|
|
914
|
+
e.stopPropagation();
|
|
915
|
+
},
|
|
916
|
+
{ passive: true }
|
|
917
|
+
);
|
|
918
|
+
bullet.addEventListener(BROWSER.CLICK, () => {
|
|
919
|
+
this._flicking.moveTo(panelIndex).catch((err) => {
|
|
1330
920
|
if (err instanceof flicking.FlickingError) return;
|
|
1331
921
|
throw err;
|
|
1332
922
|
});
|
|
1333
923
|
});
|
|
1334
|
-
}
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
var BulletRenderer =
|
|
1340
|
-
/*#__PURE__*/
|
|
1341
|
-
function (_super) {
|
|
1342
|
-
__extends(BulletRenderer, _super);
|
|
1343
|
-
|
|
1344
|
-
function BulletRenderer() {
|
|
1345
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
1346
|
-
|
|
1347
|
-
_this._bullets = [];
|
|
1348
|
-
_this._prevIndex = -1;
|
|
1349
|
-
return _this;
|
|
1350
|
-
}
|
|
1351
|
-
|
|
1352
|
-
var __proto = BulletRenderer.prototype;
|
|
1353
|
-
Object.defineProperty(__proto, "_bulletClass", {
|
|
1354
|
-
get: function () {
|
|
1355
|
-
var pagination = this._pagination;
|
|
1356
|
-
return pagination.classPrefix + "-" + PAGINATION.BULLET_SUFFIX;
|
|
1357
|
-
},
|
|
1358
|
-
enumerable: false,
|
|
1359
|
-
configurable: true
|
|
1360
|
-
});
|
|
1361
|
-
Object.defineProperty(__proto, "_activeClass", {
|
|
1362
|
-
get: function () {
|
|
1363
|
-
var pagination = this._pagination;
|
|
1364
|
-
return pagination.classPrefix + "-" + PAGINATION.BULLET_ACTIVE_SUFFIX;
|
|
1365
|
-
},
|
|
1366
|
-
enumerable: false,
|
|
1367
|
-
configurable: true
|
|
1368
|
-
});
|
|
1369
|
-
|
|
1370
|
-
__proto.destroy = function () {
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
class BulletRenderer extends Renderer {
|
|
927
|
+
constructor() {
|
|
928
|
+
super(...arguments);
|
|
1371
929
|
this._bullets = [];
|
|
1372
930
|
this._prevIndex = -1;
|
|
1373
|
-
}
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
931
|
+
}
|
|
932
|
+
get _bulletClass() {
|
|
933
|
+
const pagination = this._pagination;
|
|
934
|
+
return `${pagination.classPrefix}-${PAGINATION.BULLET_SUFFIX}`;
|
|
935
|
+
}
|
|
936
|
+
get _activeClass() {
|
|
937
|
+
const pagination = this._pagination;
|
|
938
|
+
return `${pagination.classPrefix}-${PAGINATION.BULLET_ACTIVE_SUFFIX}`;
|
|
939
|
+
}
|
|
940
|
+
destroy() {
|
|
941
|
+
this._bullets = [];
|
|
942
|
+
this._prevIndex = -1;
|
|
943
|
+
}
|
|
944
|
+
render() {
|
|
945
|
+
const flicking2 = this._flicking;
|
|
946
|
+
const pagination = this._pagination;
|
|
947
|
+
const wrapper = this._wrapper;
|
|
948
|
+
const bulletClass = this._bulletClass;
|
|
949
|
+
const activeClass = this._activeClass;
|
|
950
|
+
const renderBullet = pagination.renderBullet;
|
|
951
|
+
const renderActiveBullet = pagination.renderActiveBullet;
|
|
952
|
+
const bulletWrapperClass = `${pagination.classPrefix}-${PAGINATION.BULLET_WRAPPER_SUFFIX}`;
|
|
953
|
+
const anchorPoints = flicking2.camera.anchorPoints;
|
|
1387
954
|
addClass(wrapper, bulletWrapperClass);
|
|
1388
|
-
wrapper.innerHTML = anchorPoints.map(
|
|
1389
|
-
if (renderActiveBullet && anchorPoint.panel.index ===
|
|
955
|
+
wrapper.innerHTML = anchorPoints.map((anchorPoint, index) => {
|
|
956
|
+
if (renderActiveBullet && anchorPoint.panel.index === flicking2.index) {
|
|
1390
957
|
return renderActiveBullet(bulletClass, index);
|
|
1391
958
|
} else {
|
|
1392
959
|
return renderBullet(bulletClass, index);
|
|
1393
960
|
}
|
|
1394
961
|
}).join("\n");
|
|
1395
|
-
|
|
1396
|
-
bullets.forEach(
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
if (anchorPoint.panel.index === flicking.index) {
|
|
962
|
+
const bullets = [].slice.call(wrapper.children);
|
|
963
|
+
bullets.forEach((bullet, index) => {
|
|
964
|
+
const anchorPoint = anchorPoints[index];
|
|
965
|
+
if (anchorPoint.panel.index === flicking2.index) {
|
|
1400
966
|
addClass(bullet, activeClass);
|
|
1401
|
-
|
|
967
|
+
this._prevIndex = index;
|
|
1402
968
|
}
|
|
1403
|
-
|
|
1404
|
-
_this._addBulletEvents(bullet, index);
|
|
969
|
+
this._addBulletEvents(bullet, index);
|
|
1405
970
|
});
|
|
1406
971
|
this._bullets = bullets;
|
|
1407
|
-
}
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
var renderActiveBullet = pagination.renderActiveBullet;
|
|
972
|
+
}
|
|
973
|
+
update(index) {
|
|
974
|
+
const flicking2 = this._flicking;
|
|
975
|
+
const pagination = this._pagination;
|
|
976
|
+
const wrapper = this._wrapper;
|
|
977
|
+
const bullets = this._bullets;
|
|
978
|
+
const bulletClass = this._bulletClass;
|
|
979
|
+
const activeClass = this._activeClass;
|
|
980
|
+
const prevIndex = this._prevIndex;
|
|
981
|
+
const anchorPoints = flicking2.camera.anchorPoints;
|
|
982
|
+
const renderBullet = pagination.renderBullet;
|
|
983
|
+
const renderActiveBullet = pagination.renderActiveBullet;
|
|
1420
984
|
if (anchorPoints.length <= 0) return;
|
|
1421
|
-
|
|
1422
|
-
|
|
985
|
+
const anchorOffset = anchorPoints[0].panel.index;
|
|
986
|
+
const activeBulletIndex = index - anchorOffset;
|
|
1423
987
|
if (prevIndex === activeBulletIndex) return;
|
|
1424
|
-
|
|
1425
988
|
if (renderActiveBullet) {
|
|
1426
|
-
|
|
1427
|
-
|
|
989
|
+
const prevBullet = bullets[prevIndex];
|
|
1428
990
|
if (prevBullet) {
|
|
1429
|
-
|
|
1430
|
-
|
|
991
|
+
const newBullet = this._createBulletFromString(renderBullet(bulletClass, prevIndex), prevIndex);
|
|
1431
992
|
prevBullet.parentElement.replaceChild(newBullet, prevBullet);
|
|
1432
993
|
bullets[prevIndex] = newBullet;
|
|
1433
994
|
}
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
995
|
+
const activeBullet = bullets[activeBulletIndex];
|
|
996
|
+
const newActiveBullet = this._createBulletFromString(
|
|
997
|
+
renderActiveBullet(`${bulletClass} ${activeClass}`, activeBulletIndex),
|
|
998
|
+
activeBulletIndex
|
|
999
|
+
);
|
|
1439
1000
|
wrapper.replaceChild(newActiveBullet, activeBullet);
|
|
1440
1001
|
bullets[activeBulletIndex] = newActiveBullet;
|
|
1441
1002
|
} else {
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1003
|
+
const activeBullet = bullets[activeBulletIndex];
|
|
1004
|
+
const prevBullet = bullets[prevIndex];
|
|
1445
1005
|
if (prevBullet) {
|
|
1446
1006
|
removeClass(prevBullet, activeClass);
|
|
1447
1007
|
}
|
|
1448
|
-
|
|
1449
1008
|
addClass(activeBullet, activeClass);
|
|
1450
1009
|
}
|
|
1451
|
-
|
|
1452
1010
|
this._prevIndex = activeBulletIndex;
|
|
1453
|
-
}
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
function FractionRenderer() {
|
|
1464
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
1465
|
-
|
|
1466
|
-
_this._prevIndex = -1;
|
|
1467
|
-
_this._prevTotal = -1;
|
|
1468
|
-
return _this;
|
|
1469
|
-
}
|
|
1470
|
-
|
|
1471
|
-
var __proto = FractionRenderer.prototype;
|
|
1472
|
-
|
|
1473
|
-
__proto.destroy = function () {
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
class FractionRenderer extends Renderer {
|
|
1014
|
+
constructor() {
|
|
1015
|
+
super(...arguments);
|
|
1016
|
+
this._prevIndex = -1;
|
|
1017
|
+
this._prevTotal = -1;
|
|
1018
|
+
}
|
|
1019
|
+
destroy() {
|
|
1474
1020
|
this._prevIndex = -1;
|
|
1475
1021
|
this._prevTotal = -1;
|
|
1476
|
-
}
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
var fractionTotalClass = pagination.classPrefix + "-" + PAGINATION.FRACTION_TOTAL_SUFFIX;
|
|
1022
|
+
}
|
|
1023
|
+
render() {
|
|
1024
|
+
const flicking2 = this._flicking;
|
|
1025
|
+
const wrapper = this._wrapper;
|
|
1026
|
+
const pagination = this._pagination;
|
|
1027
|
+
const fractionWrapperClass = `${pagination.classPrefix}-${PAGINATION.FRACTION_WRAPPER_SUFFIX}`;
|
|
1028
|
+
const fractionCurrentClass = `${pagination.classPrefix}-${PAGINATION.FRACTION_CURRENT_SUFFIX}`;
|
|
1029
|
+
const fractionTotalClass = `${pagination.classPrefix}-${PAGINATION.FRACTION_TOTAL_SUFFIX}`;
|
|
1485
1030
|
addClass(wrapper, fractionWrapperClass);
|
|
1486
1031
|
wrapper.innerHTML = pagination.renderFraction(fractionCurrentClass, fractionTotalClass);
|
|
1487
|
-
this.update(
|
|
1488
|
-
}
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
var anchorCount = anchorPoints.length;
|
|
1032
|
+
this.update(flicking2.index);
|
|
1033
|
+
}
|
|
1034
|
+
update(index) {
|
|
1035
|
+
const flicking2 = this._flicking;
|
|
1036
|
+
const wrapper = this._wrapper;
|
|
1037
|
+
const pagination = this._pagination;
|
|
1038
|
+
const anchorPoints = flicking2.camera.anchorPoints;
|
|
1039
|
+
const currentIndex = anchorPoints.length > 0 ? index - anchorPoints[0].panel.index + 1 : 0;
|
|
1040
|
+
const anchorCount = anchorPoints.length;
|
|
1497
1041
|
if (currentIndex === this._prevIndex && anchorCount === this._prevTotal) return;
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1042
|
+
const fractionCurrentSelector = `.${pagination.classPrefix}-${PAGINATION.FRACTION_CURRENT_SUFFIX}`;
|
|
1043
|
+
const fractionTotalSelector = `.${pagination.classPrefix}-${PAGINATION.FRACTION_TOTAL_SUFFIX}`;
|
|
1044
|
+
const currentWrapper = wrapper.querySelector(fractionCurrentSelector);
|
|
1045
|
+
const totalWrapper = wrapper.querySelector(fractionTotalSelector);
|
|
1502
1046
|
currentWrapper.innerHTML = pagination.fractionCurrentFormat(currentIndex);
|
|
1503
1047
|
totalWrapper.innerHTML = pagination.fractionTotalFormat(anchorCount);
|
|
1504
1048
|
this._prevIndex = currentIndex;
|
|
1505
1049
|
this._prevTotal = anchorCount;
|
|
1506
|
-
}
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
_this._sliderIndex = -1;
|
|
1523
|
-
|
|
1524
|
-
_this.moveTo = function (index) {
|
|
1525
|
-
var pagination = _this._pagination;
|
|
1526
|
-
var sliderEl = _this._wrapper.firstElementChild;
|
|
1527
|
-
var bulletSize = _this._bulletSize;
|
|
1528
|
-
var wrapperSize = bulletSize * pagination.bulletCount;
|
|
1529
|
-
sliderEl.style.transform = "translate(" + (wrapperSize / 2 - (index + 0.5) * bulletSize) + "px)";
|
|
1530
|
-
_this._sliderIndex = index;
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
class ScrollBulletRenderer extends Renderer {
|
|
1053
|
+
constructor() {
|
|
1054
|
+
super(...arguments);
|
|
1055
|
+
this._bullets = [];
|
|
1056
|
+
this._bulletSize = 0;
|
|
1057
|
+
this._previousIndex = -1;
|
|
1058
|
+
this._sliderIndex = -1;
|
|
1059
|
+
this.moveTo = (index) => {
|
|
1060
|
+
const pagination = this._pagination;
|
|
1061
|
+
const sliderEl = this._wrapper.firstElementChild;
|
|
1062
|
+
const bulletSize = this._bulletSize;
|
|
1063
|
+
const wrapperSize = bulletSize * pagination.bulletCount;
|
|
1064
|
+
sliderEl.style.transform = `translate(${wrapperSize / 2 - (index + 0.5) * bulletSize}px)`;
|
|
1065
|
+
this._sliderIndex = index;
|
|
1531
1066
|
};
|
|
1532
|
-
|
|
1533
|
-
return _this;
|
|
1534
1067
|
}
|
|
1535
|
-
|
|
1536
|
-
var __proto = ScrollBulletRenderer.prototype;
|
|
1537
|
-
|
|
1538
|
-
__proto.destroy = function () {
|
|
1068
|
+
destroy() {
|
|
1539
1069
|
this._bullets = [];
|
|
1540
1070
|
this._bulletSize = 0;
|
|
1541
1071
|
this._previousIndex = -1;
|
|
1542
1072
|
this._sliderIndex = -1;
|
|
1543
|
-
}
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
var sliderClass = pagination.classPrefix + "-" + PAGINATION.SCROLL_SLIDER_SUFFIX;
|
|
1556
|
-
var uninitClass = pagination.classPrefix + "-" + PAGINATION.SCROLL_UNINIT_SUFFIX;
|
|
1557
|
-
var sliderEl = document.createElement("div");
|
|
1073
|
+
}
|
|
1074
|
+
render() {
|
|
1075
|
+
const wrapper = this._wrapper;
|
|
1076
|
+
const flicking2 = this._flicking;
|
|
1077
|
+
const pagination = this._pagination;
|
|
1078
|
+
const renderBullet = pagination.renderBullet;
|
|
1079
|
+
const anchorPoints = flicking2.camera.anchorPoints;
|
|
1080
|
+
const dynamicWrapperClass = `${pagination.classPrefix}-${PAGINATION.SCROLL_WRAPPER_SUFFIX}`;
|
|
1081
|
+
const bulletClass = `${pagination.classPrefix}-${PAGINATION.BULLET_SUFFIX}`;
|
|
1082
|
+
const sliderClass = `${pagination.classPrefix}-${PAGINATION.SCROLL_SLIDER_SUFFIX}`;
|
|
1083
|
+
const uninitClass = `${pagination.classPrefix}-${PAGINATION.SCROLL_UNINIT_SUFFIX}`;
|
|
1084
|
+
const sliderEl = document.createElement("div");
|
|
1558
1085
|
addClass(sliderEl, sliderClass);
|
|
1559
1086
|
addClass(wrapper, uninitClass);
|
|
1560
1087
|
addClass(wrapper, dynamicWrapperClass);
|
|
1561
1088
|
wrapper.appendChild(sliderEl);
|
|
1562
|
-
sliderEl.innerHTML = anchorPoints.map(
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
bullets.forEach(function (bullet, index) {
|
|
1567
|
-
_this._addBulletEvents(bullet, index);
|
|
1089
|
+
sliderEl.innerHTML = anchorPoints.map((_, index) => renderBullet(bulletClass, index)).join("\n");
|
|
1090
|
+
const bullets = [].slice.call(sliderEl.children);
|
|
1091
|
+
bullets.forEach((bullet, index) => {
|
|
1092
|
+
this._addBulletEvents(bullet, index);
|
|
1568
1093
|
});
|
|
1569
1094
|
if (bullets.length <= 0) return;
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
wrapper.style.width = bulletSize * pagination.bulletCount
|
|
1095
|
+
const bulletStyle = getComputedStyle(bullets[0]);
|
|
1096
|
+
const bulletSize = bullets[0].clientWidth + parseFloat(bulletStyle.marginLeft) + parseFloat(bulletStyle.marginRight);
|
|
1097
|
+
wrapper.style.width = `${bulletSize * pagination.bulletCount}px`;
|
|
1573
1098
|
this._bullets = bullets;
|
|
1574
1099
|
this._bulletSize = bulletSize;
|
|
1575
1100
|
this._previousIndex = -1;
|
|
1576
1101
|
this.update(this._flicking.index);
|
|
1577
|
-
window.requestAnimationFrame(
|
|
1102
|
+
window.requestAnimationFrame(() => {
|
|
1578
1103
|
removeClass(wrapper, uninitClass);
|
|
1579
1104
|
});
|
|
1580
|
-
}
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
var activeIndex = index - anchorOffset;
|
|
1105
|
+
}
|
|
1106
|
+
update(index) {
|
|
1107
|
+
const pagination = this._pagination;
|
|
1108
|
+
const flicking$1 = this._flicking;
|
|
1109
|
+
const bullets = this._bullets;
|
|
1110
|
+
const prevIndex = this._previousIndex;
|
|
1111
|
+
const renderBullet = pagination.renderBullet;
|
|
1112
|
+
const renderActiveBullet = pagination.renderActiveBullet;
|
|
1113
|
+
const anchorPoints = flicking$1.camera.anchorPoints;
|
|
1114
|
+
const anchorOffset = anchorPoints[0].panel.index;
|
|
1115
|
+
const activeIndex = index - anchorOffset;
|
|
1592
1116
|
if (anchorPoints.length <= 0) return;
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
};
|
|
1601
|
-
|
|
1602
|
-
var bulletNextClass = function (offset) {
|
|
1603
|
-
return "" + nextClassPrefix + (offset > 1 ? offset : "");
|
|
1604
|
-
};
|
|
1605
|
-
|
|
1606
|
-
var prevClassRegex = new RegExp("^" + prevClassPrefix);
|
|
1607
|
-
var nextClassRegex = new RegExp("^" + nextClassPrefix);
|
|
1608
|
-
|
|
1117
|
+
const bulletClass = `${pagination.classPrefix}-${PAGINATION.BULLET_SUFFIX}`;
|
|
1118
|
+
const bulletActiveClass = `${pagination.classPrefix}-${PAGINATION.BULLET_ACTIVE_SUFFIX}`;
|
|
1119
|
+
const prevClassPrefix = `${pagination.classPrefix}-${PAGINATION.SCROLL_PREV_SUFFIX}`;
|
|
1120
|
+
const nextClassPrefix = `${pagination.classPrefix}-${PAGINATION.SCROLL_NEXT_SUFFIX}`;
|
|
1121
|
+
const bulletPrevClass = (offset) => `${prevClassPrefix}${offset > 1 ? offset : ""}`;
|
|
1122
|
+
const bulletNextClass = (offset) => `${nextClassPrefix}${offset > 1 ? offset : ""}`;
|
|
1123
|
+
const prevClassRegex = new RegExp(`^${prevClassPrefix}`);
|
|
1124
|
+
const nextClassRegex = new RegExp(`^${nextClassPrefix}`);
|
|
1609
1125
|
if (renderActiveBullet) {
|
|
1610
|
-
|
|
1611
|
-
|
|
1126
|
+
const prevBullet = bullets[prevIndex];
|
|
1612
1127
|
if (prevBullet) {
|
|
1613
|
-
|
|
1614
|
-
|
|
1128
|
+
const newBullet = this._createBulletFromString(renderBullet(bulletClass, prevIndex), prevIndex);
|
|
1615
1129
|
prevBullet.parentElement.replaceChild(newBullet, prevBullet);
|
|
1616
1130
|
bullets[prevIndex] = newBullet;
|
|
1617
1131
|
}
|
|
1618
|
-
|
|
1619
|
-
var activeBullet = bullets[activeIndex];
|
|
1620
|
-
|
|
1132
|
+
const activeBullet = bullets[activeIndex];
|
|
1621
1133
|
if (activeBullet) {
|
|
1622
|
-
|
|
1623
|
-
|
|
1134
|
+
const newActiveBullet = this._createBulletFromString(renderActiveBullet(bulletClass, activeIndex), activeIndex);
|
|
1624
1135
|
activeBullet.parentElement.replaceChild(newActiveBullet, activeBullet);
|
|
1625
1136
|
bullets[activeIndex] = newActiveBullet;
|
|
1626
1137
|
}
|
|
1627
1138
|
}
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
for (var _i = 0, classList_1 = classList; _i < classList_1.length; _i++) {
|
|
1634
|
-
var className = classList_1[_i];
|
|
1635
|
-
|
|
1139
|
+
bullets.forEach((bullet, idx) => {
|
|
1140
|
+
const indexOffset = idx - activeIndex;
|
|
1141
|
+
const classList = bullet.className.split(" ");
|
|
1142
|
+
for (const className of classList) {
|
|
1636
1143
|
if (className === bulletActiveClass || prevClassRegex.test(className) || nextClassRegex.test(className)) {
|
|
1637
1144
|
removeClass(bullet, className);
|
|
1638
1145
|
}
|
|
1639
1146
|
}
|
|
1640
|
-
|
|
1641
1147
|
if (indexOffset === 0) {
|
|
1642
1148
|
addClass(bullet, bulletActiveClass);
|
|
1643
1149
|
} else if (indexOffset > 0) {
|
|
@@ -1648,76 +1154,45 @@ version: 4.8.0-beta.1
|
|
|
1648
1154
|
});
|
|
1649
1155
|
pagination.scrollOnChange(activeIndex, {
|
|
1650
1156
|
total: bullets.length,
|
|
1651
|
-
prevIndex
|
|
1157
|
+
prevIndex,
|
|
1652
1158
|
sliderIndex: this._sliderIndex,
|
|
1653
1159
|
direction: activeIndex > prevIndex ? flicking.DIRECTION.NEXT : flicking.DIRECTION.PREV,
|
|
1654
|
-
bullets:
|
|
1160
|
+
bullets: [...bullets],
|
|
1655
1161
|
moveTo: this.moveTo
|
|
1656
1162
|
});
|
|
1657
1163
|
this._previousIndex = activeIndex;
|
|
1658
|
-
}
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
function () {
|
|
1670
|
-
function Pagination(_a) {
|
|
1671
|
-
var _this = this;
|
|
1672
|
-
|
|
1673
|
-
var _b = _a === void 0 ? {} : _a,
|
|
1674
|
-
_c = _b.parentEl,
|
|
1675
|
-
parentEl = _c === void 0 ? null : _c,
|
|
1676
|
-
_d = _b.selector,
|
|
1677
|
-
selector = _d === void 0 ? PAGINATION.SELECTOR : _d,
|
|
1678
|
-
_e = _b.type,
|
|
1679
|
-
type = _e === void 0 ? PAGINATION.TYPE.BULLET : _e,
|
|
1680
|
-
_f = _b.classPrefix,
|
|
1681
|
-
classPrefix = _f === void 0 ? PAGINATION.PREFIX : _f,
|
|
1682
|
-
_g = _b.bulletCount,
|
|
1683
|
-
bulletCount = _g === void 0 ? 5 : _g,
|
|
1684
|
-
_h = _b.renderBullet,
|
|
1685
|
-
renderBullet = _h === void 0 ? function (className) {
|
|
1686
|
-
return "<span class=\"" + className + "\"></span>";
|
|
1687
|
-
} : _h,
|
|
1688
|
-
_j = _b.renderActiveBullet,
|
|
1689
|
-
renderActiveBullet = _j === void 0 ? null : _j,
|
|
1690
|
-
_k = _b.renderFraction,
|
|
1691
|
-
renderFraction = _k === void 0 ? function (currentClass, totalClass) {
|
|
1692
|
-
return "<span class=\"" + currentClass + "\"></span>/<span class=\"" + totalClass + "\"></span>";
|
|
1693
|
-
} : _k,
|
|
1694
|
-
_l = _b.fractionCurrentFormat,
|
|
1695
|
-
fractionCurrentFormat = _l === void 0 ? function (index) {
|
|
1696
|
-
return index.toString();
|
|
1697
|
-
} : _l,
|
|
1698
|
-
_m = _b.fractionTotalFormat,
|
|
1699
|
-
fractionTotalFormat = _m === void 0 ? function (index) {
|
|
1700
|
-
return index.toString();
|
|
1701
|
-
} : _m,
|
|
1702
|
-
_o = _b.scrollOnChange,
|
|
1703
|
-
scrollOnChange = _o === void 0 ? function (index, ctx) {
|
|
1704
|
-
return ctx.moveTo(index);
|
|
1705
|
-
} : _o;
|
|
1706
|
-
/* Internal Values */
|
|
1707
|
-
|
|
1708
|
-
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
class Pagination {
|
|
1167
|
+
/**
|
|
1168
|
+
* @param options - Options for the Pagination instance
|
|
1169
|
+
* @example
|
|
1170
|
+
* ```ts
|
|
1171
|
+
* flicking.addPlugins(new Pagination({ type: "bullet", selector: ".flicking-pagination" }));
|
|
1172
|
+
* ```
|
|
1173
|
+
*/
|
|
1174
|
+
constructor(options = {}) {
|
|
1709
1175
|
this._flicking = null;
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
_this._renderer.render();
|
|
1176
|
+
this.update = () => {
|
|
1177
|
+
this._removeAllChilds();
|
|
1178
|
+
this._renderer.render();
|
|
1715
1179
|
};
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
_this._renderer.update(evt.index);
|
|
1180
|
+
this._onIndexChange = (evt) => {
|
|
1181
|
+
this._renderer.update(evt.index);
|
|
1719
1182
|
};
|
|
1720
|
-
|
|
1183
|
+
const {
|
|
1184
|
+
parentEl = null,
|
|
1185
|
+
selector = PAGINATION.SELECTOR,
|
|
1186
|
+
type = PAGINATION.TYPE.BULLET,
|
|
1187
|
+
classPrefix = PAGINATION.PREFIX,
|
|
1188
|
+
bulletCount = 5,
|
|
1189
|
+
renderBullet = (className) => `<span class="${className}"></span>`,
|
|
1190
|
+
renderActiveBullet = null,
|
|
1191
|
+
renderFraction = (currentClass, totalClass) => `<span class="${currentClass}"></span>/<span class="${totalClass}"></span>`,
|
|
1192
|
+
fractionCurrentFormat = (index) => index.toString(),
|
|
1193
|
+
fractionTotalFormat = (index) => index.toString(),
|
|
1194
|
+
scrollOnChange = (index, ctx) => ctx.moveTo(index)
|
|
1195
|
+
} = options;
|
|
1721
1196
|
this._parentEl = parentEl;
|
|
1722
1197
|
this._selector = selector;
|
|
1723
1198
|
this._type = type;
|
|
@@ -1730,211 +1205,163 @@ version: 4.8.0-beta.1
|
|
|
1730
1205
|
this._fractionTotalFormat = fractionTotalFormat;
|
|
1731
1206
|
this._scrollOnChange = scrollOnChange;
|
|
1732
1207
|
}
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
}
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
}
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
}
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
}
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
},
|
|
1826
|
-
set: function (val) {
|
|
1827
|
-
this._fractionTotalFormat = val;
|
|
1828
|
-
},
|
|
1829
|
-
enumerable: false,
|
|
1830
|
-
configurable: true
|
|
1831
|
-
});
|
|
1832
|
-
Object.defineProperty(__proto, "scrollOnChange", {
|
|
1833
|
-
get: function () {
|
|
1834
|
-
return this._scrollOnChange;
|
|
1835
|
-
},
|
|
1836
|
-
set: function (val) {
|
|
1837
|
-
this._scrollOnChange = val;
|
|
1838
|
-
},
|
|
1839
|
-
enumerable: false,
|
|
1840
|
-
configurable: true
|
|
1841
|
-
});
|
|
1842
|
-
Object.defineProperty(__proto, "bulletWrapperclassPrefixClass", {
|
|
1843
|
-
set: function (val) {
|
|
1844
|
-
this._classPrefix = val;
|
|
1845
|
-
},
|
|
1846
|
-
enumerable: false,
|
|
1847
|
-
configurable: true
|
|
1848
|
-
});
|
|
1849
|
-
|
|
1850
|
-
__proto.init = function (flicking$1) {
|
|
1208
|
+
/** Current value of the {@link PaginationOptions.parentEl | parentEl} option. */
|
|
1209
|
+
get parentEl() {
|
|
1210
|
+
return this._parentEl;
|
|
1211
|
+
}
|
|
1212
|
+
/** Current value of the {@link PaginationOptions.selector | selector} option. */
|
|
1213
|
+
get selector() {
|
|
1214
|
+
return this._selector;
|
|
1215
|
+
}
|
|
1216
|
+
/** Current value of the {@link PaginationOptions.type | type} option. */
|
|
1217
|
+
get type() {
|
|
1218
|
+
return this._type;
|
|
1219
|
+
}
|
|
1220
|
+
/** Current value of the {@link PaginationOptions.classPrefix | classPrefix} option. */
|
|
1221
|
+
get classPrefix() {
|
|
1222
|
+
return this._classPrefix;
|
|
1223
|
+
}
|
|
1224
|
+
/** Current value of the {@link PaginationOptions.bulletCount | bulletCount} option. */
|
|
1225
|
+
get bulletCount() {
|
|
1226
|
+
return this._bulletCount;
|
|
1227
|
+
}
|
|
1228
|
+
/** Current value of the {@link PaginationOptions.renderBullet | renderBullet} option. */
|
|
1229
|
+
get renderBullet() {
|
|
1230
|
+
return this._renderBullet;
|
|
1231
|
+
}
|
|
1232
|
+
/** Current value of the {@link PaginationOptions.renderActiveBullet | renderActiveBullet} option. */
|
|
1233
|
+
get renderActiveBullet() {
|
|
1234
|
+
return this._renderActiveBullet;
|
|
1235
|
+
}
|
|
1236
|
+
/** Current value of the {@link PaginationOptions.renderFraction | renderFraction} option. */
|
|
1237
|
+
get renderFraction() {
|
|
1238
|
+
return this._renderFraction;
|
|
1239
|
+
}
|
|
1240
|
+
/** Current value of the {@link PaginationOptions.fractionCurrentFormat | fractionCurrentFormat} option. */
|
|
1241
|
+
get fractionCurrentFormat() {
|
|
1242
|
+
return this._fractionCurrentFormat;
|
|
1243
|
+
}
|
|
1244
|
+
/** Current value of the {@link PaginationOptions.fractionTotalFormat | fractionTotalFormat} option. */
|
|
1245
|
+
get fractionTotalFormat() {
|
|
1246
|
+
return this._fractionTotalFormat;
|
|
1247
|
+
}
|
|
1248
|
+
/** Current value of the {@link PaginationOptions.scrollOnChange | scrollOnChange} option. */
|
|
1249
|
+
get scrollOnChange() {
|
|
1250
|
+
return this._scrollOnChange;
|
|
1251
|
+
}
|
|
1252
|
+
/** Sets {@link PaginationOptions.parentEl | parentEl}. */
|
|
1253
|
+
set parentEl(val) {
|
|
1254
|
+
this._parentEl = val;
|
|
1255
|
+
}
|
|
1256
|
+
/** Sets {@link PaginationOptions.selector | selector}. */
|
|
1257
|
+
set selector(val) {
|
|
1258
|
+
this._selector = val;
|
|
1259
|
+
}
|
|
1260
|
+
/** Sets {@link PaginationOptions.type | type}. */
|
|
1261
|
+
set type(val) {
|
|
1262
|
+
this._type = val;
|
|
1263
|
+
}
|
|
1264
|
+
/** Sets {@link PaginationOptions.classPrefix | classPrefix}. */
|
|
1265
|
+
set bulletWrapperclassPrefixClass(val) {
|
|
1266
|
+
this._classPrefix = val;
|
|
1267
|
+
}
|
|
1268
|
+
/** Sets {@link PaginationOptions.bulletCount | bulletCount}. */
|
|
1269
|
+
set bulletCount(val) {
|
|
1270
|
+
this._bulletCount = val;
|
|
1271
|
+
}
|
|
1272
|
+
/** Sets {@link PaginationOptions.renderBullet | renderBullet}. */
|
|
1273
|
+
set renderBullet(val) {
|
|
1274
|
+
this._renderBullet = val;
|
|
1275
|
+
}
|
|
1276
|
+
/** Sets {@link PaginationOptions.renderActiveBullet | renderActiveBullet}. */
|
|
1277
|
+
set renderActiveBullet(val) {
|
|
1278
|
+
this._renderActiveBullet = val;
|
|
1279
|
+
}
|
|
1280
|
+
/** Sets {@link PaginationOptions.renderFraction | renderFraction}. */
|
|
1281
|
+
set renderFraction(val) {
|
|
1282
|
+
this._renderFraction = val;
|
|
1283
|
+
}
|
|
1284
|
+
/** Sets {@link PaginationOptions.fractionCurrentFormat | fractionCurrentFormat}. */
|
|
1285
|
+
set fractionCurrentFormat(val) {
|
|
1286
|
+
this._fractionCurrentFormat = val;
|
|
1287
|
+
}
|
|
1288
|
+
/** Sets {@link PaginationOptions.fractionTotalFormat | fractionTotalFormat}. */
|
|
1289
|
+
set fractionTotalFormat(val) {
|
|
1290
|
+
this._fractionTotalFormat = val;
|
|
1291
|
+
}
|
|
1292
|
+
/** Sets {@link PaginationOptions.scrollOnChange | scrollOnChange}. */
|
|
1293
|
+
set scrollOnChange(val) {
|
|
1294
|
+
this._scrollOnChange = val;
|
|
1295
|
+
}
|
|
1296
|
+
/** Initialize the plugin, create the pagination renderer, and attach event listeners to the Flicking instance.
|
|
1297
|
+
* @param flicking - The Flicking instance to attach this plugin to
|
|
1298
|
+
*/
|
|
1299
|
+
init(flicking$1) {
|
|
1851
1300
|
if (this._flicking) {
|
|
1852
1301
|
this.destroy();
|
|
1853
1302
|
}
|
|
1854
|
-
|
|
1855
1303
|
this._flicking = flicking$1;
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1304
|
+
const type = this._type;
|
|
1305
|
+
const selector = this._selector;
|
|
1306
|
+
const parentEl = this._parentEl ? this._parentEl : flicking$1.element;
|
|
1307
|
+
const wrapper = parentEl.querySelector(selector);
|
|
1861
1308
|
if (!wrapper) {
|
|
1862
|
-
throw new Error(
|
|
1309
|
+
throw new Error(`[Flicking-Pagination] Couldn't find element with the given selector: ${selector}`);
|
|
1863
1310
|
}
|
|
1864
|
-
|
|
1865
1311
|
this._wrapper = wrapper;
|
|
1866
1312
|
this._renderer = this._createRenderer(type);
|
|
1867
1313
|
flicking$1.on(flicking.EVENTS.WILL_CHANGE, this._onIndexChange);
|
|
1868
1314
|
flicking$1.on(flicking.EVENTS.WILL_RESTORE, this._onIndexChange);
|
|
1869
1315
|
flicking$1.on(flicking.EVENTS.PANEL_CHANGE, this.update);
|
|
1870
1316
|
this.update();
|
|
1871
|
-
}
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1317
|
+
}
|
|
1318
|
+
/** Destroy the plugin, remove all event listeners, and clean up pagination DOM elements. */
|
|
1319
|
+
destroy() {
|
|
1320
|
+
const flicking$1 = this._flicking;
|
|
1876
1321
|
if (!flicking$1) {
|
|
1877
1322
|
return;
|
|
1878
1323
|
}
|
|
1879
|
-
|
|
1880
1324
|
flicking$1.off(flicking.EVENTS.WILL_CHANGE, this._onIndexChange);
|
|
1881
1325
|
flicking$1.off(flicking.EVENTS.WILL_RESTORE, this._onIndexChange);
|
|
1882
1326
|
flicking$1.off(flicking.EVENTS.PANEL_CHANGE, this.update);
|
|
1883
|
-
|
|
1884
1327
|
this._renderer.destroy();
|
|
1885
|
-
|
|
1886
1328
|
this._removeAllChilds();
|
|
1887
|
-
|
|
1888
1329
|
this._flicking = null;
|
|
1889
|
-
}
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
var options = {
|
|
1330
|
+
}
|
|
1331
|
+
_createRenderer(type) {
|
|
1332
|
+
const options = {
|
|
1893
1333
|
flicking: this._flicking,
|
|
1894
1334
|
pagination: this,
|
|
1895
1335
|
wrapper: this._wrapper
|
|
1896
1336
|
};
|
|
1897
|
-
|
|
1898
1337
|
switch (type) {
|
|
1899
1338
|
case PAGINATION.TYPE.BULLET:
|
|
1900
1339
|
return new BulletRenderer(options);
|
|
1901
|
-
|
|
1902
1340
|
case PAGINATION.TYPE.FRACTION:
|
|
1903
1341
|
return new FractionRenderer(options);
|
|
1904
|
-
|
|
1905
1342
|
case PAGINATION.TYPE.SCROLL:
|
|
1906
1343
|
return new ScrollBulletRenderer(options);
|
|
1907
|
-
|
|
1908
1344
|
default:
|
|
1909
|
-
throw new Error(
|
|
1345
|
+
throw new Error(`[Flicking-Pagination] type "${type}" is not supported.`);
|
|
1910
1346
|
}
|
|
1911
|
-
}
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
var wrapper = this._wrapper;
|
|
1915
|
-
|
|
1347
|
+
}
|
|
1348
|
+
_removeAllChilds() {
|
|
1349
|
+
const wrapper = this._wrapper;
|
|
1916
1350
|
while (wrapper.firstChild) {
|
|
1917
1351
|
wrapper.removeChild(wrapper.firstChild);
|
|
1918
1352
|
}
|
|
1919
|
-
}
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
exports.PAGINATION = PAGINATION;
|
|
1933
|
-
exports.Pagination = Pagination;
|
|
1934
|
-
exports.Parallax = Parallax;
|
|
1935
|
-
exports.Perspective = Perspective;
|
|
1936
|
-
exports.SYNC = SYNC;
|
|
1937
|
-
exports.Sync = Sync;
|
|
1938
|
-
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
exports2.ARROW = ARROW;
|
|
1356
|
+
exports2.Arrow = Arrow;
|
|
1357
|
+
exports2.AutoPlay = AutoPlay;
|
|
1358
|
+
exports2.Fade = Fade;
|
|
1359
|
+
exports2.PAGINATION = PAGINATION;
|
|
1360
|
+
exports2.Pagination = Pagination;
|
|
1361
|
+
exports2.Parallax = Parallax;
|
|
1362
|
+
exports2.Perspective = Perspective;
|
|
1363
|
+
exports2.SYNC = SYNC;
|
|
1364
|
+
exports2.Sync = Sync;
|
|
1365
|
+
Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
|
|
1939
1366
|
}));
|
|
1940
1367
|
//# sourceMappingURL=plugins.js.map
|