@egjs/react-flicking 4.11.3-beta.3 → 4.11.3-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/declaration/ReactRenderer.d.ts +1 -0
- package/dist/flicking.cjs.js +49 -177
- package/dist/flicking.cjs.js.map +1 -1
- package/dist/flicking.esm.js +49 -177
- package/dist/flicking.esm.js.map +1 -1
- package/dist/flicking.umd.js +49 -177
- package/dist/flicking.umd.js.map +1 -1
- package/package.json +2 -2
package/dist/flicking.esm.js
CHANGED
|
@@ -4,7 +4,7 @@ name: @egjs/react-flicking
|
|
|
4
4
|
license: MIT
|
|
5
5
|
author: NAVER Corp.
|
|
6
6
|
repository: https://github.com/naver/egjs-flicking/tree/master/packages/react-flicking
|
|
7
|
-
version: 4.
|
|
7
|
+
version: 4.11.3-beta.4
|
|
8
8
|
*/
|
|
9
9
|
import * as React from 'react';
|
|
10
10
|
import React__default from 'react';
|
|
@@ -14,7 +14,7 @@ import VanillaFlicking__default, { getFlickingAttached, ExternalRenderer, Virtua
|
|
|
14
14
|
export * from '@egjs/flicking';
|
|
15
15
|
import { findDOMNode } from 'react-dom';
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
/******************************************************************************
|
|
18
18
|
Copyright (c) Microsoft Corporation.
|
|
19
19
|
|
|
20
20
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -28,8 +28,8 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
28
28
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
29
29
|
PERFORMANCE OF THIS SOFTWARE.
|
|
30
30
|
***************************************************************************** */
|
|
31
|
-
|
|
32
31
|
/* global Reflect, Promise */
|
|
32
|
+
|
|
33
33
|
var extendStatics = function (d, b) {
|
|
34
34
|
extendStatics = Object.setPrototypeOf || {
|
|
35
35
|
__proto__: []
|
|
@@ -38,38 +38,29 @@ var extendStatics = function (d, b) {
|
|
|
38
38
|
} || function (d, b) {
|
|
39
39
|
for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
|
40
40
|
};
|
|
41
|
-
|
|
42
41
|
return extendStatics(d, b);
|
|
43
42
|
};
|
|
44
|
-
|
|
45
43
|
function __extends(d, b) {
|
|
46
44
|
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
47
45
|
extendStatics(d, b);
|
|
48
|
-
|
|
49
46
|
function __() {
|
|
50
47
|
this.constructor = d;
|
|
51
48
|
}
|
|
52
|
-
|
|
53
49
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
54
50
|
}
|
|
55
51
|
var __assign = function () {
|
|
56
52
|
__assign = Object.assign || function __assign(t) {
|
|
57
53
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
58
54
|
s = arguments[i];
|
|
59
|
-
|
|
60
55
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
61
56
|
}
|
|
62
|
-
|
|
63
57
|
return t;
|
|
64
58
|
};
|
|
65
|
-
|
|
66
59
|
return __assign.apply(this, arguments);
|
|
67
60
|
};
|
|
68
61
|
function __rest(s, e) {
|
|
69
62
|
var t = {};
|
|
70
|
-
|
|
71
63
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
72
|
-
|
|
73
64
|
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
74
65
|
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
75
66
|
}
|
|
@@ -77,8 +68,8 @@ function __rest(s, e) {
|
|
|
77
68
|
}
|
|
78
69
|
function __decorate(decorators, target, key, desc) {
|
|
79
70
|
var c = arguments.length,
|
|
80
|
-
|
|
81
|
-
|
|
71
|
+
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
72
|
+
d;
|
|
82
73
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
83
74
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
84
75
|
}
|
|
@@ -88,7 +79,6 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
88
79
|
resolve(value);
|
|
89
80
|
});
|
|
90
81
|
}
|
|
91
|
-
|
|
92
82
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
93
83
|
function fulfilled(value) {
|
|
94
84
|
try {
|
|
@@ -97,7 +87,6 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
97
87
|
reject(e);
|
|
98
88
|
}
|
|
99
89
|
}
|
|
100
|
-
|
|
101
90
|
function rejected(value) {
|
|
102
91
|
try {
|
|
103
92
|
step(generator["throw"](value));
|
|
@@ -105,28 +94,26 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
105
94
|
reject(e);
|
|
106
95
|
}
|
|
107
96
|
}
|
|
108
|
-
|
|
109
97
|
function step(result) {
|
|
110
98
|
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
111
99
|
}
|
|
112
|
-
|
|
113
100
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
114
101
|
});
|
|
115
102
|
}
|
|
116
103
|
function __generator(thisArg, body) {
|
|
117
104
|
var _ = {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
105
|
+
label: 0,
|
|
106
|
+
sent: function () {
|
|
107
|
+
if (t[0] & 1) throw t[1];
|
|
108
|
+
return t[1];
|
|
109
|
+
},
|
|
110
|
+
trys: [],
|
|
111
|
+
ops: []
|
|
122
112
|
},
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
y,
|
|
128
|
-
t,
|
|
129
|
-
g;
|
|
113
|
+
f,
|
|
114
|
+
y,
|
|
115
|
+
t,
|
|
116
|
+
g;
|
|
130
117
|
return g = {
|
|
131
118
|
next: verb(0),
|
|
132
119
|
"throw": verb(1),
|
|
@@ -134,78 +121,59 @@ function __generator(thisArg, body) {
|
|
|
134
121
|
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
135
122
|
return this;
|
|
136
123
|
}), g;
|
|
137
|
-
|
|
138
124
|
function verb(n) {
|
|
139
125
|
return function (v) {
|
|
140
126
|
return step([n, v]);
|
|
141
127
|
};
|
|
142
128
|
}
|
|
143
|
-
|
|
144
129
|
function step(op) {
|
|
145
130
|
if (f) throw new TypeError("Generator is already executing.");
|
|
146
|
-
|
|
147
|
-
while (_) try {
|
|
131
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
148
132
|
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;
|
|
149
133
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
150
|
-
|
|
151
134
|
switch (op[0]) {
|
|
152
135
|
case 0:
|
|
153
136
|
case 1:
|
|
154
137
|
t = op;
|
|
155
138
|
break;
|
|
156
|
-
|
|
157
139
|
case 4:
|
|
158
140
|
_.label++;
|
|
159
141
|
return {
|
|
160
142
|
value: op[1],
|
|
161
143
|
done: false
|
|
162
144
|
};
|
|
163
|
-
|
|
164
145
|
case 5:
|
|
165
146
|
_.label++;
|
|
166
147
|
y = op[1];
|
|
167
148
|
op = [0];
|
|
168
149
|
continue;
|
|
169
|
-
|
|
170
150
|
case 7:
|
|
171
151
|
op = _.ops.pop();
|
|
172
|
-
|
|
173
152
|
_.trys.pop();
|
|
174
|
-
|
|
175
153
|
continue;
|
|
176
|
-
|
|
177
154
|
default:
|
|
178
155
|
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
179
156
|
_ = 0;
|
|
180
157
|
continue;
|
|
181
158
|
}
|
|
182
|
-
|
|
183
159
|
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
184
160
|
_.label = op[1];
|
|
185
161
|
break;
|
|
186
162
|
}
|
|
187
|
-
|
|
188
163
|
if (op[0] === 6 && _.label < t[1]) {
|
|
189
164
|
_.label = t[1];
|
|
190
165
|
t = op;
|
|
191
166
|
break;
|
|
192
167
|
}
|
|
193
|
-
|
|
194
168
|
if (t && _.label < t[2]) {
|
|
195
169
|
_.label = t[2];
|
|
196
|
-
|
|
197
170
|
_.ops.push(op);
|
|
198
|
-
|
|
199
171
|
break;
|
|
200
172
|
}
|
|
201
|
-
|
|
202
173
|
if (t[2]) _.ops.pop();
|
|
203
|
-
|
|
204
174
|
_.trys.pop();
|
|
205
|
-
|
|
206
175
|
continue;
|
|
207
176
|
}
|
|
208
|
-
|
|
209
177
|
op = body.call(thisArg, _);
|
|
210
178
|
} catch (e) {
|
|
211
179
|
op = [6, e];
|
|
@@ -213,7 +181,6 @@ function __generator(thisArg, body) {
|
|
|
213
181
|
} finally {
|
|
214
182
|
f = t = 0;
|
|
215
183
|
}
|
|
216
|
-
|
|
217
184
|
if (op[0] & 5) throw op[1];
|
|
218
185
|
return {
|
|
219
186
|
value: op[0] ? op[1] : void 0,
|
|
@@ -258,27 +225,19 @@ var DEFAULT_PROPS = {
|
|
|
258
225
|
onPanelChange: function (e) {}
|
|
259
226
|
};
|
|
260
227
|
|
|
261
|
-
var ReactRenderer =
|
|
262
|
-
/*#__PURE__*/
|
|
263
|
-
function (_super) {
|
|
228
|
+
var ReactRenderer = /*#__PURE__*/function (_super) {
|
|
264
229
|
__extends(ReactRenderer, _super);
|
|
265
|
-
|
|
266
230
|
function ReactRenderer(options) {
|
|
267
231
|
var _this = _super.call(this, options) || this;
|
|
268
|
-
|
|
269
232
|
_this._reactFlicking = options.reactFlicking;
|
|
270
233
|
return _this;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
|
|
234
|
+
}
|
|
235
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
274
236
|
var __proto = ReactRenderer.prototype;
|
|
275
|
-
|
|
276
237
|
__proto.render = function () {
|
|
277
238
|
return __awaiter(this, void 0, void 0, function () {
|
|
278
239
|
var flicking, reactFlicking, strategy;
|
|
279
|
-
|
|
280
240
|
var _this = this;
|
|
281
|
-
|
|
282
241
|
return __generator(this, function (_a) {
|
|
283
242
|
flicking = getFlickingAttached(this._flicking);
|
|
284
243
|
reactFlicking = this._reactFlicking;
|
|
@@ -286,11 +245,10 @@ function (_super) {
|
|
|
286
245
|
this._rendering = true;
|
|
287
246
|
strategy.updateRenderingPanels(flicking);
|
|
288
247
|
strategy.renderPanels(flicking);
|
|
289
|
-
return [2
|
|
290
|
-
/*return*/
|
|
291
|
-
, new Promise(function (resolve) {
|
|
248
|
+
return [2 /*return*/, new Promise(function (resolve) {
|
|
292
249
|
reactFlicking.renderEmitter.once("render", function () {
|
|
293
250
|
_this._rendering = false;
|
|
251
|
+
_this._afterRender();
|
|
294
252
|
resolve();
|
|
295
253
|
});
|
|
296
254
|
reactFlicking.forceUpdate();
|
|
@@ -298,28 +256,19 @@ function (_super) {
|
|
|
298
256
|
});
|
|
299
257
|
});
|
|
300
258
|
};
|
|
301
|
-
|
|
302
259
|
__proto.forceRenderAllPanels = function () {
|
|
303
260
|
return __awaiter(this, void 0, void 0, function () {
|
|
304
261
|
var reactFlicking;
|
|
305
|
-
|
|
306
262
|
var _this = this;
|
|
307
|
-
|
|
308
263
|
return __generator(this, function (_a) {
|
|
309
264
|
switch (_a.label) {
|
|
310
265
|
case 0:
|
|
311
266
|
reactFlicking = this._reactFlicking;
|
|
312
267
|
this._rendering = true;
|
|
313
|
-
return [4
|
|
314
|
-
/*yield*/
|
|
315
|
-
, _super.prototype.forceRenderAllPanels.call(this)];
|
|
316
|
-
|
|
268
|
+
return [4 /*yield*/, _super.prototype.forceRenderAllPanels.call(this)];
|
|
317
269
|
case 1:
|
|
318
270
|
_a.sent();
|
|
319
|
-
|
|
320
|
-
return [2
|
|
321
|
-
/*return*/
|
|
322
|
-
, new Promise(function (resolve) {
|
|
271
|
+
return [2 /*return*/, new Promise(function (resolve) {
|
|
323
272
|
reactFlicking.renderEmitter.once("render", function () {
|
|
324
273
|
_this._rendering = false;
|
|
325
274
|
resolve();
|
|
@@ -330,34 +279,30 @@ function (_super) {
|
|
|
330
279
|
});
|
|
331
280
|
});
|
|
332
281
|
};
|
|
333
|
-
|
|
282
|
+
__proto.destroy = function () {
|
|
283
|
+
_super.prototype.destroy.call(this);
|
|
284
|
+
this._reactFlicking.renderEmitter.off("render");
|
|
285
|
+
};
|
|
334
286
|
__proto._collectPanels = function () {
|
|
335
287
|
var flicking = getFlickingAttached(this._flicking);
|
|
336
288
|
var reactFlicking = this._reactFlicking;
|
|
337
289
|
var reactPanels = reactFlicking.reactPanels;
|
|
338
290
|
this._panels = this._strategy.collectPanels(flicking, reactPanels);
|
|
339
291
|
};
|
|
340
|
-
|
|
341
292
|
__proto._createPanel = function (externalComponent, options) {
|
|
342
293
|
return this._strategy.createPanel(externalComponent, options);
|
|
343
294
|
};
|
|
344
|
-
|
|
345
295
|
return ReactRenderer;
|
|
346
296
|
}(ExternalRenderer);
|
|
347
297
|
|
|
348
|
-
var StrictPanel =
|
|
349
|
-
/*#__PURE__*/
|
|
350
|
-
function (_super) {
|
|
298
|
+
var StrictPanel = /*#__PURE__*/function (_super) {
|
|
351
299
|
__extends(StrictPanel, _super);
|
|
352
|
-
|
|
353
300
|
function StrictPanel() {
|
|
354
301
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
355
|
-
|
|
356
302
|
_this._hide = false;
|
|
357
303
|
_this._elRef = React.createRef();
|
|
358
304
|
return _this;
|
|
359
305
|
}
|
|
360
|
-
|
|
361
306
|
var __proto = StrictPanel.prototype;
|
|
362
307
|
Object.defineProperty(__proto, "nativeElement", {
|
|
363
308
|
get: function () {
|
|
@@ -373,40 +318,30 @@ function (_super) {
|
|
|
373
318
|
enumerable: false,
|
|
374
319
|
configurable: true
|
|
375
320
|
});
|
|
376
|
-
|
|
377
321
|
__proto.render = function () {
|
|
378
322
|
return this._hide ? React.createElement(React.Fragment, null) : this._getElement();
|
|
379
323
|
};
|
|
380
|
-
|
|
381
324
|
__proto.show = function () {
|
|
382
325
|
this._hide = false;
|
|
383
326
|
};
|
|
384
|
-
|
|
385
327
|
__proto.hide = function () {
|
|
386
328
|
this._hide = true;
|
|
387
329
|
};
|
|
388
|
-
|
|
389
330
|
__proto._getElement = function () {
|
|
390
331
|
return React.cloneElement(React.Children.only(this.props.children), {
|
|
391
332
|
ref: this._elRef
|
|
392
333
|
});
|
|
393
334
|
};
|
|
394
|
-
|
|
395
335
|
return StrictPanel;
|
|
396
336
|
}(React.Component);
|
|
397
337
|
|
|
398
|
-
var NonStrictPanel =
|
|
399
|
-
/*#__PURE__*/
|
|
400
|
-
function (_super) {
|
|
338
|
+
var NonStrictPanel = /*#__PURE__*/function (_super) {
|
|
401
339
|
__extends(NonStrictPanel, _super);
|
|
402
|
-
|
|
403
340
|
function NonStrictPanel() {
|
|
404
341
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
405
|
-
|
|
406
342
|
_this._hide = false;
|
|
407
343
|
return _this;
|
|
408
344
|
}
|
|
409
|
-
|
|
410
345
|
var __proto = NonStrictPanel.prototype;
|
|
411
346
|
Object.defineProperty(__proto, "nativeElement", {
|
|
412
347
|
get: function () {
|
|
@@ -422,19 +357,15 @@ function (_super) {
|
|
|
422
357
|
enumerable: false,
|
|
423
358
|
configurable: true
|
|
424
359
|
});
|
|
425
|
-
|
|
426
360
|
__proto.render = function () {
|
|
427
361
|
return this._hide ? React.createElement(React.Fragment, null) : this.props.children;
|
|
428
362
|
};
|
|
429
|
-
|
|
430
363
|
__proto.show = function () {
|
|
431
364
|
this._hide = false;
|
|
432
365
|
};
|
|
433
|
-
|
|
434
366
|
__proto.hide = function () {
|
|
435
367
|
this._hide = true;
|
|
436
368
|
};
|
|
437
|
-
|
|
438
369
|
return NonStrictPanel;
|
|
439
370
|
}(React.Component);
|
|
440
371
|
|
|
@@ -446,13 +377,10 @@ var ViewportSlot = React__default.memo(function (props) {
|
|
|
446
377
|
return React__default.createElement(React__default.Fragment, null, props.children);
|
|
447
378
|
});
|
|
448
379
|
|
|
449
|
-
var ReactElementProvider =
|
|
450
|
-
/*#__PURE__*/
|
|
451
|
-
function () {
|
|
380
|
+
var ReactElementProvider = /*#__PURE__*/function () {
|
|
452
381
|
function ReactElementProvider(el) {
|
|
453
382
|
this._el = el;
|
|
454
383
|
}
|
|
455
|
-
|
|
456
384
|
var __proto = ReactElementProvider.prototype;
|
|
457
385
|
Object.defineProperty(__proto, "element", {
|
|
458
386
|
get: function () {
|
|
@@ -468,36 +396,26 @@ function () {
|
|
|
468
396
|
enumerable: false,
|
|
469
397
|
configurable: true
|
|
470
398
|
});
|
|
471
|
-
|
|
472
399
|
__proto.show = function () {
|
|
473
400
|
this._el.show();
|
|
474
401
|
};
|
|
475
|
-
|
|
476
402
|
__proto.hide = function () {
|
|
477
403
|
this._el.hide();
|
|
478
404
|
};
|
|
479
|
-
|
|
480
405
|
return ReactElementProvider;
|
|
481
406
|
}();
|
|
482
407
|
|
|
483
|
-
var Flicking =
|
|
484
|
-
/*#__PURE__*/
|
|
485
|
-
function (_super) {
|
|
408
|
+
var Flicking = /*#__PURE__*/function (_super) {
|
|
486
409
|
__extends(Flicking, _super);
|
|
487
|
-
|
|
488
410
|
function Flicking(props) {
|
|
489
411
|
var _this = _super.call(this, props) || this;
|
|
490
|
-
|
|
491
412
|
_this._panels = [];
|
|
492
413
|
_this._renderEmitter = new Component();
|
|
493
|
-
|
|
494
414
|
var children = _this._getChildren();
|
|
495
|
-
|
|
496
415
|
_this._panels = _this._createPanelRefs(props, children);
|
|
497
416
|
_this._prevChildren = children;
|
|
498
417
|
return _this;
|
|
499
418
|
}
|
|
500
|
-
|
|
501
419
|
var __proto = Flicking.prototype;
|
|
502
420
|
Object.defineProperty(__proto, "reactPanels", {
|
|
503
421
|
get: function () {
|
|
@@ -515,7 +433,6 @@ function (_super) {
|
|
|
515
433
|
enumerable: false,
|
|
516
434
|
configurable: true
|
|
517
435
|
});
|
|
518
|
-
|
|
519
436
|
__proto.componentDidMount = function () {
|
|
520
437
|
var props = this.props;
|
|
521
438
|
var rendererOptions = {
|
|
@@ -529,123 +446,103 @@ function (_super) {
|
|
|
529
446
|
externalRenderer: new ReactRenderer(rendererOptions)
|
|
530
447
|
}));
|
|
531
448
|
this._vanillaFlicking = flicking;
|
|
532
|
-
|
|
533
449
|
var children = this._getChildren();
|
|
534
|
-
|
|
535
450
|
this._jsxDiffer = new ListDiffer(children, function (panel) {
|
|
536
451
|
return panel.key;
|
|
537
452
|
});
|
|
538
453
|
this._pluginsDiffer = new ListDiffer();
|
|
539
454
|
this._prevChildren = children;
|
|
540
|
-
|
|
541
455
|
this._bindEvents();
|
|
542
|
-
|
|
543
456
|
this._checkPlugins();
|
|
544
|
-
|
|
545
457
|
if (props.status) {
|
|
546
458
|
flicking.setStatus(props.status);
|
|
547
459
|
}
|
|
548
460
|
};
|
|
549
|
-
|
|
550
461
|
__proto.componentWillUnmount = function () {
|
|
551
462
|
var _a;
|
|
552
|
-
|
|
553
463
|
(_a = this._vanillaFlicking) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
554
464
|
};
|
|
555
|
-
|
|
556
465
|
__proto.shouldComponentUpdate = function (nextProps) {
|
|
557
466
|
var vanillaFlicking = this._vanillaFlicking;
|
|
558
467
|
var prevProps = this.props;
|
|
559
468
|
if (!vanillaFlicking || !vanillaFlicking.initialized) return false;
|
|
560
|
-
|
|
561
469
|
var children = nextProps.children,
|
|
562
|
-
|
|
563
|
-
|
|
470
|
+
restProps = __rest(nextProps, ["children"]);
|
|
564
471
|
for (var key in restProps) {
|
|
565
472
|
if (prevProps[key] !== nextProps[key]) {
|
|
566
473
|
return true;
|
|
567
474
|
}
|
|
568
475
|
}
|
|
569
|
-
|
|
570
476
|
var prevChildren = this._prevChildren;
|
|
571
|
-
|
|
572
477
|
var nextChildren = this._getChildren(children);
|
|
573
|
-
|
|
574
478
|
if (nextProps.renderOnSameKey || !this._hasSameChildren(prevChildren, nextChildren)) return true;
|
|
575
479
|
return false;
|
|
576
480
|
};
|
|
577
|
-
|
|
578
481
|
__proto.beforeRender = function () {
|
|
579
482
|
var vanillaFlicking = this._vanillaFlicking;
|
|
580
483
|
var props = this.props;
|
|
581
|
-
var prevChildren = this._prevChildren;
|
|
484
|
+
var prevChildren = this._prevChildren;
|
|
485
|
+
// Ignore updates before init, they will be updated after "ready" event's force update
|
|
582
486
|
// Also, prevent updates when another update is already queued.
|
|
583
487
|
// This usually happens when render() called twice without calling componentDidMount, like in the case of React.StrictMode.
|
|
584
|
-
|
|
585
488
|
if (!vanillaFlicking || !vanillaFlicking.initialized || this._diffResult) return;
|
|
586
|
-
|
|
587
489
|
var nextChildren = this._getChildren(props.children);
|
|
588
|
-
|
|
589
490
|
if (props.renderOnSameKey || !this._hasSameChildren(prevChildren, nextChildren)) {
|
|
590
491
|
this._panels = this._createPanelRefs(props, nextChildren);
|
|
591
492
|
this._diffResult = this._jsxDiffer.update(nextChildren);
|
|
592
493
|
this._prevChildren = nextChildren;
|
|
593
494
|
}
|
|
594
495
|
};
|
|
595
|
-
|
|
596
496
|
__proto.componentDidUpdate = function () {
|
|
597
497
|
var flicking = this._vanillaFlicking;
|
|
598
498
|
var renderEmitter = this._renderEmitter;
|
|
599
499
|
var diffResult = this._diffResult;
|
|
600
|
-
|
|
601
500
|
this._checkPlugins();
|
|
602
|
-
|
|
603
501
|
renderEmitter.trigger("render");
|
|
604
502
|
flicking.camera.updateOffset();
|
|
503
|
+
// Omit 'virtual', as it can't have any setter
|
|
504
|
+
var _a = this.props;
|
|
505
|
+
_a.virtual;
|
|
506
|
+
var props = __rest(_a, ["virtual"]);
|
|
507
|
+
for (var key in props) {
|
|
508
|
+
if (key in flicking && flicking[key] !== props[key]) {
|
|
509
|
+
flicking[key] = props[key];
|
|
510
|
+
}
|
|
511
|
+
}
|
|
605
512
|
if (!diffResult || !flicking.initialized) return;
|
|
606
513
|
sync(flicking, diffResult, this.reactPanels);
|
|
607
514
|
this._diffResult = null;
|
|
608
515
|
};
|
|
609
|
-
|
|
610
516
|
__proto.render = function () {
|
|
611
517
|
var _this = this;
|
|
612
|
-
|
|
613
518
|
var _a, _b;
|
|
614
|
-
|
|
615
519
|
var props = this.props;
|
|
616
520
|
var Viewport = props.viewportTag;
|
|
617
521
|
var Camera = props.cameraTag;
|
|
618
522
|
var attributes = {};
|
|
619
523
|
var flicking = this._vanillaFlicking;
|
|
620
524
|
this.beforeRender();
|
|
621
|
-
|
|
622
525
|
for (var name in props) {
|
|
623
526
|
if (!(name in DEFAULT_PROPS) && !(name in VanillaFlicking__default.prototype)) {
|
|
624
527
|
attributes[name] = props[name];
|
|
625
528
|
}
|
|
626
529
|
}
|
|
627
|
-
|
|
628
530
|
var initialized = flicking && flicking.initialized;
|
|
629
531
|
var viewportClasses = ["flicking-viewport"];
|
|
630
532
|
var cameraClasses = ["flicking-camera"];
|
|
631
533
|
var isHorizontal = flicking ? flicking.horizontal : (_a = props.horizontal) !== null && _a !== void 0 ? _a : true;
|
|
632
|
-
|
|
633
534
|
if (!isHorizontal) {
|
|
634
535
|
viewportClasses.push("vertical");
|
|
635
536
|
}
|
|
636
|
-
|
|
637
537
|
if (props.hideBeforeInit && !initialized) {
|
|
638
538
|
viewportClasses.push("flicking-hidden");
|
|
639
539
|
}
|
|
640
|
-
|
|
641
540
|
if (attributes.className) {
|
|
642
541
|
viewportClasses.push(attributes.className);
|
|
643
542
|
}
|
|
644
|
-
|
|
645
543
|
if (props.cameraClass) {
|
|
646
544
|
cameraClasses.push(props.cameraClass);
|
|
647
545
|
}
|
|
648
|
-
|
|
649
546
|
var cameraProps = !initialized && props.firstPanelSize ? {
|
|
650
547
|
style: {
|
|
651
548
|
transform: getDefaultCameraTransform(this.props.align, this.props.horizontal, this.props.firstPanelSize)
|
|
@@ -661,10 +558,8 @@ function (_super) {
|
|
|
661
558
|
className: cameraClasses.join(" ")
|
|
662
559
|
}, cameraProps), panels), this._getViewportSlot());
|
|
663
560
|
};
|
|
664
|
-
|
|
665
561
|
__proto._createPanelRefs = function (props, children) {
|
|
666
562
|
var _a;
|
|
667
|
-
|
|
668
563
|
var panelsPerView = (_a = props.panelsPerView) !== null && _a !== void 0 ? _a : -1;
|
|
669
564
|
return panelsPerView > 0 && !!props.virtual ? range(panelsPerView + 1).map(function () {
|
|
670
565
|
return React.createRef();
|
|
@@ -672,10 +567,8 @@ function (_super) {
|
|
|
672
567
|
return React.createRef();
|
|
673
568
|
});
|
|
674
569
|
};
|
|
675
|
-
|
|
676
570
|
__proto._bindEvents = function () {
|
|
677
571
|
var _this = this;
|
|
678
|
-
|
|
679
572
|
var flicking = this._vanillaFlicking;
|
|
680
573
|
Object.keys(EVENTS).forEach(function (eventKey) {
|
|
681
574
|
var eventName = EVENTS[eventKey];
|
|
@@ -690,16 +583,13 @@ function (_super) {
|
|
|
690
583
|
_this.forceUpdate();
|
|
691
584
|
});
|
|
692
585
|
};
|
|
693
|
-
|
|
694
586
|
__proto._checkPlugins = function () {
|
|
695
587
|
var flicking = this._vanillaFlicking;
|
|
696
|
-
|
|
697
588
|
var _a = this._pluginsDiffer.update(this.props.plugins),
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
589
|
+
list = _a.list,
|
|
590
|
+
added = _a.added,
|
|
591
|
+
removed = _a.removed,
|
|
592
|
+
prevList = _a.prevList;
|
|
703
593
|
flicking.addPlugins.apply(flicking, added.map(function (index) {
|
|
704
594
|
return list[index];
|
|
705
595
|
}));
|
|
@@ -707,12 +597,10 @@ function (_super) {
|
|
|
707
597
|
return prevList[index];
|
|
708
598
|
}));
|
|
709
599
|
};
|
|
710
|
-
|
|
711
600
|
__proto._hasSameChildren = function (prevChildren, nextChildren) {
|
|
712
601
|
if (prevChildren.length !== nextChildren.length || prevChildren.length === 0) return false;
|
|
713
602
|
var same = prevChildren.every(function (child, idx) {
|
|
714
603
|
var nextChild = nextChildren[idx];
|
|
715
|
-
|
|
716
604
|
if (child.key && nextChild.key) {
|
|
717
605
|
return child.key === nextChild.key;
|
|
718
606
|
} else {
|
|
@@ -721,40 +609,32 @@ function (_super) {
|
|
|
721
609
|
});
|
|
722
610
|
return same;
|
|
723
611
|
};
|
|
724
|
-
|
|
725
612
|
__proto._getChildren = function (children) {
|
|
726
613
|
var _this = this;
|
|
727
|
-
|
|
728
614
|
if (children === void 0) {
|
|
729
615
|
children = this.props.children;
|
|
730
616
|
}
|
|
731
|
-
|
|
732
617
|
return React.Children.toArray(children).filter(function (child) {
|
|
733
618
|
return child.type !== ViewportSlot;
|
|
734
619
|
}).reduce(function (all, child) {
|
|
735
620
|
return __spreadArray(__spreadArray([], all, true), _this._unpackFragment(child), true);
|
|
736
621
|
}, []);
|
|
737
622
|
};
|
|
738
|
-
|
|
739
623
|
__proto._getViewportSlot = function () {
|
|
740
624
|
return React.Children.toArray(this.props.children).filter(function (child) {
|
|
741
625
|
return child.type === ViewportSlot;
|
|
742
626
|
});
|
|
743
627
|
};
|
|
744
|
-
|
|
745
628
|
__proto._unpackFragment = function (child) {
|
|
746
629
|
var _this = this;
|
|
747
|
-
|
|
748
630
|
return this._isFragment(child) ? React.Children.toArray(child.props.children).reduce(function (allChilds, fragChild) {
|
|
749
631
|
return __spreadArray(__spreadArray([], allChilds, true), _this._unpackFragment(fragChild), true);
|
|
750
632
|
}, []) : [child];
|
|
751
633
|
};
|
|
752
|
-
|
|
753
634
|
__proto._getVirtualPanels = function () {
|
|
754
635
|
var _this = this;
|
|
755
|
-
|
|
756
636
|
var _a = this.props.virtual.panelClass,
|
|
757
|
-
|
|
637
|
+
panelClass = _a === void 0 ? "flicking-panel" : _a;
|
|
758
638
|
var panelsPerView = this.props.panelsPerView;
|
|
759
639
|
var flicking = this._vanillaFlicking;
|
|
760
640
|
var initialized = flicking && flicking.initialized;
|
|
@@ -775,12 +655,9 @@ function (_super) {
|
|
|
775
655
|
});
|
|
776
656
|
});
|
|
777
657
|
};
|
|
778
|
-
|
|
779
658
|
__proto._getPanels = function () {
|
|
780
659
|
var _this = this;
|
|
781
|
-
|
|
782
660
|
var origChildren = this._getChildren();
|
|
783
|
-
|
|
784
661
|
var vanillaFlicking = this._vanillaFlicking;
|
|
785
662
|
var diffResult = this._diffResult;
|
|
786
663
|
var children = vanillaFlicking && vanillaFlicking.initialized ? diffResult ? getRenderingPanels(vanillaFlicking, diffResult) : getRenderingPanels(vanillaFlicking, diff(origChildren, origChildren)) : origChildren;
|
|
@@ -796,19 +673,14 @@ function (_super) {
|
|
|
796
673
|
}, child);
|
|
797
674
|
});
|
|
798
675
|
};
|
|
799
|
-
|
|
800
676
|
__proto._isFragment = function (child) {
|
|
801
677
|
if (child.type) {
|
|
802
678
|
return child.type === React.Fragment;
|
|
803
679
|
}
|
|
804
|
-
|
|
805
680
|
return child === React.Fragment;
|
|
806
681
|
};
|
|
807
|
-
|
|
808
682
|
Flicking.defaultProps = DEFAULT_PROPS;
|
|
809
|
-
|
|
810
683
|
__decorate([withFlickingMethods], Flicking.prototype, "_vanillaFlicking", void 0);
|
|
811
|
-
|
|
812
684
|
return Flicking;
|
|
813
685
|
}(React.Component);
|
|
814
686
|
|