@egjs/flicking 4.5.1 → 4.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,7 @@ name: @egjs/flicking
4
4
  license: MIT
5
5
  author: NAVER Corp.
6
6
  repository: https://github.com/naver/egjs-flicking
7
- version: 4.5.1
7
+ version: 4.6.0
8
8
  */
9
9
  import Component, { ComponentEvent } from '@egjs/component';
10
10
  import Axes, { PanInput } from '@egjs/axes';
@@ -969,6 +969,33 @@ function () {
969
969
  var _this = this;
970
970
 
971
971
  this._onResize = function () {
972
+ var flicking = _this._flicking;
973
+ var resizeDebounce = flicking.resizeDebounce;
974
+ var maxResizeDebounce = flicking.maxResizeDebounce;
975
+
976
+ if (resizeDebounce <= 0) {
977
+ void flicking.resize();
978
+ } else {
979
+ if (_this._maxResizeDebounceTimer <= 0) {
980
+ if (maxResizeDebounce > 0 && maxResizeDebounce >= resizeDebounce) {
981
+ _this._maxResizeDebounceTimer = window.setTimeout(_this._doScheduledResize, maxResizeDebounce);
982
+ }
983
+ }
984
+
985
+ if (_this._resizeTimer > 0) {
986
+ clearTimeout(_this._resizeTimer);
987
+ _this._resizeTimer = 0;
988
+ }
989
+
990
+ _this._resizeTimer = window.setTimeout(_this._doScheduledResize, resizeDebounce);
991
+ }
992
+ };
993
+
994
+ this._doScheduledResize = function () {
995
+ clearTimeout(_this._resizeTimer);
996
+ clearTimeout(_this._maxResizeDebounceTimer);
997
+ _this._maxResizeDebounceTimer = -1;
998
+ _this._resizeTimer = -1;
972
999
  void _this._flicking.resize();
973
1000
  }; // eslint-disable-next-line @typescript-eslint/member-ordering
974
1001
 
@@ -988,6 +1015,8 @@ function () {
988
1015
  this._flicking = flicking;
989
1016
  this._enabled = false;
990
1017
  this._resizeObserver = null;
1018
+ this._resizeTimer = -1;
1019
+ this._maxResizeDebounceTimer = -1;
991
1020
  }
992
1021
 
993
1022
  var __proto = AutoResizer.prototype;
@@ -4038,7 +4067,7 @@ var Camera =
4038
4067
  /*#__PURE__*/
4039
4068
  function () {
4040
4069
  /** */
4041
- function Camera(_a) {
4070
+ function Camera(flicking, _a) {
4042
4071
  var _this = this;
4043
4072
 
4044
4073
  var _b = (_a === void 0 ? {} : _a).align,
@@ -4078,7 +4107,7 @@ function () {
4078
4107
  _this._transform = transformName;
4079
4108
  };
4080
4109
 
4081
- this._flicking = null;
4110
+ this._flicking = flicking;
4082
4111
 
4083
4112
  this._resetInternalValues(); // Options
4084
4113
 
@@ -4373,17 +4402,14 @@ function () {
4373
4402
  /**
4374
4403
  * Initialize Camera
4375
4404
  * @ko Camera를 초기화합니다
4376
- * @param {Flicking} flicking An instance of {@link Flicking}<ko>Flicking의 인스턴스</ko>
4377
- * @chainable
4378
4405
  * @throws {FlickingError}
4379
4406
  * {@link ERROR_CODE VAL_MUST_NOT_NULL} If the camera element(`.flicking-camera`) does not exist inside viewport element
4380
4407
  * <ko>{@link ERROR_CODE VAL_MUST_NOT_NULL} 뷰포트 엘리먼트 내부에 카메라 엘리먼트(`.flicking-camera`)가 존재하지 않을 경우</ko>
4381
4408
  * @return {this}
4382
4409
  */
4383
4410
 
4384
- __proto.init = function (flicking) {
4385
- this._flicking = flicking;
4386
- var viewportEl = flicking.viewport.element;
4411
+ __proto.init = function () {
4412
+ var viewportEl = this._flicking.viewport.element;
4387
4413
  checkExistence(viewportEl.firstElementChild, "First element child of the viewport element");
4388
4414
  this._el = viewportEl.firstElementChild;
4389
4415
 
@@ -4401,8 +4427,6 @@ function () {
4401
4427
 
4402
4428
 
4403
4429
  __proto.destroy = function () {
4404
- this._flicking = null;
4405
-
4406
4430
  this._resetInternalValues();
4407
4431
 
4408
4432
  return this;
@@ -4433,12 +4457,12 @@ function () {
4433
4457
 
4434
4458
  this._checkReachEnd(prevPos, pos);
4435
4459
 
4436
- this.applyTransform();
4437
-
4438
4460
  if (toggled) {
4439
4461
  void flicking.renderer.render().then(function () {
4440
4462
  _this.updateOffset();
4441
4463
  });
4464
+ } else {
4465
+ this.applyTransform();
4442
4466
  }
4443
4467
  };
4444
4468
  /**
@@ -4625,7 +4649,6 @@ function () {
4625
4649
  });
4626
4650
  }
4627
4651
 
4628
- this.updateOffset();
4629
4652
  return this;
4630
4653
  };
4631
4654
  /**
@@ -4717,7 +4740,6 @@ function () {
4717
4740
  /**
4718
4741
  * Apply "transform" style with the current position to camera element
4719
4742
  * @ko 현재 위치를 기준으로한 transform 스타일을 카메라 엘리먼트에 적용합니다.
4720
- * @chainable
4721
4743
  * @return {this}
4722
4744
  */
4723
4745
 
@@ -4725,6 +4747,8 @@ function () {
4725
4747
  __proto.applyTransform = function () {
4726
4748
  var el = this._el;
4727
4749
  var flicking = getFlickingAttached(this._flicking);
4750
+ var renderer = flicking.renderer;
4751
+ if (renderer.rendering) return this;
4728
4752
  var actualPosition = this._position - this._alignPos - this._offset + this._circularOffset;
4729
4753
  el.style[this._transform] = flicking.horizontal ? "translate(" + -actualPosition + "px)" : "translate(0, " + -actualPosition + "px)";
4730
4754
  return this;
@@ -4897,7 +4921,8 @@ function () {
4897
4921
  align = _b === void 0 ? ALIGN.CENTER : _b,
4898
4922
  strategy = _a.strategy;
4899
4923
  this._flicking = null;
4900
- this._panels = []; // Bind options
4924
+ this._panels = [];
4925
+ this._rendering = false; // Bind options
4901
4926
 
4902
4927
  this._align = align;
4903
4928
  this._strategy = strategy;
@@ -4920,6 +4945,20 @@ function () {
4920
4945
  enumerable: false,
4921
4946
  configurable: true
4922
4947
  });
4948
+ Object.defineProperty(__proto, "rendering", {
4949
+ /**
4950
+ * A boolean value indicating whether rendering is in progress
4951
+ * @ko 현재 렌더링이 시작되어 끝나기 전까지의 상태인지의 여부
4952
+ * @type {boolean}
4953
+ * @readonly
4954
+ * @internal
4955
+ */
4956
+ get: function () {
4957
+ return this._rendering;
4958
+ },
4959
+ enumerable: false,
4960
+ configurable: true
4961
+ });
4923
4962
  Object.defineProperty(__proto, "panelCount", {
4924
4963
  /**
4925
4964
  * Count of panels
@@ -5051,6 +5090,25 @@ function () {
5051
5090
 
5052
5091
 
5053
5092
  __proto.batchInsert = function () {
5093
+ var items = [];
5094
+
5095
+ for (var _i = 0; _i < arguments.length; _i++) {
5096
+ items[_i] = arguments[_i];
5097
+ }
5098
+
5099
+ var allPanelsInserted = this.batchInsertDefer.apply(this, __spread(items));
5100
+ if (allPanelsInserted.length <= 0) return [];
5101
+ this.updateAfterPanelChange(allPanelsInserted, []);
5102
+ return allPanelsInserted;
5103
+ };
5104
+ /**
5105
+ * Defers update
5106
+ * camera position & others will be updated after calling updateAfterPanelChange
5107
+ * @internal
5108
+ */
5109
+
5110
+
5111
+ __proto.batchInsertDefer = function () {
5054
5112
  var _this = this;
5055
5113
 
5056
5114
  var items = [];
@@ -5061,7 +5119,6 @@ function () {
5061
5119
 
5062
5120
  var panels = this._panels;
5063
5121
  var flicking = getFlickingAttached(this._flicking);
5064
- var control = flicking.control;
5065
5122
  var prevFirstPanel = panels[0];
5066
5123
  var align = parsePanelAlign(this._align);
5067
5124
  var allPanelsInserted = items.reduce(function (addedPanels, item) {
@@ -5101,27 +5158,6 @@ function () {
5101
5158
  });
5102
5159
  return __spread(addedPanels, panelsInserted);
5103
5160
  }, []);
5104
- if (allPanelsInserted.length <= 0) return []; // Update camera & control
5105
-
5106
- this._updateCameraAndControl();
5107
-
5108
- void this.render(); // Move to the first panel added if no panels existed
5109
- // FIXME: fix for animating case
5110
-
5111
- if (allPanelsInserted.length > 0 && !control.animating) {
5112
- void control.moveToPanel(control.activePanel || allPanelsInserted[0], {
5113
- duration: 0
5114
- }).catch(function () {
5115
- return void 0;
5116
- });
5117
- }
5118
-
5119
- flicking.camera.updateOffset();
5120
- flicking.trigger(new ComponentEvent(EVENTS.PANEL_CHANGE, {
5121
- added: allPanelsInserted,
5122
- removed: []
5123
- }));
5124
- this.checkPanelContentsReady(allPanelsInserted);
5125
5161
  return allPanelsInserted;
5126
5162
  };
5127
5163
  /**
@@ -5138,6 +5174,25 @@ function () {
5138
5174
 
5139
5175
 
5140
5176
  __proto.batchRemove = function () {
5177
+ var items = [];
5178
+
5179
+ for (var _i = 0; _i < arguments.length; _i++) {
5180
+ items[_i] = arguments[_i];
5181
+ }
5182
+
5183
+ var allPanelsRemoved = this.batchRemoveDefer.apply(this, __spread(items));
5184
+ if (allPanelsRemoved.length <= 0) return [];
5185
+ this.updateAfterPanelChange([], allPanelsRemoved);
5186
+ return allPanelsRemoved;
5187
+ };
5188
+ /**
5189
+ * Defers update
5190
+ * camera position & others will be updated after calling updateAfterPanelChange
5191
+ * @internal
5192
+ */
5193
+
5194
+
5195
+ __proto.batchRemoveDefer = function () {
5141
5196
  var _this = this;
5142
5197
 
5143
5198
  var items = [];
@@ -5148,10 +5203,8 @@ function () {
5148
5203
 
5149
5204
  var panels = this._panels;
5150
5205
  var flicking = getFlickingAttached(this._flicking);
5151
- var camera = flicking.camera,
5152
- control = flicking.control;
5206
+ var control = flicking.control;
5153
5207
  var activePanel = control.activePanel;
5154
- var activeIndex = control.activeIndex;
5155
5208
  var allPanelsRemoved = items.reduce(function (removed, item) {
5156
5209
  var index = item.index,
5157
5210
  deleteCount = item.deleteCount;
@@ -5179,33 +5232,61 @@ function () {
5179
5232
  }
5180
5233
 
5181
5234
  return __spread(removed, panelsRemoved);
5182
- }, []); // Update camera & control
5235
+ }, []);
5236
+ return allPanelsRemoved;
5237
+ };
5238
+ /**
5239
+ * @internal
5240
+ */
5241
+
5242
+
5243
+ __proto.updateAfterPanelChange = function (panelsAdded, panelsRemoved) {
5244
+ var _a;
5245
+
5246
+ var flicking = getFlickingAttached(this._flicking);
5247
+ var camera = flicking.camera,
5248
+ control = flicking.control;
5249
+ var panels = this._panels;
5250
+ var activePanel = control.activePanel; // Update camera & control
5183
5251
 
5184
5252
  this._updateCameraAndControl();
5185
5253
 
5186
- void this.render(); // FIXME: fix for animating case
5254
+ void this.render();
5187
5255
 
5188
- if (allPanelsRemoved.length > 0 && !control.animating) {
5189
- var targetPanel = includes(allPanelsRemoved, activePanel) ? panels[activeIndex] || panels[panels.length - 1] : activePanel;
5256
+ if (!activePanel || activePanel.removed) {
5257
+ if (panels.length <= 0) {
5258
+ // All panels removed
5259
+ camera.lookAt(0);
5260
+ } else {
5261
+ var targetIndex = (_a = activePanel === null || activePanel === void 0 ? void 0 : activePanel.index) !== null && _a !== void 0 ? _a : 0;
5190
5262
 
5191
- if (targetPanel) {
5192
- void control.moveToPanel(targetPanel, {
5263
+ if (targetIndex > panels.length - 1) {
5264
+ targetIndex = panels.length - 1;
5265
+ }
5266
+
5267
+ void control.moveToPanel(panels[targetIndex], {
5193
5268
  duration: 0
5194
5269
  }).catch(function () {
5195
5270
  return void 0;
5196
5271
  });
5197
- } else {
5198
- // All panels removed
5199
- camera.lookAt(0);
5200
5272
  }
5273
+ } else {
5274
+ void control.moveToPanel(control.activePanel, {
5275
+ duration: 0
5276
+ }).catch(function () {
5277
+ return void 0;
5278
+ });
5201
5279
  }
5202
5280
 
5203
5281
  flicking.camera.updateOffset();
5204
- flicking.trigger(new ComponentEvent(EVENTS.PANEL_CHANGE, {
5205
- added: [],
5206
- removed: allPanelsRemoved
5207
- }));
5208
- return allPanelsRemoved;
5282
+
5283
+ if (panelsAdded.length > 0 || panelsRemoved.length > 0) {
5284
+ flicking.trigger(new ComponentEvent(EVENTS.PANEL_CHANGE, {
5285
+ added: panelsAdded,
5286
+ removed: panelsRemoved
5287
+ }));
5288
+ this.checkPanelContentsReady(__spread(panelsAdded, panelsRemoved));
5289
+ }
5209
5290
  };
5210
5291
  /**
5211
5292
  * @internal
@@ -5250,6 +5331,7 @@ function () {
5250
5331
  });
5251
5332
  if (!flicking.initialized) return;
5252
5333
  camera.updateRange();
5334
+ camera.updateOffset();
5253
5335
  camera.updateAnchors();
5254
5336
 
5255
5337
  if (control.animating) ; else {
@@ -5283,6 +5365,7 @@ function () {
5283
5365
  var camera = flicking.camera,
5284
5366
  control = flicking.control;
5285
5367
  camera.updateRange();
5368
+ camera.updateOffset();
5286
5369
  camera.updateAnchors();
5287
5370
  camera.resetNeedPanelHistory();
5288
5371
  control.updateInput();
@@ -6567,10 +6650,14 @@ function (_super) {
6567
6650
  autoResize = _4 === void 0 ? true : _4,
6568
6651
  _5 = _b.useResizeObserver,
6569
6652
  useResizeObserver = _5 === void 0 ? true : _5,
6570
- _6 = _b.externalRenderer,
6571
- externalRenderer = _6 === void 0 ? null : _6,
6572
- _7 = _b.renderExternal,
6573
- renderExternal = _7 === void 0 ? null : _7;
6653
+ _6 = _b.resizeDebounce,
6654
+ resizeDebounce = _6 === void 0 ? 0 : _6,
6655
+ _7 = _b.maxResizeDebounce,
6656
+ maxResizeDebounce = _7 === void 0 ? 100 : _7,
6657
+ _8 = _b.externalRenderer,
6658
+ externalRenderer = _8 === void 0 ? null : _8,
6659
+ _9 = _b.renderExternal,
6660
+ renderExternal = _9 === void 0 ? null : _9;
6574
6661
 
6575
6662
  var _this = _super.call(this) || this; // Internal states
6576
6663
 
@@ -6606,6 +6693,8 @@ function (_super) {
6606
6693
  _this._autoInit = autoInit;
6607
6694
  _this._autoResize = autoResize;
6608
6695
  _this._useResizeObserver = useResizeObserver;
6696
+ _this._resizeDebounce = resizeDebounce;
6697
+ _this._maxResizeDebounce = maxResizeDebounce;
6609
6698
  _this._externalRenderer = externalRenderer;
6610
6699
  _this._renderExternal = renderExternal; // Create core components
6611
6700
 
@@ -7454,6 +7543,38 @@ function (_super) {
7454
7543
  enumerable: false,
7455
7544
  configurable: true
7456
7545
  });
7546
+ Object.defineProperty(__proto, "resizeDebounce", {
7547
+ /**
7548
+ * Delays size recalculation from `autoResize` by the given time in milisecond.
7549
+ * If the size is changed again while being delayed, it cancels the previous one and delays from the beginning again.
7550
+ * This can increase performance by preventing `resize` being called too often.
7551
+ * @ko `autoResize` 설정시에 호출되는 크기 재계산을 주어진 시간(단위: ms)만큼 지연시킵니다.
7552
+ * 지연시키는 도중 크기가 다시 변경되었을 경우, 이전 것을 취소하고 주어진 시간만큼 다시 지연시킵니다.
7553
+ * 이를 통해 `resize`가 너무 많이 호출되는 것을 방지하여 성능을 향상시킬 수 있습니다.
7554
+ * @type {number}
7555
+ * @default 0
7556
+ */
7557
+ get: function () {
7558
+ return this._resizeDebounce;
7559
+ },
7560
+ enumerable: false,
7561
+ configurable: true
7562
+ });
7563
+ Object.defineProperty(__proto, "maxResizeDebounce", {
7564
+ /**
7565
+ * The maximum time for size recalculation delay when using `resizeDebounce`, in milisecond.
7566
+ * This guarantees that size recalculation is performed at least once every (n)ms.
7567
+ * @ko `resizeDebounce` 사용시에 크기 재계산이 지연되는 최대 시간을 지정합니다. (단위: ms)
7568
+ * 이를 통해, 적어도 (n)ms에 한번은 크기 재계산을 수행하는 것을 보장할 수 있습니다.
7569
+ * @type {number}
7570
+ * @default 100
7571
+ */
7572
+ get: function () {
7573
+ return this._maxResizeDebounce;
7574
+ },
7575
+ enumerable: false,
7576
+ configurable: true
7577
+ });
7457
7578
  Object.defineProperty(__proto, "externalRenderer", {
7458
7579
  /**
7459
7580
  * This is an option for the frameworks(React, Vue, Angular, ...). Don't set it as it's automatically managed by Flicking.
@@ -7489,85 +7610,61 @@ function (_super) {
7489
7610
  * @ko Flicking을 초기화하고, 디폴트 인덱스로 이동합니다
7490
7611
  * 이 메소드는 `autoInit` 옵션이 true(default)일 경우 Flicking이 생성될 때 자동으로 호출됩니다
7491
7612
  * @fires Flicking#ready
7492
- * @return {this}
7613
+ * @return {Promise<void>}
7493
7614
  */
7494
7615
 
7495
7616
  __proto.init = function () {
7496
- return __awaiter(this, void 0, void 0, function () {
7497
- var camera, renderer, control, virtualManager, originalTrigger, preventEventsBeforeInit;
7498
-
7499
- var _this = this;
7500
-
7501
- return __generator(this, function (_a) {
7502
- switch (_a.label) {
7503
- case 0:
7504
- if (this._initialized) return [2
7505
- /*return*/
7506
- ];
7507
- camera = this._camera;
7508
- renderer = this._renderer;
7509
- control = this._control;
7510
- virtualManager = this._virtualManager;
7511
- originalTrigger = this.trigger;
7512
- preventEventsBeforeInit = this._preventEventsBeforeInit;
7513
- camera.init(this);
7514
- virtualManager.init();
7515
- renderer.init(this);
7516
- control.init(this);
7517
-
7518
- if (preventEventsBeforeInit) {
7519
- this.trigger = function () {
7520
- return _this;
7521
- };
7522
- }
7523
-
7524
- return [4
7525
- /*yield*/
7526
- , this.resize()];
7527
-
7528
- case 1:
7529
- _a.sent(); // Look at initial panel
7530
-
7617
+ var _this = this;
7531
7618
 
7532
- return [4
7533
- /*yield*/
7534
- , this._moveToInitialPanel()];
7619
+ if (this._initialized) return Promise.resolve();
7620
+ var camera = this._camera;
7621
+ var renderer = this._renderer;
7622
+ var control = this._control;
7623
+ var virtualManager = this._virtualManager;
7624
+ var originalTrigger = this.trigger;
7625
+ var preventEventsBeforeInit = this._preventEventsBeforeInit;
7626
+ camera.init();
7627
+ virtualManager.init();
7628
+ renderer.init(this);
7629
+ control.init(this);
7630
+
7631
+ if (preventEventsBeforeInit) {
7632
+ this.trigger = function () {
7633
+ return _this;
7634
+ };
7635
+ }
7535
7636
 
7536
- case 2:
7537
- // Look at initial panel
7538
- _a.sent();
7637
+ this._initialResize(); // Look at initial panel
7539
7638
 
7540
- if (this._autoResize) {
7541
- this._autoResizer.enable();
7542
- }
7543
7639
 
7544
- if (this._preventClickOnDrag) {
7545
- control.controller.addPreventClickHandler();
7546
- }
7640
+ this._moveToInitialPanel();
7547
7641
 
7548
- if (this._disableOnInit) {
7549
- this.disableInput();
7550
- }
7642
+ if (this._autoResize) {
7643
+ this._autoResizer.enable();
7644
+ }
7551
7645
 
7552
- renderer.checkPanelContentsReady(renderer.panels);
7646
+ if (this._preventClickOnDrag) {
7647
+ control.controller.addPreventClickHandler();
7648
+ }
7553
7649
 
7554
- this._plugins.forEach(function (plugin) {
7555
- return plugin.init(_this);
7556
- }); // Done initializing & emit ready event
7650
+ if (this._disableOnInit) {
7651
+ this.disableInput();
7652
+ }
7557
7653
 
7654
+ renderer.checkPanelContentsReady(renderer.panels);
7655
+ return renderer.render().then(function () {
7656
+ // Done initializing & emit ready event
7657
+ _this._plugins.forEach(function (plugin) {
7658
+ return plugin.init(_this);
7659
+ });
7558
7660
 
7559
- this._initialized = true;
7661
+ _this._initialized = true;
7560
7662
 
7561
- if (preventEventsBeforeInit) {
7562
- this.trigger = originalTrigger;
7563
- }
7663
+ if (preventEventsBeforeInit) {
7664
+ _this.trigger = originalTrigger;
7665
+ }
7564
7666
 
7565
- this.trigger(new ComponentEvent(EVENTS.READY));
7566
- return [2
7567
- /*return*/
7568
- ];
7569
- }
7570
- });
7667
+ _this.trigger(new ComponentEvent(EVENTS.READY));
7571
7668
  });
7572
7669
  };
7573
7670
  /**
@@ -8185,7 +8282,7 @@ function (_super) {
8185
8282
  console.warn("\"circular\" and \"bound\" option cannot be used together, ignoring bound.");
8186
8283
  }
8187
8284
 
8188
- return new Camera({
8285
+ return new Camera(this, {
8189
8286
  align: this._align
8190
8287
  });
8191
8288
  };
@@ -8221,23 +8318,59 @@ function (_super) {
8221
8318
  };
8222
8319
 
8223
8320
  __proto._moveToInitialPanel = function () {
8224
- return __awaiter(this, void 0, void 0, function () {
8225
- var renderer, control, initialPanel;
8226
- return __generator(this, function (_a) {
8227
- renderer = this._renderer;
8228
- control = this._control;
8229
- initialPanel = renderer.getPanel(this._defaultIndex) || renderer.getPanel(0);
8230
- if (!initialPanel) return [2
8231
- /*return*/
8232
- ];
8233
- control.setActive(initialPanel, null, false);
8234
- return [2
8235
- /*return*/
8236
- , control.moveToPanel(initialPanel, {
8237
- duration: 0
8238
- })];
8239
- });
8240
- });
8321
+ var renderer = this._renderer;
8322
+ var control = this._control;
8323
+ var camera = this._camera;
8324
+ var initialPanel = renderer.getPanel(this._defaultIndex) || renderer.getPanel(0);
8325
+ if (!initialPanel) return;
8326
+ var nearestAnchor = camera.findNearestAnchor(initialPanel.position);
8327
+ control.setActive(initialPanel, null, false);
8328
+
8329
+ if (!nearestAnchor) {
8330
+ throw new FlickingError(MESSAGE.POSITION_NOT_REACHABLE(initialPanel.position), CODE.POSITION_NOT_REACHABLE);
8331
+ }
8332
+
8333
+ var position = initialPanel.position;
8334
+
8335
+ if (!camera.canReach(initialPanel)) {
8336
+ position = nearestAnchor.position;
8337
+ }
8338
+
8339
+ camera.lookAt(position);
8340
+ control.updateInput();
8341
+ camera.updateOffset();
8342
+ };
8343
+
8344
+ __proto._initialResize = function () {
8345
+ var viewport = this._viewport;
8346
+ var renderer = this._renderer;
8347
+ var camera = this._camera;
8348
+ var control = this._control;
8349
+ this.trigger(new ComponentEvent(EVENTS.BEFORE_RESIZE, {
8350
+ width: 0,
8351
+ height: 0,
8352
+ element: viewport.element
8353
+ }));
8354
+ viewport.resize();
8355
+ renderer.updatePanelSize();
8356
+ camera.updateAlignPos();
8357
+ camera.updateRange();
8358
+ camera.updateAnchors();
8359
+ camera.updateOffset();
8360
+ control.updateInput();
8361
+ var newWidth = viewport.width;
8362
+ var newHeight = viewport.height;
8363
+ var sizeChanged = newWidth !== 0 || newHeight !== 0;
8364
+ this.trigger(new ComponentEvent(EVENTS.AFTER_RESIZE, {
8365
+ width: viewport.width,
8366
+ height: viewport.height,
8367
+ prev: {
8368
+ width: 0,
8369
+ height: 0
8370
+ },
8371
+ sizeChanged: sizeChanged,
8372
+ element: viewport.element
8373
+ }));
8241
8374
  };
8242
8375
  /**
8243
8376
  * Version info string
@@ -8251,7 +8384,7 @@ function (_super) {
8251
8384
  */
8252
8385
 
8253
8386
 
8254
- Flicking.VERSION = "4.5.1";
8387
+ Flicking.VERSION = "4.6.0";
8255
8388
  return Flicking;
8256
8389
  }(Component);
8257
8390
 
@@ -8274,7 +8407,7 @@ function (_super) {
8274
8407
  var withFlickingMethods = function (prototype, flickingName) {
8275
8408
  [Component.prototype, Flicking.prototype].forEach(function (proto) {
8276
8409
  Object.getOwnPropertyNames(proto).filter(function (name) {
8277
- return !prototype[name] && !name.startsWith("_") && name !== "constructor";
8410
+ return !prototype[name] && name.indexOf("_") !== 0 && name !== "constructor";
8278
8411
  }).forEach(function (name) {
8279
8412
  var descriptor = Object.getOwnPropertyDescriptor(proto, name);
8280
8413
 
@@ -8331,6 +8464,9 @@ var sync = (function (flicking, diffResult, rendered) {
8331
8464
 
8332
8465
  var prevList = __spread(diffResult.prevList);
8333
8466
 
8467
+ var added = [];
8468
+ var removed = [];
8469
+
8334
8470
  if (diffResult.removed.length > 0) {
8335
8471
  var endIdx_1 = -1;
8336
8472
  var prevIdx_1 = -1;
@@ -8340,7 +8476,7 @@ var sync = (function (flicking, diffResult, rendered) {
8340
8476
  }
8341
8477
 
8342
8478
  if (prevIdx_1 >= 0 && removedIdx !== prevIdx_1 - 1) {
8343
- batchRemove(renderer, prevIdx_1, endIdx_1 + 1);
8479
+ removed.push.apply(removed, __spread(batchRemove(renderer, prevIdx_1, endIdx_1 + 1)));
8344
8480
  endIdx_1 = removedIdx;
8345
8481
  prevIdx_1 = removedIdx;
8346
8482
  } else {
@@ -8349,39 +8485,34 @@ var sync = (function (flicking, diffResult, rendered) {
8349
8485
 
8350
8486
  prevList.splice(removedIdx, 1);
8351
8487
  });
8352
- batchRemove(renderer, prevIdx_1, endIdx_1 + 1);
8488
+ removed.push.apply(removed, __spread(batchRemove(renderer, prevIdx_1, endIdx_1 + 1)));
8353
8489
  }
8354
8490
 
8355
8491
  diffResult.ordered.forEach(function (_a) {
8356
8492
  var _b = __read(_a, 2),
8357
- prevIdx = _b[0],
8358
- newIdx = _b[1];
8493
+ from = _b[0],
8494
+ to = _b[1];
8359
8495
 
8360
- var prevPanel = panels[prevIdx];
8361
- var indexDiff = newIdx - prevIdx;
8362
-
8363
- if (indexDiff > 0) {
8364
- var middlePanels = panels.slice(prevIdx + 1, newIdx + 1);
8365
- prevPanel.increaseIndex(indexDiff);
8366
- middlePanels.forEach(function (panel) {
8367
- return panel.decreaseIndex(1);
8368
- });
8369
- } else {
8370
- var middlePanels = panels.slice(newIdx, prevIdx);
8371
- prevPanel.decreaseIndex(-indexDiff);
8372
- middlePanels.forEach(function (panel) {
8373
- return panel.increaseIndex(1);
8374
- });
8375
- } // Update position
8376
-
8377
-
8378
- prevPanel.resize();
8496
+ var prevPanel = panels.splice(from, 1)[0];
8497
+ panels.splice(to, 0, prevPanel);
8379
8498
  });
8380
8499
 
8381
8500
  if (diffResult.ordered.length > 0) {
8501
+ panels.forEach(function (panel, idx) {
8502
+ var indexDiff = idx - panel.index;
8503
+
8504
+ if (indexDiff > 0) {
8505
+ panel.increaseIndex(indexDiff);
8506
+ } else {
8507
+ panel.decreaseIndex(-indexDiff);
8508
+ }
8509
+ });
8382
8510
  panels.sort(function (panel1, panel2) {
8383
8511
  return panel1.index - panel2.index;
8384
8512
  });
8513
+ panels.forEach(function (panel) {
8514
+ panel.updatePosition();
8515
+ });
8385
8516
  }
8386
8517
 
8387
8518
  if (diffResult.added.length > 0) {
@@ -8394,7 +8525,7 @@ var sync = (function (flicking, diffResult, rendered) {
8394
8525
  }
8395
8526
 
8396
8527
  if (prevIdx_2 >= 0 && addedIdx !== prevIdx_2 + 1) {
8397
- batchInsert(renderer, diffResult, addedElements_1, startIdx_1, idx + 1);
8528
+ added.push.apply(added, __spread(batchInsert(renderer, diffResult, addedElements_1, startIdx_1, idx + 1)));
8398
8529
  startIdx_1 = -1;
8399
8530
  prevIdx_2 = -1;
8400
8531
  } else {
@@ -8403,13 +8534,15 @@ var sync = (function (flicking, diffResult, rendered) {
8403
8534
  });
8404
8535
 
8405
8536
  if (startIdx_1 >= 0) {
8406
- batchInsert(renderer, diffResult, addedElements_1, startIdx_1);
8537
+ added.push.apply(added, __spread(batchInsert(renderer, diffResult, addedElements_1, startIdx_1)));
8407
8538
  }
8408
8539
  }
8540
+
8541
+ renderer.updateAfterPanelChange(added, removed);
8409
8542
  });
8410
8543
 
8411
8544
  var batchInsert = function (renderer, diffResult, addedElements, startIdx, endIdx) {
8412
- renderer.batchInsert.apply(renderer, __spread(diffResult.added.slice(startIdx, endIdx).map(function (index, elIdx) {
8545
+ return renderer.batchInsertDefer.apply(renderer, __spread(diffResult.added.slice(startIdx, endIdx).map(function (index, elIdx) {
8413
8546
  return {
8414
8547
  index: index,
8415
8548
  elements: [addedElements[elIdx]],
@@ -8420,7 +8553,7 @@ var batchInsert = function (renderer, diffResult, addedElements, startIdx, endId
8420
8553
 
8421
8554
  var batchRemove = function (renderer, startIdx, endIdx) {
8422
8555
  var removed = renderer.panels.slice(startIdx, endIdx);
8423
- renderer.batchRemove({
8556
+ return renderer.batchRemoveDefer({
8424
8557
  index: startIdx,
8425
8558
  deleteCount: removed.length,
8426
8559
  hasDOMInElements: false