@egjs/react-flicking 4.3.0 → 4.4.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/declaration/Flicking.d.ts +14 -7
- package/declaration/NonStrictPanel.d.ts +10 -0
- package/declaration/ReactElementProvider.d.ts +12 -0
- package/declaration/ReactRenderer.d.ts +3 -3
- package/declaration/StrictPanel.d.ts +12 -0
- package/declaration/ViewportSlot.d.ts +1 -1
- package/declaration/types.d.ts +2 -1
- package/dist/flicking.cjs.js +272 -168
- package/dist/flicking.cjs.js.map +1 -1
- package/dist/flicking.esm.js +270 -170
- package/dist/flicking.esm.js.map +1 -1
- package/package.json +4 -5
- package/src/react-flicking/Flicking.tsx +130 -48
- package/src/react-flicking/NonStrictPanel.tsx +29 -0
- package/src/react-flicking/ReactElementProvider.ts +28 -0
- package/src/react-flicking/ReactRenderer.ts +22 -24
- package/src/react-flicking/StrictPanel.tsx +36 -0
- package/src/react-flicking/ViewportSlot.tsx +5 -1
- package/src/react-flicking/consts.ts +0 -1
- package/src/react-flicking/index.umd.ts +4 -0
- package/src/react-flicking/types.ts +3 -1
- package/declaration/NonStrictPanelComponent.d.ts +0 -8
- package/declaration/ReactPanel.d.ts +0 -9
- package/declaration/ReactPanelComponent.d.ts +0 -6
- package/declaration/StrictPanelComponent.d.ts +0 -10
- package/src/react-flicking/NonStrictPanelComponent.tsx +0 -18
- package/src/react-flicking/ReactPanel.ts +0 -20
- package/src/react-flicking/ReactPanelComponent.tsx +0 -6
- package/src/react-flicking/StrictPanelComponent.tsx +0 -24
package/dist/flicking.cjs.js
CHANGED
|
@@ -4,14 +4,14 @@ 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.4.2
|
|
8
8
|
*/
|
|
9
9
|
'use strict';
|
|
10
10
|
|
|
11
11
|
var React = require('react');
|
|
12
|
+
var Component = require('@egjs/component');
|
|
12
13
|
var ListDiffer = require('@egjs/list-differ');
|
|
13
14
|
var VanillaFlicking = require('@egjs/flicking');
|
|
14
|
-
var reactIs = require('react-is');
|
|
15
15
|
var reactDom = require('react-dom');
|
|
16
16
|
|
|
17
17
|
/*! *****************************************************************************
|
|
@@ -227,7 +227,6 @@ var DEFAULT_PROPS = {
|
|
|
227
227
|
plugins: [],
|
|
228
228
|
useFindDOMNode: false,
|
|
229
229
|
hideBeforeInit: false,
|
|
230
|
-
firstPanelSize: undefined,
|
|
231
230
|
onReady: function (e) {},
|
|
232
231
|
onBeforeResize: function (e) {},
|
|
233
232
|
onAfterResize: function (e) {},
|
|
@@ -247,41 +246,9 @@ var DEFAULT_PROPS = {
|
|
|
247
246
|
onPanelChange: function (e) {}
|
|
248
247
|
};
|
|
249
248
|
|
|
250
|
-
var
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
function ReactPanel() {
|
|
254
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
var __proto = ReactPanel.prototype;
|
|
258
|
-
Object.defineProperty(__proto, "element", {
|
|
259
|
-
get: function () {
|
|
260
|
-
return this._externalComponent.element;
|
|
261
|
-
},
|
|
262
|
-
enumerable: false,
|
|
263
|
-
configurable: true
|
|
264
|
-
});
|
|
265
|
-
Object.defineProperty(__proto, "rendered", {
|
|
266
|
-
get: function () {
|
|
267
|
-
return !this._externalComponent.hide;
|
|
268
|
-
},
|
|
269
|
-
enumerable: false,
|
|
270
|
-
configurable: true
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
__proto.markForShow = function () {
|
|
274
|
-
this._externalComponent.hide = false;
|
|
275
|
-
};
|
|
276
|
-
|
|
277
|
-
__proto.markForHide = function () {
|
|
278
|
-
this._externalComponent.hide = true;
|
|
279
|
-
};
|
|
280
|
-
|
|
281
|
-
return ReactPanel;
|
|
282
|
-
}(VanillaFlicking.ExternalPanel);
|
|
283
|
-
|
|
284
|
-
var ReactRenderer = function (_super) {
|
|
249
|
+
var ReactRenderer =
|
|
250
|
+
/*#__PURE__*/
|
|
251
|
+
function (_super) {
|
|
285
252
|
__extends(ReactRenderer, _super);
|
|
286
253
|
|
|
287
254
|
function ReactRenderer(options) {
|
|
@@ -296,21 +263,18 @@ var ReactRenderer = function (_super) {
|
|
|
296
263
|
|
|
297
264
|
__proto.render = function () {
|
|
298
265
|
return __awaiter(this, void 0, void 0, function () {
|
|
299
|
-
var flicking, reactFlicking;
|
|
266
|
+
var flicking, reactFlicking, strategy;
|
|
300
267
|
return __generator(this, function (_a) {
|
|
301
|
-
flicking = this._flicking;
|
|
268
|
+
flicking = VanillaFlicking.getFlickingAttached(this._flicking);
|
|
302
269
|
reactFlicking = this._reactFlicking;
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
this._updateRenderingPanels();
|
|
308
|
-
|
|
270
|
+
strategy = this._strategy;
|
|
271
|
+
strategy.updateRenderingPanels(flicking);
|
|
272
|
+
strategy.renderPanels(flicking);
|
|
309
273
|
return [2
|
|
310
274
|
/*return*/
|
|
311
275
|
, new Promise(function (resolve) {
|
|
312
|
-
reactFlicking.
|
|
313
|
-
reactFlicking.
|
|
276
|
+
reactFlicking.renderEmitter.once("render", resolve);
|
|
277
|
+
reactFlicking.forceUpdate();
|
|
314
278
|
})];
|
|
315
279
|
});
|
|
316
280
|
});
|
|
@@ -320,163 +284,232 @@ var ReactRenderer = function (_super) {
|
|
|
320
284
|
return __awaiter(this, void 0, void 0, function () {
|
|
321
285
|
var reactFlicking;
|
|
322
286
|
return __generator(this, function (_a) {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
287
|
+
switch (_a.label) {
|
|
288
|
+
case 0:
|
|
289
|
+
reactFlicking = this._reactFlicking;
|
|
290
|
+
return [4
|
|
291
|
+
/*yield*/
|
|
292
|
+
, _super.prototype.forceRenderAllPanels.call(this)];
|
|
293
|
+
|
|
294
|
+
case 1:
|
|
295
|
+
_a.sent();
|
|
296
|
+
|
|
297
|
+
return [2
|
|
298
|
+
/*return*/
|
|
299
|
+
, new Promise(function (resolve) {
|
|
300
|
+
reactFlicking.renderEmitter.once("render", resolve);
|
|
301
|
+
reactFlicking.forceUpdate();
|
|
302
|
+
})];
|
|
303
|
+
}
|
|
338
304
|
});
|
|
339
305
|
});
|
|
340
306
|
};
|
|
341
307
|
|
|
342
308
|
__proto._collectPanels = function () {
|
|
343
|
-
var
|
|
344
|
-
|
|
345
|
-
var
|
|
346
|
-
|
|
347
|
-
var children = this._reactFlicking.reactPanels;
|
|
348
|
-
this._panels = children.map(function (panelComponent, index) {
|
|
349
|
-
return new ReactPanel({
|
|
350
|
-
flicking: _this._flicking,
|
|
351
|
-
index: index,
|
|
352
|
-
align: align,
|
|
353
|
-
externalComponent: panelComponent
|
|
354
|
-
});
|
|
355
|
-
});
|
|
309
|
+
var flicking = VanillaFlicking.getFlickingAttached(this._flicking);
|
|
310
|
+
var reactFlicking = this._reactFlicking;
|
|
311
|
+
var reactPanels = reactFlicking.reactPanels;
|
|
312
|
+
this._panels = this._strategy.collectPanels(flicking, reactPanels);
|
|
356
313
|
};
|
|
357
314
|
|
|
358
315
|
__proto._createPanel = function (externalComponent, options) {
|
|
359
|
-
return
|
|
360
|
-
externalComponent: externalComponent
|
|
361
|
-
}, options));
|
|
316
|
+
return this._strategy.createPanel(externalComponent, options);
|
|
362
317
|
};
|
|
363
318
|
|
|
364
319
|
return ReactRenderer;
|
|
365
320
|
}(VanillaFlicking.ExternalRenderer);
|
|
366
321
|
|
|
367
|
-
var
|
|
368
|
-
|
|
322
|
+
var StrictPanel =
|
|
323
|
+
/*#__PURE__*/
|
|
324
|
+
function (_super) {
|
|
325
|
+
__extends(StrictPanel, _super);
|
|
369
326
|
|
|
370
|
-
function
|
|
327
|
+
function StrictPanel() {
|
|
371
328
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
372
329
|
|
|
373
|
-
_this.
|
|
330
|
+
_this._hide = false;
|
|
331
|
+
_this._elRef = React.createRef();
|
|
374
332
|
return _this;
|
|
375
333
|
}
|
|
376
334
|
|
|
377
|
-
var __proto =
|
|
378
|
-
Object.defineProperty(__proto, "
|
|
335
|
+
var __proto = StrictPanel.prototype;
|
|
336
|
+
Object.defineProperty(__proto, "nativeElement", {
|
|
379
337
|
get: function () {
|
|
380
|
-
return
|
|
338
|
+
return this._elRef.current;
|
|
339
|
+
},
|
|
340
|
+
enumerable: false,
|
|
341
|
+
configurable: true
|
|
342
|
+
});
|
|
343
|
+
Object.defineProperty(__proto, "rendered", {
|
|
344
|
+
get: function () {
|
|
345
|
+
return !this._hide;
|
|
381
346
|
},
|
|
382
347
|
enumerable: false,
|
|
383
348
|
configurable: true
|
|
384
349
|
});
|
|
385
350
|
|
|
386
351
|
__proto.render = function () {
|
|
387
|
-
return this.
|
|
352
|
+
return this._hide ? React.createElement(React.Fragment, null) : this._getElement();
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
__proto.show = function () {
|
|
356
|
+
this._hide = false;
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
__proto.hide = function () {
|
|
360
|
+
this._hide = true;
|
|
388
361
|
};
|
|
389
362
|
|
|
390
|
-
|
|
363
|
+
__proto._getElement = function () {
|
|
364
|
+
return React.cloneElement(React.Children.only(this.props.children), {
|
|
365
|
+
ref: this._elRef
|
|
366
|
+
});
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
return StrictPanel;
|
|
391
370
|
}(React.Component);
|
|
392
371
|
|
|
393
|
-
var
|
|
394
|
-
|
|
372
|
+
var NonStrictPanel =
|
|
373
|
+
/*#__PURE__*/
|
|
374
|
+
function (_super) {
|
|
375
|
+
__extends(NonStrictPanel, _super);
|
|
395
376
|
|
|
396
|
-
function
|
|
377
|
+
function NonStrictPanel() {
|
|
397
378
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
398
379
|
|
|
399
|
-
_this.
|
|
400
|
-
_this._elRef = React.createRef();
|
|
380
|
+
_this._hide = false;
|
|
401
381
|
return _this;
|
|
402
382
|
}
|
|
403
383
|
|
|
404
|
-
var __proto =
|
|
405
|
-
Object.defineProperty(__proto, "
|
|
384
|
+
var __proto = NonStrictPanel.prototype;
|
|
385
|
+
Object.defineProperty(__proto, "nativeElement", {
|
|
406
386
|
get: function () {
|
|
407
|
-
return this
|
|
387
|
+
return reactDom.findDOMNode(this);
|
|
388
|
+
},
|
|
389
|
+
enumerable: false,
|
|
390
|
+
configurable: true
|
|
391
|
+
});
|
|
392
|
+
Object.defineProperty(__proto, "rendered", {
|
|
393
|
+
get: function () {
|
|
394
|
+
return !this._hide;
|
|
408
395
|
},
|
|
409
396
|
enumerable: false,
|
|
410
397
|
configurable: true
|
|
411
398
|
});
|
|
412
399
|
|
|
413
400
|
__proto.render = function () {
|
|
414
|
-
return this.
|
|
401
|
+
return this._hide ? React.createElement(React.Fragment, null) : this.props.children;
|
|
415
402
|
};
|
|
416
403
|
|
|
417
|
-
__proto.
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
404
|
+
__proto.show = function () {
|
|
405
|
+
this._hide = false;
|
|
406
|
+
};
|
|
407
|
+
|
|
408
|
+
__proto.hide = function () {
|
|
409
|
+
this._hide = true;
|
|
421
410
|
};
|
|
422
411
|
|
|
423
|
-
return
|
|
412
|
+
return NonStrictPanel;
|
|
424
413
|
}(React.Component);
|
|
425
414
|
|
|
426
|
-
|
|
415
|
+
/*
|
|
416
|
+
* Copyright (c) 2015 NAVER Corp.
|
|
417
|
+
* egjs projects are licensed under the MIT license
|
|
418
|
+
*/
|
|
419
|
+
var ViewportSlot = React.memo(function (_a) {
|
|
427
420
|
var children = _a.children;
|
|
428
421
|
return React.createElement(React.Fragment, null, children);
|
|
429
|
-
};
|
|
422
|
+
});
|
|
430
423
|
|
|
431
|
-
var
|
|
424
|
+
var ReactElementProvider =
|
|
425
|
+
/*#__PURE__*/
|
|
426
|
+
function () {
|
|
427
|
+
function ReactElementProvider(el) {
|
|
428
|
+
this._el = el;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
var __proto = ReactElementProvider.prototype;
|
|
432
|
+
Object.defineProperty(__proto, "element", {
|
|
433
|
+
get: function () {
|
|
434
|
+
return this._el.nativeElement;
|
|
435
|
+
},
|
|
436
|
+
enumerable: false,
|
|
437
|
+
configurable: true
|
|
438
|
+
});
|
|
439
|
+
Object.defineProperty(__proto, "rendered", {
|
|
440
|
+
get: function () {
|
|
441
|
+
return this._el.rendered;
|
|
442
|
+
},
|
|
443
|
+
enumerable: false,
|
|
444
|
+
configurable: true
|
|
445
|
+
});
|
|
446
|
+
|
|
447
|
+
__proto.show = function () {
|
|
448
|
+
this._el.show();
|
|
449
|
+
};
|
|
450
|
+
|
|
451
|
+
__proto.hide = function () {
|
|
452
|
+
this._el.hide();
|
|
453
|
+
};
|
|
454
|
+
|
|
455
|
+
return ReactElementProvider;
|
|
456
|
+
}();
|
|
457
|
+
|
|
458
|
+
var LifeCycleState;
|
|
459
|
+
|
|
460
|
+
(function (LifeCycleState) {
|
|
461
|
+
LifeCycleState[LifeCycleState["BEFORE_UPDATE"] = 0] = "BEFORE_UPDATE";
|
|
462
|
+
LifeCycleState[LifeCycleState["RENDER"] = 1] = "RENDER";
|
|
463
|
+
LifeCycleState[LifeCycleState["UPDATED"] = 2] = "UPDATED";
|
|
464
|
+
})(LifeCycleState || (LifeCycleState = {}));
|
|
465
|
+
|
|
466
|
+
var Flicking =
|
|
467
|
+
/*#__PURE__*/
|
|
468
|
+
function (_super) {
|
|
432
469
|
__extends(Flicking, _super);
|
|
433
470
|
|
|
434
471
|
function Flicking(props) {
|
|
435
472
|
var _this = _super.call(this, props) || this;
|
|
436
473
|
|
|
437
474
|
_this._panels = [];
|
|
438
|
-
_this.
|
|
439
|
-
|
|
440
|
-
|
|
475
|
+
_this._renderEmitter = new Component();
|
|
476
|
+
_this._currentState = LifeCycleState.BEFORE_UPDATE;
|
|
477
|
+
_this._panels = _this._createPanelRefs(props, _this._getChildren());
|
|
441
478
|
return _this;
|
|
442
479
|
}
|
|
443
480
|
|
|
444
481
|
var __proto = Flicking.prototype;
|
|
445
|
-
Object.defineProperty(__proto, "
|
|
482
|
+
Object.defineProperty(__proto, "reactPanels", {
|
|
446
483
|
get: function () {
|
|
447
|
-
return this.
|
|
484
|
+
return this._panels.map(function (panel) {
|
|
485
|
+
return panel.current;
|
|
486
|
+
});
|
|
448
487
|
},
|
|
449
488
|
enumerable: false,
|
|
450
489
|
configurable: true
|
|
451
490
|
});
|
|
452
|
-
Object.defineProperty(__proto, "
|
|
491
|
+
Object.defineProperty(__proto, "renderEmitter", {
|
|
453
492
|
get: function () {
|
|
454
|
-
return this.
|
|
455
|
-
return panel.current;
|
|
456
|
-
});
|
|
493
|
+
return this._renderEmitter;
|
|
457
494
|
},
|
|
458
495
|
enumerable: false,
|
|
459
496
|
configurable: true
|
|
460
497
|
});
|
|
461
498
|
|
|
462
|
-
__proto.setRenderCallback = function (callback) {
|
|
463
|
-
this._renderCallback = callback;
|
|
464
|
-
};
|
|
465
|
-
|
|
466
499
|
__proto.componentDidMount = function () {
|
|
467
|
-
this._mounted = true;
|
|
468
500
|
var props = this.props;
|
|
501
|
+
var rendererOptions = {
|
|
502
|
+
reactFlicking: this,
|
|
503
|
+
align: props.align,
|
|
504
|
+
strategy: props.virtual && props.panelsPerView > 0 ? new VanillaFlicking.VirtualRenderingStrategy() : new VanillaFlicking.NormalRenderingStrategy({
|
|
505
|
+
providerCtor: ReactElementProvider
|
|
506
|
+
})
|
|
507
|
+
};
|
|
469
508
|
var flicking = new VanillaFlicking(this._viewportElement, __assign(__assign({}, props), {
|
|
470
|
-
|
|
471
|
-
renderer: ReactRenderer,
|
|
472
|
-
rendererOptions: {
|
|
473
|
-
reactFlicking: this
|
|
474
|
-
}
|
|
475
|
-
}
|
|
509
|
+
externalRenderer: new ReactRenderer(rendererOptions)
|
|
476
510
|
}));
|
|
477
511
|
this._vanillaFlicking = flicking;
|
|
478
|
-
|
|
479
|
-
this._bindEvents();
|
|
512
|
+
this._currentState = LifeCycleState.UPDATED;
|
|
480
513
|
|
|
481
514
|
var children = this._getChildren();
|
|
482
515
|
|
|
@@ -485,55 +518,67 @@ var Flicking = function (_super) {
|
|
|
485
518
|
});
|
|
486
519
|
this._pluginsDiffer = new ListDiffer();
|
|
487
520
|
|
|
521
|
+
this._bindEvents();
|
|
522
|
+
|
|
488
523
|
this._checkPlugins();
|
|
524
|
+
|
|
525
|
+
if (props.status) {
|
|
526
|
+
flicking.setStatus(props.status);
|
|
527
|
+
}
|
|
489
528
|
};
|
|
490
529
|
|
|
491
530
|
__proto.componentWillUnmount = function () {
|
|
492
|
-
|
|
531
|
+
var _a;
|
|
493
532
|
|
|
494
|
-
this._vanillaFlicking.destroy();
|
|
533
|
+
(_a = this._vanillaFlicking) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
495
534
|
};
|
|
496
535
|
|
|
497
536
|
__proto.shouldComponentUpdate = function (nextProps) {
|
|
498
|
-
var
|
|
537
|
+
var props = this.props;
|
|
499
538
|
|
|
500
|
-
|
|
539
|
+
if (this._currentState !== LifeCycleState.BEFORE_UPDATE && props.children !== nextProps.children) {
|
|
540
|
+
var nextChildren = this._getChildren(nextProps.children);
|
|
501
541
|
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
|
|
542
|
+
this._panels = this._createPanelRefs(nextProps, nextChildren);
|
|
543
|
+
this._diffResult = this._jsxDiffer.update(nextChildren);
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
this._currentState = LifeCycleState.BEFORE_UPDATE;
|
|
547
|
+
|
|
548
|
+
for (var key in nextProps) {
|
|
549
|
+
if (props[key] !== nextProps[key]) {
|
|
550
|
+
return true;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
return false;
|
|
507
555
|
};
|
|
508
556
|
|
|
509
557
|
__proto.componentDidUpdate = function () {
|
|
510
558
|
var flicking = this._vanillaFlicking;
|
|
559
|
+
var renderEmitter = this._renderEmitter;
|
|
511
560
|
var diffResult = this._diffResult;
|
|
512
561
|
|
|
513
562
|
this._checkPlugins();
|
|
514
563
|
|
|
515
|
-
|
|
564
|
+
renderEmitter.trigger("render");
|
|
565
|
+
this._currentState = LifeCycleState.UPDATED;
|
|
516
566
|
if (!diffResult || !flicking.initialized) return;
|
|
517
567
|
VanillaFlicking.sync(flicking, diffResult, this.reactPanels);
|
|
518
|
-
|
|
519
|
-
if (diffResult.added.length > 0 || diffResult.removed.length > 0) {
|
|
520
|
-
this.setState({});
|
|
521
|
-
}
|
|
522
|
-
|
|
523
568
|
this._diffResult = null;
|
|
524
569
|
};
|
|
525
570
|
|
|
526
571
|
__proto.render = function () {
|
|
527
572
|
var _this = this;
|
|
528
573
|
|
|
529
|
-
var _a;
|
|
574
|
+
var _a, _b;
|
|
530
575
|
|
|
531
576
|
var props = this.props;
|
|
532
577
|
var Viewport = props.viewportTag;
|
|
533
578
|
var Camera = props.cameraTag;
|
|
534
579
|
var attributes = {};
|
|
535
580
|
var flicking = this._vanillaFlicking;
|
|
536
|
-
|
|
581
|
+
this._currentState = LifeCycleState.RENDER;
|
|
537
582
|
|
|
538
583
|
for (var name in props) {
|
|
539
584
|
if (!(name in DEFAULT_PROPS) && !(name in VanillaFlicking.prototype)) {
|
|
@@ -541,6 +586,7 @@ var Flicking = function (_super) {
|
|
|
541
586
|
}
|
|
542
587
|
}
|
|
543
588
|
|
|
589
|
+
var initialized = flicking && flicking.initialized;
|
|
544
590
|
var viewportClasses = ["flicking-viewport"];
|
|
545
591
|
var isHorizontal = flicking ? flicking.horizontal : (_a = props.horizontal) !== null && _a !== void 0 ? _a : true;
|
|
546
592
|
|
|
@@ -561,18 +607,7 @@ var Flicking = function (_super) {
|
|
|
561
607
|
transform: VanillaFlicking.getDefaultCameraTransform(this.props.align, this.props.horizontal, this.props.firstPanelSize)
|
|
562
608
|
}
|
|
563
609
|
} : {};
|
|
564
|
-
var
|
|
565
|
-
var panels = this.props.useFindDOMNode ? children.map(function (child, idx) {
|
|
566
|
-
return React.createElement(NonStrictPanelComponent, {
|
|
567
|
-
key: child.key,
|
|
568
|
-
ref: _this._panels[idx]
|
|
569
|
-
}, child);
|
|
570
|
-
}) : children.map(function (child, idx) {
|
|
571
|
-
return React.createElement(StrictPanelComponent, {
|
|
572
|
-
key: child.key,
|
|
573
|
-
ref: _this._panels[idx]
|
|
574
|
-
}, child);
|
|
575
|
-
});
|
|
610
|
+
var panels = !!props.virtual && ((_b = props.panelsPerView) !== null && _b !== void 0 ? _b : -1) > 0 ? this._getVirtualPanels() : this._getPanels();
|
|
576
611
|
return React.createElement(Viewport, __assign({}, attributes, {
|
|
577
612
|
className: viewportClasses.join(" "),
|
|
578
613
|
ref: function (e) {
|
|
@@ -583,6 +618,17 @@ var Flicking = function (_super) {
|
|
|
583
618
|
}, cameraProps), panels), this._getViewportSlot());
|
|
584
619
|
};
|
|
585
620
|
|
|
621
|
+
__proto._createPanelRefs = function (props, children) {
|
|
622
|
+
var _a;
|
|
623
|
+
|
|
624
|
+
var panelsPerView = (_a = props.panelsPerView) !== null && _a !== void 0 ? _a : -1;
|
|
625
|
+
return panelsPerView > 0 && !!props.virtual ? VanillaFlicking.range(panelsPerView + 1).map(function () {
|
|
626
|
+
return React.createRef();
|
|
627
|
+
}) : children.map(function () {
|
|
628
|
+
return React.createRef();
|
|
629
|
+
});
|
|
630
|
+
};
|
|
631
|
+
|
|
586
632
|
__proto._bindEvents = function () {
|
|
587
633
|
var _this = this;
|
|
588
634
|
|
|
@@ -602,19 +648,18 @@ var Flicking = function (_super) {
|
|
|
602
648
|
};
|
|
603
649
|
|
|
604
650
|
__proto._checkPlugins = function () {
|
|
605
|
-
var
|
|
651
|
+
var flicking = this._vanillaFlicking;
|
|
606
652
|
|
|
607
|
-
var
|
|
608
|
-
list =
|
|
609
|
-
added =
|
|
610
|
-
removed =
|
|
611
|
-
prevList =
|
|
653
|
+
var _a = this._pluginsDiffer.update(this.props.plugins),
|
|
654
|
+
list = _a.list,
|
|
655
|
+
added = _a.added,
|
|
656
|
+
removed = _a.removed,
|
|
657
|
+
prevList = _a.prevList;
|
|
612
658
|
|
|
613
|
-
|
|
659
|
+
flicking.addPlugins.apply(flicking, added.map(function (index) {
|
|
614
660
|
return list[index];
|
|
615
661
|
}));
|
|
616
|
-
|
|
617
|
-
(_b = this._vanillaFlicking).removePlugins.apply(_b, removed.map(function (index) {
|
|
662
|
+
flicking.removePlugins.apply(flicking, removed.map(function (index) {
|
|
618
663
|
return prevList[index];
|
|
619
664
|
}));
|
|
620
665
|
};
|
|
@@ -629,7 +674,7 @@ var Flicking = function (_super) {
|
|
|
629
674
|
return React.Children.toArray(children).filter(function (child) {
|
|
630
675
|
return child.type !== ViewportSlot;
|
|
631
676
|
}).reduce(function (all, child) {
|
|
632
|
-
return __spreadArray(__spreadArray([], all), _this._unpackFragment(child));
|
|
677
|
+
return __spreadArray(__spreadArray([], all, true), _this._unpackFragment(child), true);
|
|
633
678
|
}, []);
|
|
634
679
|
};
|
|
635
680
|
|
|
@@ -642,11 +687,66 @@ var Flicking = function (_super) {
|
|
|
642
687
|
__proto._unpackFragment = function (child) {
|
|
643
688
|
var _this = this;
|
|
644
689
|
|
|
645
|
-
return
|
|
646
|
-
return __spreadArray(__spreadArray([], allChilds), _this._unpackFragment(fragChild));
|
|
690
|
+
return this._isFragment(child) ? React.Children.toArray(child.props.children).reduce(function (allChilds, fragChild) {
|
|
691
|
+
return __spreadArray(__spreadArray([], allChilds, true), _this._unpackFragment(fragChild), true);
|
|
647
692
|
}, []) : [child];
|
|
648
693
|
};
|
|
649
694
|
|
|
695
|
+
__proto._getVirtualPanels = function () {
|
|
696
|
+
var _this = this;
|
|
697
|
+
|
|
698
|
+
var _a = this.props.virtual.panelClass,
|
|
699
|
+
panelClass = _a === void 0 ? "flicking-panel" : _a;
|
|
700
|
+
var panelsPerView = this.props.panelsPerView;
|
|
701
|
+
var flicking = this._vanillaFlicking;
|
|
702
|
+
var initialized = flicking && flicking.initialized;
|
|
703
|
+
var renderingIndexes = initialized ? flicking.renderer.strategy.getRenderingIndexesByOrder(flicking) : VanillaFlicking.range(panelsPerView + 1);
|
|
704
|
+
var firstPanel = flicking && flicking.panels[0];
|
|
705
|
+
var size = firstPanel ? flicking.horizontal ? {
|
|
706
|
+
width: firstPanel.size
|
|
707
|
+
} : {
|
|
708
|
+
height: firstPanel.size
|
|
709
|
+
} : {};
|
|
710
|
+
return renderingIndexes.map(function (idx) {
|
|
711
|
+
return React.createElement("div", {
|
|
712
|
+
key: idx,
|
|
713
|
+
"data-element-index": idx,
|
|
714
|
+
ref: _this._panels[idx],
|
|
715
|
+
className: panelClass,
|
|
716
|
+
style: size
|
|
717
|
+
});
|
|
718
|
+
});
|
|
719
|
+
};
|
|
720
|
+
|
|
721
|
+
__proto._getPanels = function () {
|
|
722
|
+
var _this = this;
|
|
723
|
+
|
|
724
|
+
var origChildren = this._getChildren();
|
|
725
|
+
|
|
726
|
+
var vanillaFlicking = this._vanillaFlicking;
|
|
727
|
+
var diffResult = this._diffResult;
|
|
728
|
+
var children = vanillaFlicking && vanillaFlicking.initialized ? diffResult ? VanillaFlicking.getRenderingPanels(vanillaFlicking, diffResult) : VanillaFlicking.getRenderingPanels(vanillaFlicking, ListDiffer.diff(origChildren, origChildren)) : origChildren;
|
|
729
|
+
return this.props.useFindDOMNode ? children.map(function (child, idx) {
|
|
730
|
+
return React.createElement(NonStrictPanel, {
|
|
731
|
+
key: child.key,
|
|
732
|
+
ref: _this._panels[idx]
|
|
733
|
+
}, child);
|
|
734
|
+
}) : children.map(function (child, idx) {
|
|
735
|
+
return React.createElement(StrictPanel, {
|
|
736
|
+
key: child.key,
|
|
737
|
+
ref: _this._panels[idx]
|
|
738
|
+
}, child);
|
|
739
|
+
});
|
|
740
|
+
};
|
|
741
|
+
|
|
742
|
+
__proto._isFragment = function (child) {
|
|
743
|
+
if (child.type) {
|
|
744
|
+
return child.type === React.Fragment;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
return child === React.Fragment;
|
|
748
|
+
};
|
|
749
|
+
|
|
650
750
|
Flicking.defaultProps = DEFAULT_PROPS;
|
|
651
751
|
|
|
652
752
|
__decorate([VanillaFlicking.withFlickingMethods], Flicking.prototype, "_vanillaFlicking", void 0);
|
|
@@ -654,6 +754,10 @@ var Flicking = function (_super) {
|
|
|
654
754
|
return Flicking;
|
|
655
755
|
}(React.Component);
|
|
656
756
|
|
|
757
|
+
/*
|
|
758
|
+
* Copyright (c) 2015 NAVER Corp.
|
|
759
|
+
* egjs projects are licensed under the MIT license
|
|
760
|
+
*/
|
|
657
761
|
Flicking.ViewportSlot = ViewportSlot;
|
|
658
762
|
|
|
659
763
|
module.exports = Flicking;
|