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