@egjs/vue3-flicking 4.15.0 → 4.17.0-beta.2
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/LICENSE +19 -0
- package/declaration/FlickingProps.d.ts +1 -1
- package/declaration/VuePanel.d.ts +1 -1
- package/declaration/VueRenderer.d.ts +1 -1
- package/declaration/types.d.ts +3 -3
- package/dist/flicking.cjs.js +446 -542
- package/dist/flicking.cjs.js.map +1 -1
- package/dist/flicking.esm.js +450 -541
- package/dist/flicking.esm.js.map +1 -1
- package/package.json +16 -22
- package/src/Flicking.ts +55 -62
- package/src/FlickingProps.ts +3 -2
- package/src/VueElementProvider.ts +3 -1
- package/src/VueRenderer.ts +3 -8
- package/src/reactive.ts +1 -2
- package/src/types.ts +27 -30
- package/public/favicon.ico +0 -0
- package/public/index.html +0 -18
package/dist/flicking.esm.js
CHANGED
|
@@ -1,229 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
version: 4.15.0
|
|
8
|
-
*/
|
|
9
|
-
import { defineComponent, getCurrentInstance, resolveComponent, h, Comment, Text, Fragment } from 'vue';
|
|
10
|
-
import ListDiffer from '@egjs/list-differ';
|
|
11
|
-
import Component from '@egjs/component';
|
|
12
|
-
import VanillaFlicking__default, { getFlickingAttached, ExternalRenderer, getRenderingPanels, range, withFlickingMethods, VirtualRenderingStrategy, NormalRenderingStrategy, EVENTS, sync, getDefaultCameraTransform, flickingReactiveAPIAdapter } from '@egjs/flicking';
|
|
13
|
-
export * from '@egjs/flicking';
|
|
14
|
-
import { useReactive } from '@cfcs/vue3';
|
|
15
|
-
|
|
16
|
-
/*! *****************************************************************************
|
|
17
|
-
Copyright (c) Microsoft Corporation.
|
|
18
|
-
|
|
19
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
20
|
-
purpose with or without fee is hereby granted.
|
|
21
|
-
|
|
22
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
23
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
24
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
25
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
26
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
27
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
28
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
29
|
-
***************************************************************************** */
|
|
30
|
-
|
|
31
|
-
/* global Reflect, Promise */
|
|
32
|
-
var extendStatics = function (d, b) {
|
|
33
|
-
extendStatics = Object.setPrototypeOf || {
|
|
34
|
-
__proto__: []
|
|
35
|
-
} instanceof Array && function (d, b) {
|
|
36
|
-
d.__proto__ = b;
|
|
37
|
-
} || function (d, b) {
|
|
38
|
-
for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
return extendStatics(d, b);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
function __extends(d, b) {
|
|
45
|
-
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
46
|
-
extendStatics(d, b);
|
|
47
|
-
|
|
48
|
-
function __() {
|
|
49
|
-
this.constructor = d;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
53
|
-
}
|
|
54
|
-
var __assign = function () {
|
|
55
|
-
__assign = Object.assign || function __assign(t) {
|
|
56
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
57
|
-
s = arguments[i];
|
|
58
|
-
|
|
59
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return t;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
return __assign.apply(this, arguments);
|
|
66
|
-
};
|
|
67
|
-
function __rest(s, e) {
|
|
68
|
-
var t = {};
|
|
69
|
-
|
|
70
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
71
|
-
|
|
72
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
73
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
74
|
-
}
|
|
75
|
-
return t;
|
|
76
|
-
}
|
|
77
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
78
|
-
function adopt(value) {
|
|
79
|
-
return value instanceof P ? value : new P(function (resolve) {
|
|
80
|
-
resolve(value);
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
85
|
-
function fulfilled(value) {
|
|
86
|
-
try {
|
|
87
|
-
step(generator.next(value));
|
|
88
|
-
} catch (e) {
|
|
89
|
-
reject(e);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function rejected(value) {
|
|
94
|
-
try {
|
|
95
|
-
step(generator["throw"](value));
|
|
96
|
-
} catch (e) {
|
|
97
|
-
reject(e);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function step(result) {
|
|
102
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
function __generator(thisArg, body) {
|
|
109
|
-
var _ = {
|
|
110
|
-
label: 0,
|
|
111
|
-
sent: function () {
|
|
112
|
-
if (t[0] & 1) throw t[1];
|
|
113
|
-
return t[1];
|
|
114
|
-
},
|
|
115
|
-
trys: [],
|
|
116
|
-
ops: []
|
|
117
|
-
},
|
|
118
|
-
f,
|
|
119
|
-
y,
|
|
120
|
-
t,
|
|
121
|
-
g;
|
|
122
|
-
return g = {
|
|
123
|
-
next: verb(0),
|
|
124
|
-
"throw": verb(1),
|
|
125
|
-
"return": verb(2)
|
|
126
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
127
|
-
return this;
|
|
128
|
-
}), g;
|
|
129
|
-
|
|
130
|
-
function verb(n) {
|
|
131
|
-
return function (v) {
|
|
132
|
-
return step([n, v]);
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
function step(op) {
|
|
137
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
138
|
-
|
|
139
|
-
while (_) try {
|
|
140
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
141
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
142
|
-
|
|
143
|
-
switch (op[0]) {
|
|
144
|
-
case 0:
|
|
145
|
-
case 1:
|
|
146
|
-
t = op;
|
|
147
|
-
break;
|
|
148
|
-
|
|
149
|
-
case 4:
|
|
150
|
-
_.label++;
|
|
151
|
-
return {
|
|
152
|
-
value: op[1],
|
|
153
|
-
done: false
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
case 5:
|
|
157
|
-
_.label++;
|
|
158
|
-
y = op[1];
|
|
159
|
-
op = [0];
|
|
160
|
-
continue;
|
|
161
|
-
|
|
162
|
-
case 7:
|
|
163
|
-
op = _.ops.pop();
|
|
164
|
-
|
|
165
|
-
_.trys.pop();
|
|
166
|
-
|
|
167
|
-
continue;
|
|
168
|
-
|
|
169
|
-
default:
|
|
170
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
171
|
-
_ = 0;
|
|
172
|
-
continue;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
176
|
-
_.label = op[1];
|
|
177
|
-
break;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
181
|
-
_.label = t[1];
|
|
182
|
-
t = op;
|
|
183
|
-
break;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
if (t && _.label < t[2]) {
|
|
187
|
-
_.label = t[2];
|
|
188
|
-
|
|
189
|
-
_.ops.push(op);
|
|
190
|
-
|
|
191
|
-
break;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
if (t[2]) _.ops.pop();
|
|
195
|
-
|
|
196
|
-
_.trys.pop();
|
|
197
|
-
|
|
198
|
-
continue;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
op = body.call(thisArg, _);
|
|
202
|
-
} catch (e) {
|
|
203
|
-
op = [6, e];
|
|
204
|
-
y = 0;
|
|
205
|
-
} finally {
|
|
206
|
-
f = t = 0;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
if (op[0] & 5) throw op[1];
|
|
210
|
-
return {
|
|
211
|
-
value: op[0] ? op[1] : void 0,
|
|
212
|
-
done: true
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
function __spreadArray(to, from, pack) {
|
|
217
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
218
|
-
if (ar || !(i in from)) {
|
|
219
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
220
|
-
ar[i] = from[i];
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
var FlickingProps = {
|
|
1
|
+
import Component from "@egjs/component";
|
|
2
|
+
import VanillaFlicking__default, { ExternalRenderer, getFlickingAttached, EVENTS, getDefaultCameraTransform, sync, VirtualRenderingStrategy, NormalRenderingStrategy, getRenderingPanels, range, withFlickingMethods, flickingReactiveAPIAdapter } from "@egjs/flicking";
|
|
3
|
+
export * from "@egjs/flicking";
|
|
4
|
+
import ListDiffer from "@egjs/list-differ";
|
|
5
|
+
import { defineComponent, Fragment, Comment, Text, h, getCurrentInstance, resolveComponent, ref, onMounted, onUnmounted } from "vue";
|
|
6
|
+
const FlickingProps = {
|
|
227
7
|
viewportTag: {
|
|
228
8
|
type: String,
|
|
229
9
|
default: "div",
|
|
@@ -250,16 +30,12 @@ var FlickingProps = {
|
|
|
250
30
|
},
|
|
251
31
|
options: {
|
|
252
32
|
type: Object,
|
|
253
|
-
default:
|
|
254
|
-
return {};
|
|
255
|
-
},
|
|
33
|
+
default: () => ({}),
|
|
256
34
|
required: false
|
|
257
35
|
},
|
|
258
36
|
plugins: {
|
|
259
37
|
type: Array,
|
|
260
|
-
default:
|
|
261
|
-
return [];
|
|
262
|
-
},
|
|
38
|
+
default: () => [],
|
|
263
39
|
required: false
|
|
264
40
|
},
|
|
265
41
|
status: {
|
|
@@ -267,388 +43,250 @@ var FlickingProps = {
|
|
|
267
43
|
required: false
|
|
268
44
|
}
|
|
269
45
|
};
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
function (_super) {
|
|
274
|
-
__extends(VueRenderer, _super);
|
|
275
|
-
|
|
276
|
-
function VueRenderer(options) {
|
|
277
|
-
var _this = _super.call(this, options) || this;
|
|
278
|
-
|
|
279
|
-
_this._vueFlicking = options.vueFlicking;
|
|
280
|
-
return _this;
|
|
46
|
+
class VueElementProvider {
|
|
47
|
+
get rendered() {
|
|
48
|
+
return !this._el.hide;
|
|
281
49
|
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
_this._afterRender();
|
|
302
|
-
|
|
303
|
-
resolve();
|
|
304
|
-
});
|
|
305
|
-
vueFlicking.$forceUpdate();
|
|
306
|
-
})];
|
|
307
|
-
});
|
|
308
|
-
});
|
|
309
|
-
};
|
|
310
|
-
|
|
311
|
-
__proto.forceRenderAllPanels = function () {
|
|
312
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
313
|
-
var vueFlicking;
|
|
314
|
-
return __generator(this, function (_a) {
|
|
315
|
-
switch (_a.label) {
|
|
316
|
-
case 0:
|
|
317
|
-
vueFlicking = this._vueFlicking;
|
|
318
|
-
return [4
|
|
319
|
-
/*yield*/
|
|
320
|
-
, _super.prototype.forceRenderAllPanels.call(this)];
|
|
321
|
-
|
|
322
|
-
case 1:
|
|
323
|
-
_a.sent();
|
|
324
|
-
|
|
325
|
-
return [2
|
|
326
|
-
/*return*/
|
|
327
|
-
, new Promise(function (resolve) {
|
|
328
|
-
vueFlicking.renderEmitter.once("render", resolve);
|
|
329
|
-
vueFlicking.$forceUpdate();
|
|
330
|
-
})];
|
|
331
|
-
}
|
|
332
|
-
});
|
|
333
|
-
});
|
|
334
|
-
};
|
|
335
|
-
|
|
336
|
-
__proto._collectPanels = function () {
|
|
337
|
-
var flicking = getFlickingAttached(this._flicking);
|
|
338
|
-
var vueFlicking = this._vueFlicking;
|
|
339
|
-
var childRefs = vueFlicking.$refs;
|
|
340
|
-
var vuePanels = Object.keys(childRefs).map(function (refKey) {
|
|
341
|
-
return childRefs[refKey];
|
|
342
|
-
});
|
|
343
|
-
this._panels = this._strategy.collectPanels(flicking, vuePanels);
|
|
344
|
-
};
|
|
345
|
-
|
|
346
|
-
__proto._createPanel = function (externalComponent, options) {
|
|
347
|
-
return this._strategy.createPanel(externalComponent, options);
|
|
348
|
-
};
|
|
349
|
-
|
|
350
|
-
return VueRenderer;
|
|
351
|
-
}(ExternalRenderer);
|
|
352
|
-
|
|
353
|
-
/*
|
|
354
|
-
* Copyright (c) 2015 NAVER Corp.
|
|
355
|
-
* egjs projects are licensed under the MIT license
|
|
356
|
-
*/
|
|
357
|
-
var VuePanel = defineComponent({
|
|
358
|
-
data: function () {
|
|
50
|
+
get element() {
|
|
51
|
+
const el = this._el.$el.nextSibling;
|
|
52
|
+
if (el && el.nodeType === Node.ELEMENT_NODE) {
|
|
53
|
+
this._cachedElement = el;
|
|
54
|
+
}
|
|
55
|
+
return this._cachedElement;
|
|
56
|
+
}
|
|
57
|
+
constructor(el) {
|
|
58
|
+
this._el = el;
|
|
59
|
+
}
|
|
60
|
+
show() {
|
|
61
|
+
this._el.hide = false;
|
|
62
|
+
}
|
|
63
|
+
hide() {
|
|
64
|
+
this._el.hide = true;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const VuePanel = defineComponent({
|
|
68
|
+
data() {
|
|
359
69
|
return {
|
|
360
70
|
hide: false
|
|
361
71
|
};
|
|
362
72
|
},
|
|
363
|
-
render
|
|
73
|
+
render() {
|
|
364
74
|
if (this.hide || !this.$slots.default) return;
|
|
365
75
|
return this.$slots.default();
|
|
366
76
|
}
|
|
367
77
|
});
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
function VueElementProvider(el) {
|
|
373
|
-
this._el = el;
|
|
78
|
+
class VueRenderer extends ExternalRenderer {
|
|
79
|
+
constructor(options) {
|
|
80
|
+
super(options);
|
|
81
|
+
this._vueFlicking = options.vueFlicking;
|
|
374
82
|
}
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
var Flicking = defineComponent({
|
|
83
|
+
async render() {
|
|
84
|
+
const flicking = getFlickingAttached(this._flicking);
|
|
85
|
+
const vueFlicking = this._vueFlicking;
|
|
86
|
+
const strategy = this._strategy;
|
|
87
|
+
strategy.updateRenderingPanels(flicking);
|
|
88
|
+
strategy.renderPanels(flicking);
|
|
89
|
+
return new Promise((resolve) => {
|
|
90
|
+
vueFlicking.renderEmitter.once("render", () => {
|
|
91
|
+
this._afterRender();
|
|
92
|
+
resolve();
|
|
93
|
+
});
|
|
94
|
+
vueFlicking.$forceUpdate();
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
async forceRenderAllPanels() {
|
|
98
|
+
const vueFlicking = this._vueFlicking;
|
|
99
|
+
await super.forceRenderAllPanels();
|
|
100
|
+
return new Promise((resolve) => {
|
|
101
|
+
vueFlicking.renderEmitter.once("render", resolve);
|
|
102
|
+
vueFlicking.$forceUpdate();
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
_collectPanels() {
|
|
106
|
+
const flicking = getFlickingAttached(this._flicking);
|
|
107
|
+
const vueFlicking = this._vueFlicking;
|
|
108
|
+
const childRefs = vueFlicking.$refs;
|
|
109
|
+
const vuePanels = Object.keys(childRefs).map((refKey) => childRefs[refKey]);
|
|
110
|
+
this._panels = this._strategy.collectPanels(flicking, vuePanels);
|
|
111
|
+
}
|
|
112
|
+
_createPanel(externalComponent, options) {
|
|
113
|
+
return this._strategy.createPanel(externalComponent, options);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
const Flicking = defineComponent({
|
|
410
117
|
props: FlickingProps,
|
|
411
118
|
components: {
|
|
412
119
|
Panel: VuePanel
|
|
413
120
|
},
|
|
414
|
-
data
|
|
121
|
+
data() {
|
|
415
122
|
return {};
|
|
416
123
|
},
|
|
417
|
-
created
|
|
418
|
-
var _this = this;
|
|
419
|
-
|
|
124
|
+
created() {
|
|
420
125
|
this.vanillaFlicking = null;
|
|
421
126
|
this.renderEmitter = new Component();
|
|
422
127
|
this.diffResult = null;
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
});
|
|
128
|
+
this.getPanels = () => {
|
|
129
|
+
const componentInstance = getCurrentInstance();
|
|
130
|
+
const vueFlicking = componentInstance?.ctx;
|
|
131
|
+
const flicking = this.vanillaFlicking;
|
|
132
|
+
const defaultSlots = this.getSlots();
|
|
133
|
+
const diffResult = vueFlicking?.diffResult;
|
|
134
|
+
const slots = diffResult ? getRenderingPanels(flicking, diffResult) : defaultSlots;
|
|
135
|
+
const panelComponent = resolveComponent("Panel");
|
|
136
|
+
const panels = slots.map(
|
|
137
|
+
(slot, idx) => h(
|
|
138
|
+
panelComponent,
|
|
139
|
+
{
|
|
140
|
+
key: slot.key,
|
|
141
|
+
ref: idx.toString()
|
|
142
|
+
},
|
|
143
|
+
() => slot
|
|
144
|
+
)
|
|
145
|
+
);
|
|
442
146
|
return panels;
|
|
443
147
|
};
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
width: firstPanel.size
|
|
456
|
-
} : {
|
|
457
|
-
height: firstPanel.size
|
|
458
|
-
} : {};
|
|
459
|
-
return renderingIndexes.map(function (idx) {
|
|
460
|
-
return h("div", {
|
|
148
|
+
this.getVirtualPanels = () => {
|
|
149
|
+
const options = this.options;
|
|
150
|
+
const { panelClass = "flicking-panel" } = options.virtual;
|
|
151
|
+
const panelsPerView = options.panelsPerView;
|
|
152
|
+
const flicking = this.vanillaFlicking;
|
|
153
|
+
const initialized = flicking?.initialized;
|
|
154
|
+
const renderingIndexes = initialized ? flicking.renderer.strategy.getRenderingIndexesByOrder(flicking) : range(panelsPerView + 1);
|
|
155
|
+
const firstPanel = initialized && flicking.panels[0];
|
|
156
|
+
const size = firstPanel ? flicking.horizontal ? { width: firstPanel.size } : { height: firstPanel.size } : {};
|
|
157
|
+
return renderingIndexes.map(
|
|
158
|
+
(idx) => h("div", {
|
|
461
159
|
key: idx,
|
|
462
160
|
ref: idx.toString(),
|
|
463
161
|
class: panelClass,
|
|
464
162
|
style: size,
|
|
465
163
|
"data-element-index": idx
|
|
466
|
-
})
|
|
467
|
-
|
|
164
|
+
})
|
|
165
|
+
);
|
|
468
166
|
};
|
|
469
|
-
|
|
470
167
|
withFlickingMethods(this, "vanillaFlicking");
|
|
471
168
|
},
|
|
472
|
-
mounted
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
var options = this.options;
|
|
478
|
-
var viewportEl = this.$el;
|
|
479
|
-
var rendererOptions = {
|
|
169
|
+
mounted() {
|
|
170
|
+
const options = this.options;
|
|
171
|
+
const viewportEl = this.$el;
|
|
172
|
+
const rendererOptions = {
|
|
480
173
|
vueFlicking: this,
|
|
481
174
|
align: options.align,
|
|
482
|
-
strategy: options.virtual && (
|
|
175
|
+
strategy: options.virtual && (options.panelsPerView ?? -1) > 0 ? new VirtualRenderingStrategy() : new NormalRenderingStrategy({
|
|
483
176
|
providerCtor: VueElementProvider
|
|
484
177
|
})
|
|
485
178
|
};
|
|
486
|
-
|
|
179
|
+
const flicking = new VanillaFlicking__default(viewportEl, {
|
|
180
|
+
...options,
|
|
487
181
|
externalRenderer: new VueRenderer(rendererOptions)
|
|
488
|
-
}));
|
|
489
|
-
this.vanillaFlicking = flicking;
|
|
490
|
-
flicking.once(EVENTS.READY, function () {
|
|
491
|
-
_this.$forceUpdate();
|
|
492
182
|
});
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
183
|
+
this.vanillaFlicking = flicking;
|
|
184
|
+
flicking.once(EVENTS.READY, () => {
|
|
185
|
+
this.$forceUpdate();
|
|
496
186
|
});
|
|
187
|
+
const slots = this.getSlots();
|
|
188
|
+
this.slotDiffer = new ListDiffer(slots, (vnode) => vnode.key);
|
|
497
189
|
this.pluginsDiffer = new ListDiffer();
|
|
498
190
|
this.bindEvents();
|
|
499
191
|
this.checkPlugins();
|
|
500
|
-
|
|
501
192
|
if (this.status) {
|
|
502
193
|
flicking.setStatus(this.status);
|
|
503
194
|
}
|
|
504
195
|
},
|
|
505
|
-
beforeUnmount
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
(_a = this.vanillaFlicking) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
196
|
+
beforeUnmount() {
|
|
197
|
+
this.vanillaFlicking?.destroy();
|
|
509
198
|
},
|
|
510
|
-
beforeMount
|
|
199
|
+
beforeMount() {
|
|
511
200
|
this.fillKeys();
|
|
512
201
|
},
|
|
513
|
-
beforeUpdate
|
|
514
|
-
var _a;
|
|
515
|
-
|
|
202
|
+
beforeUpdate() {
|
|
516
203
|
this.fillKeys();
|
|
517
|
-
this.diffResult =
|
|
204
|
+
this.diffResult = this.slotDiffer?.update(this.getSlots());
|
|
518
205
|
},
|
|
519
|
-
updated
|
|
520
|
-
|
|
521
|
-
|
|
206
|
+
updated() {
|
|
207
|
+
const flicking = this.vanillaFlicking;
|
|
208
|
+
const diffResult = this.diffResult;
|
|
522
209
|
this.checkPlugins();
|
|
523
210
|
this.renderEmitter.trigger("render");
|
|
524
|
-
if (!diffResult || !
|
|
525
|
-
|
|
211
|
+
if (!diffResult || !flicking?.initialized) return;
|
|
212
|
+
const children = this.getChildren();
|
|
526
213
|
sync(flicking, diffResult, children);
|
|
527
|
-
|
|
528
214
|
if (diffResult.added.length > 0 || diffResult.removed.length > 0) {
|
|
529
215
|
this.$forceUpdate();
|
|
530
216
|
}
|
|
531
|
-
|
|
532
|
-
this.diffResult = undefined;
|
|
217
|
+
this.diffResult = void 0;
|
|
533
218
|
},
|
|
534
|
-
render
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
var options = this.options;
|
|
541
|
-
var initialized = flicking && flicking.initialized;
|
|
542
|
-
var isHorizontal = flicking ? flicking.horizontal : (_b = this.options.horizontal) !== null && _b !== void 0 ? _b : true;
|
|
543
|
-
var viewportData = {
|
|
219
|
+
render() {
|
|
220
|
+
const flicking = this.vanillaFlicking;
|
|
221
|
+
const options = this.options;
|
|
222
|
+
const initialized = flicking?.initialized;
|
|
223
|
+
const isHorizontal = flicking ? flicking.horizontal : this.options.horizontal ?? true;
|
|
224
|
+
const viewportData = {
|
|
544
225
|
class: {
|
|
545
226
|
"flicking-viewport": true,
|
|
546
|
-
|
|
227
|
+
vertical: !isHorizontal,
|
|
547
228
|
"flicking-hidden": this.hideBeforeInit && !initialized
|
|
548
229
|
}
|
|
549
230
|
};
|
|
550
|
-
|
|
551
|
-
class:
|
|
552
|
-
"flicking-camera": true
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
} : {}
|
|
231
|
+
const cameraData = {
|
|
232
|
+
class: {
|
|
233
|
+
"flicking-camera": true,
|
|
234
|
+
[this.cameraClass]: !!this.cameraClass
|
|
235
|
+
},
|
|
236
|
+
style: !initialized && this.firstPanelSize ? { transform: getDefaultCameraTransform(this.options.align, this.options.horizontal, this.firstPanelSize) } : {}
|
|
557
237
|
};
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
return h(this.viewportTag, viewportData,
|
|
561
|
-
default: panels
|
|
562
|
-
})], viewportSlots, true));
|
|
238
|
+
const panels = options.virtual && options.panelsPerView && options.panelsPerView > 0 ? this.getVirtualPanels : this.getPanels;
|
|
239
|
+
const viewportSlots = this.$slots.viewport ? this.$slots.viewport() : [];
|
|
240
|
+
return h(this.viewportTag, viewportData, [h(this.cameraTag, cameraData, { default: panels }), ...viewportSlots]);
|
|
563
241
|
},
|
|
564
242
|
methods: {
|
|
565
|
-
getSlots
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
var slots = this.$slots.default ? this.$slots.default() : [];
|
|
569
|
-
return slots.reduce(function (elementSlots, slot) {
|
|
570
|
-
return __spreadArray(__spreadArray([], elementSlots, true), _this.getElementVNodes(slot), true);
|
|
571
|
-
}, []).filter(function (slot) {
|
|
572
|
-
return slot.type !== Comment && slot.type !== Text;
|
|
573
|
-
});
|
|
243
|
+
getSlots() {
|
|
244
|
+
const slots = this.$slots.default ? this.$slots.default() : [];
|
|
245
|
+
return slots.reduce((elementSlots, slot) => [...elementSlots, ...this.getElementVNodes(slot)], []).filter((slot) => slot.type !== Comment && slot.type !== Text);
|
|
574
246
|
},
|
|
575
|
-
getElementVNodes
|
|
576
|
-
var _this = this;
|
|
577
|
-
|
|
578
|
-
if (childSlots === void 0) {
|
|
579
|
-
childSlots = [];
|
|
580
|
-
}
|
|
581
|
-
|
|
247
|
+
getElementVNodes(slot, childSlots = []) {
|
|
582
248
|
if (slot.type === Fragment && Array.isArray(slot.children)) {
|
|
583
|
-
slot.children.filter(
|
|
584
|
-
return child && typeof child === "object";
|
|
585
|
-
}).forEach(function (child) {
|
|
586
|
-
return _this.getElementVNodes(child, childSlots);
|
|
587
|
-
});
|
|
249
|
+
slot.children.filter((child) => child && typeof child === "object").forEach((child) => this.getElementVNodes(child, childSlots));
|
|
588
250
|
} else {
|
|
589
251
|
childSlots.push(slot);
|
|
590
252
|
}
|
|
591
|
-
|
|
592
253
|
return childSlots;
|
|
593
254
|
},
|
|
594
|
-
bindEvents
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
events.forEach(function (eventName) {
|
|
602
|
-
flicking.on(eventName, function (e) {
|
|
603
|
-
e.currentTarget = _this; // Make events from camelCase to kebab-case
|
|
604
|
-
|
|
605
|
-
_this.$emit(eventName.replace(/([A-Z])/g, "-$1").toLowerCase(), e);
|
|
255
|
+
bindEvents() {
|
|
256
|
+
const flicking = this.vanillaFlicking;
|
|
257
|
+
const events = Object.keys(EVENTS).map((key) => EVENTS[key]);
|
|
258
|
+
events.forEach((eventName) => {
|
|
259
|
+
flicking.on(eventName, (e) => {
|
|
260
|
+
e.currentTarget = this;
|
|
261
|
+
this.$emit(eventName.replace(/([A-Z])/g, "-$1").toLowerCase(), e);
|
|
606
262
|
});
|
|
607
263
|
});
|
|
608
264
|
},
|
|
609
|
-
checkPlugins
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
list = _c.list,
|
|
614
|
-
added = _c.added,
|
|
615
|
-
removed = _c.removed,
|
|
616
|
-
prevList = _c.prevList;
|
|
617
|
-
|
|
618
|
-
(_a = this.vanillaFlicking).addPlugins.apply(_a, added.map(function (index) {
|
|
619
|
-
return list[index];
|
|
620
|
-
}));
|
|
621
|
-
|
|
622
|
-
(_b = this.vanillaFlicking).removePlugins.apply(_b, removed.map(function (index) {
|
|
623
|
-
return prevList[index];
|
|
624
|
-
}));
|
|
265
|
+
checkPlugins() {
|
|
266
|
+
const { list, added, removed, prevList } = this.pluginsDiffer.update(this.plugins);
|
|
267
|
+
this.vanillaFlicking.addPlugins(...added.map((index) => list[index]));
|
|
268
|
+
this.vanillaFlicking.removePlugins(...removed.map((index) => prevList[index]));
|
|
625
269
|
},
|
|
626
|
-
fillKeys
|
|
627
|
-
|
|
628
|
-
vnodes.forEach(
|
|
270
|
+
fillKeys() {
|
|
271
|
+
const vnodes = this.getSlots();
|
|
272
|
+
vnodes.forEach((node, idx) => {
|
|
629
273
|
if (node.key == null) {
|
|
630
|
-
node.key =
|
|
274
|
+
node.key = `$_${idx}`;
|
|
631
275
|
}
|
|
632
276
|
});
|
|
633
277
|
},
|
|
634
|
-
getChildren
|
|
635
|
-
|
|
636
|
-
return Object.keys(childRefs).map(
|
|
637
|
-
return childRefs[refKey];
|
|
638
|
-
});
|
|
278
|
+
getChildren() {
|
|
279
|
+
const childRefs = this.$refs;
|
|
280
|
+
return Object.keys(childRefs).map((refKey) => childRefs[refKey]);
|
|
639
281
|
}
|
|
640
282
|
},
|
|
641
283
|
watch: {
|
|
642
284
|
options: {
|
|
643
|
-
handler
|
|
644
|
-
|
|
645
|
-
if (!flicking) return;
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
var options = __rest(newOptions, ["virtual"]); // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
for (var key in options) {
|
|
285
|
+
handler(newOptions) {
|
|
286
|
+
const flicking = this.vanillaFlicking;
|
|
287
|
+
if (!flicking) return;
|
|
288
|
+
const { virtual, ...options } = newOptions;
|
|
289
|
+
for (const key in options) {
|
|
652
290
|
if (key in flicking && flicking[key] !== options[key]) {
|
|
653
291
|
flicking[key] = options[key];
|
|
654
292
|
}
|
|
@@ -659,17 +297,288 @@ var Flicking = defineComponent({
|
|
|
659
297
|
}
|
|
660
298
|
}
|
|
661
299
|
});
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
return
|
|
668
|
-
|
|
669
|
-
|
|
300
|
+
function keys(obj) {
|
|
301
|
+
return Object.keys(obj);
|
|
302
|
+
}
|
|
303
|
+
function camelize(str) {
|
|
304
|
+
return str.replace(/[\s-_]([a-z])/g, function(all, letter) {
|
|
305
|
+
return letter.toUpperCase();
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
function isFunction(val) {
|
|
309
|
+
return typeof val === "function";
|
|
310
|
+
}
|
|
311
|
+
var OBSERVERS_PATH = "__observers__";
|
|
312
|
+
var COMPUTED_PATH = "__computed__";
|
|
313
|
+
function __spreadArray(to, from, pack) {
|
|
314
|
+
if (arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
315
|
+
if (ar || !(i in from)) {
|
|
316
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
317
|
+
ar[i] = from[i];
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
321
|
+
}
|
|
322
|
+
function withReactiveMethods(ref2, methods) {
|
|
323
|
+
var obj = {};
|
|
324
|
+
if (!methods) {
|
|
325
|
+
return obj;
|
|
326
|
+
}
|
|
327
|
+
methods.forEach(function(name) {
|
|
328
|
+
obj[name] = function() {
|
|
329
|
+
var args = [];
|
|
330
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
331
|
+
args[_i] = arguments[_i];
|
|
332
|
+
}
|
|
333
|
+
var current = ref2.current || ref2.value;
|
|
334
|
+
return current[name].apply(current, args);
|
|
670
335
|
};
|
|
671
336
|
});
|
|
337
|
+
return obj;
|
|
338
|
+
}
|
|
339
|
+
function defineObservers(instance) {
|
|
340
|
+
var observers = {};
|
|
341
|
+
Object.defineProperty(instance, OBSERVERS_PATH, {
|
|
342
|
+
get: function() {
|
|
343
|
+
return observers;
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
return observers;
|
|
347
|
+
}
|
|
348
|
+
function getObservers(instance, isComputed) {
|
|
349
|
+
var _a, _b;
|
|
350
|
+
if (!instance[OBSERVERS_PATH]) {
|
|
351
|
+
defineObservers(instance);
|
|
352
|
+
}
|
|
353
|
+
var observers = instance[OBSERVERS_PATH];
|
|
354
|
+
{
|
|
355
|
+
var computedList = (_b = (_a = instance === null || instance === void 0 ? void 0 : instance.constructor) === null || _a === void 0 ? void 0 : _a.prototype) === null || _b === void 0 ? void 0 : _b[COMPUTED_PATH];
|
|
356
|
+
if (computedList) {
|
|
357
|
+
computedList.forEach(function(name) {
|
|
358
|
+
if (!(name in observers) && name in instance) {
|
|
359
|
+
instance[name];
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
return observers;
|
|
365
|
+
}
|
|
366
|
+
function adaptReactive(adapter, props) {
|
|
367
|
+
var objectAdapter = isFunction(adapter) ? {
|
|
368
|
+
setup: adapter
|
|
369
|
+
} : adapter;
|
|
370
|
+
function getProps() {
|
|
371
|
+
var _a, _b, _c, _d, _e;
|
|
372
|
+
return (_e = (_c = (_a = props === null || props === void 0 ? void 0 : props()) !== null && _a !== void 0 ? _a : (_b = objectAdapter.props) === null || _b === void 0 ? void 0 : _b.call(objectAdapter)) !== null && _c !== void 0 ? _c : (_d = objectAdapter.data) === null || _d === void 0 ? void 0 : _d.call(objectAdapter)) !== null && _e !== void 0 ? _e : {};
|
|
373
|
+
}
|
|
374
|
+
var eventEmitter = new Component();
|
|
375
|
+
var mountedHooks = [];
|
|
376
|
+
var initHooks = [];
|
|
377
|
+
var destroyHooks = [];
|
|
378
|
+
var onHooks = [];
|
|
379
|
+
var instanceRef = {
|
|
380
|
+
current: null
|
|
381
|
+
};
|
|
382
|
+
var offHooksList = [];
|
|
383
|
+
var initialState = null;
|
|
384
|
+
var eventNames = [];
|
|
385
|
+
var methodNames = [];
|
|
386
|
+
var onMounted2 = function(callback) {
|
|
387
|
+
mountedHooks.push(callback);
|
|
388
|
+
};
|
|
389
|
+
var onInit = function(callback) {
|
|
390
|
+
initHooks.push(callback);
|
|
391
|
+
};
|
|
392
|
+
var onDestroy = function(callback) {
|
|
393
|
+
destroyHooks.push(callback);
|
|
394
|
+
};
|
|
395
|
+
var on = function(callback) {
|
|
396
|
+
onHooks.push(callback);
|
|
397
|
+
};
|
|
398
|
+
var emit = function(eventName) {
|
|
399
|
+
var params = [];
|
|
400
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
401
|
+
params[_i - 1] = arguments[_i];
|
|
402
|
+
}
|
|
403
|
+
eventEmitter.trigger.apply(eventEmitter, __spreadArray([eventName], params, false));
|
|
404
|
+
};
|
|
405
|
+
var setInitialState = function(state) {
|
|
406
|
+
initialState = state;
|
|
407
|
+
};
|
|
408
|
+
var setEvents = function(events) {
|
|
409
|
+
eventNames = events;
|
|
410
|
+
};
|
|
411
|
+
var setMethods = function(methods) {
|
|
412
|
+
methodNames = methods;
|
|
413
|
+
};
|
|
414
|
+
if (objectAdapter.setup) {
|
|
415
|
+
instanceRef.current = objectAdapter.setup({
|
|
416
|
+
getProps,
|
|
417
|
+
setInitialState,
|
|
418
|
+
setEvents,
|
|
419
|
+
setMethods,
|
|
420
|
+
onMounted: onMounted2,
|
|
421
|
+
onDestroy,
|
|
422
|
+
onInit,
|
|
423
|
+
emit,
|
|
424
|
+
on
|
|
425
|
+
}) || null;
|
|
426
|
+
}
|
|
427
|
+
if (objectAdapter.created) {
|
|
428
|
+
instanceRef.current = objectAdapter.created(getProps()) || null;
|
|
429
|
+
}
|
|
430
|
+
if (objectAdapter.events) {
|
|
431
|
+
setEvents(objectAdapter.events);
|
|
432
|
+
}
|
|
433
|
+
if (objectAdapter.state) {
|
|
434
|
+
setInitialState(objectAdapter.state);
|
|
435
|
+
}
|
|
436
|
+
if (objectAdapter.methods) {
|
|
437
|
+
setMethods(objectAdapter.methods);
|
|
438
|
+
}
|
|
439
|
+
if (objectAdapter.mounted) {
|
|
440
|
+
onMounted2(objectAdapter.mounted);
|
|
441
|
+
}
|
|
442
|
+
if (objectAdapter.destroy) {
|
|
443
|
+
destroyHooks.push(objectAdapter.destroy);
|
|
444
|
+
}
|
|
445
|
+
if (objectAdapter.init) {
|
|
446
|
+
initHooks.push(objectAdapter.init);
|
|
447
|
+
}
|
|
448
|
+
if (objectAdapter.on) {
|
|
449
|
+
onHooks.push(function(instance, eventName, listener) {
|
|
450
|
+
var off = objectAdapter.on(instance, eventName, listener);
|
|
451
|
+
return function() {
|
|
452
|
+
var _a;
|
|
453
|
+
off && off();
|
|
454
|
+
(_a = objectAdapter.off) === null || _a === void 0 ? void 0 : _a.call(objectAdapter, instance, eventName, listener);
|
|
455
|
+
};
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
return {
|
|
459
|
+
events: function() {
|
|
460
|
+
return eventNames;
|
|
461
|
+
},
|
|
462
|
+
state: function() {
|
|
463
|
+
var inst = instanceRef.current;
|
|
464
|
+
if (initialState) {
|
|
465
|
+
return initialState;
|
|
466
|
+
}
|
|
467
|
+
if (inst) {
|
|
468
|
+
var observers_1 = getObservers(inst);
|
|
469
|
+
setInitialState(keys(observers_1).reduce(function(prev, cur) {
|
|
470
|
+
prev[cur] = observers_1[cur].current;
|
|
471
|
+
return prev;
|
|
472
|
+
}, {}));
|
|
473
|
+
}
|
|
474
|
+
return initialState || {};
|
|
475
|
+
},
|
|
476
|
+
instance: function() {
|
|
477
|
+
return instanceRef.current;
|
|
478
|
+
},
|
|
479
|
+
mounted: function() {
|
|
480
|
+
var props2 = getProps();
|
|
481
|
+
mountedHooks.forEach(function(hook) {
|
|
482
|
+
instanceRef.current = hook(props2, instanceRef.current) || instanceRef.current;
|
|
483
|
+
});
|
|
484
|
+
},
|
|
485
|
+
init: function() {
|
|
486
|
+
var instance = instanceRef.current;
|
|
487
|
+
var props2 = getProps();
|
|
488
|
+
offHooksList = eventNames.map(function(eventName) {
|
|
489
|
+
var listener = function() {
|
|
490
|
+
var _a;
|
|
491
|
+
var params = [];
|
|
492
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
493
|
+
params[_i] = arguments[_i];
|
|
494
|
+
}
|
|
495
|
+
(_a = eventEmitter).trigger.apply(_a, __spreadArray([eventName], params, false));
|
|
496
|
+
};
|
|
497
|
+
var instance2 = instanceRef.current;
|
|
498
|
+
return onHooks.map(function(hook) {
|
|
499
|
+
return hook(instance2, eventName, listener);
|
|
500
|
+
}).filter(Boolean);
|
|
501
|
+
});
|
|
502
|
+
initHooks.forEach(function(hook) {
|
|
503
|
+
hook(instance, props2);
|
|
504
|
+
});
|
|
505
|
+
},
|
|
506
|
+
destroy: function() {
|
|
507
|
+
offHooksList.forEach(function(offHooks) {
|
|
508
|
+
offHooks.forEach(function(hook) {
|
|
509
|
+
hook();
|
|
510
|
+
});
|
|
511
|
+
});
|
|
512
|
+
eventEmitter.off();
|
|
513
|
+
var instance = instanceRef.current;
|
|
514
|
+
var props2 = getProps();
|
|
515
|
+
destroyHooks.forEach(function(hook) {
|
|
516
|
+
hook(instance, props2);
|
|
517
|
+
});
|
|
518
|
+
},
|
|
519
|
+
methods: function() {
|
|
520
|
+
return withReactiveMethods(instanceRef, methodNames);
|
|
521
|
+
},
|
|
522
|
+
on: function(eventName, listener) {
|
|
523
|
+
eventEmitter.on(eventName, listener);
|
|
524
|
+
},
|
|
525
|
+
off: function(eventName, listener) {
|
|
526
|
+
eventEmitter.off(eventName, listener);
|
|
527
|
+
}
|
|
528
|
+
};
|
|
529
|
+
}
|
|
530
|
+
var __assign = function() {
|
|
531
|
+
__assign = Object.assign || function __assign2(t) {
|
|
532
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
533
|
+
s = arguments[i];
|
|
534
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
535
|
+
}
|
|
536
|
+
return t;
|
|
537
|
+
};
|
|
538
|
+
return __assign.apply(this, arguments);
|
|
539
|
+
};
|
|
540
|
+
function useReactive(reactiveAdapter, props) {
|
|
541
|
+
var adaptResult = adaptReactive(reactiveAdapter, props);
|
|
542
|
+
var reactiveState = adaptResult.state();
|
|
543
|
+
var names = Object.keys(reactiveState);
|
|
544
|
+
var refs = {};
|
|
545
|
+
for (var name in reactiveState) {
|
|
546
|
+
refs[name] = ref(reactiveState[name]);
|
|
547
|
+
}
|
|
548
|
+
var methods = adaptResult.methods();
|
|
549
|
+
onMounted(function() {
|
|
550
|
+
adaptResult.mounted();
|
|
551
|
+
var inst = adaptResult.instance();
|
|
552
|
+
names.forEach(function(name2) {
|
|
553
|
+
inst.subscribe(name2, function(value) {
|
|
554
|
+
refs[name2].value = value;
|
|
555
|
+
});
|
|
556
|
+
});
|
|
557
|
+
adaptResult.init();
|
|
558
|
+
});
|
|
559
|
+
onUnmounted(function() {
|
|
560
|
+
adaptResult.destroy();
|
|
561
|
+
});
|
|
562
|
+
var reactiveEvents = adaptResult.events();
|
|
563
|
+
var events = reactiveEvents.reduce(function(eventResult, name2) {
|
|
564
|
+
eventResult[camelize("on ".concat(name2))] = function(callback) {
|
|
565
|
+
adaptResult.on(name2, callback);
|
|
566
|
+
onUnmounted(function() {
|
|
567
|
+
adaptResult.off(name2, callback);
|
|
568
|
+
});
|
|
569
|
+
};
|
|
570
|
+
return eventResult;
|
|
571
|
+
}, {});
|
|
572
|
+
return __assign(__assign(__assign({}, refs), methods), events);
|
|
573
|
+
}
|
|
574
|
+
const useFlickingReactiveAPI = (flickingRef, options) => {
|
|
575
|
+
return useReactive(flickingReactiveAPIAdapter, () => ({
|
|
576
|
+
flicking: flickingRef.value ?? void 0,
|
|
577
|
+
options
|
|
578
|
+
}));
|
|
579
|
+
};
|
|
580
|
+
export {
|
|
581
|
+
Flicking as default,
|
|
582
|
+
useFlickingReactiveAPI
|
|
672
583
|
};
|
|
673
|
-
|
|
674
|
-
export { Flicking as default, useFlickingReactiveAPI };
|
|
675
584
|
//# sourceMappingURL=flicking.esm.js.map
|