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