@egjs/flicking 4.5.0 → 4.6.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/TODO.md +3 -0
- package/declaration/Flicking.d.ts +8 -1
- package/declaration/camera/Camera.d.ts +2 -2
- package/declaration/control/StrictControl.d.ts +1 -0
- package/declaration/core/AutoResizer.d.ts +3 -0
- package/declaration/core/ResizeWatcher.d.ts +33 -0
- package/declaration/renderer/Renderer.d.ts +13 -0
- package/dist/flicking-inline.css +45 -2
- package/dist/flicking-inline.min.css +1 -0
- package/dist/flicking.css +44 -2
- package/dist/flicking.esm.js +320 -171
- package/dist/flicking.esm.js.map +1 -1
- package/dist/flicking.js +320 -171
- package/dist/flicking.js.map +1 -1
- package/dist/flicking.min.css +1 -0
- package/dist/flicking.min.js +2 -2
- package/dist/flicking.min.js.map +1 -1
- package/dist/flicking.pkgd.js +320 -171
- package/dist/flicking.pkgd.js.map +1 -1
- package/dist/flicking.pkgd.min.js +2 -2
- package/dist/flicking.pkgd.min.js.map +1 -1
- package/package.json +14 -5
- package/sass/flicking-inline.sass +30 -0
- package/sass/flicking.sass +23 -0
- package/src/Flicking.ts +102 -21
- package/src/camera/Camera.ts +10 -14
- package/src/cfc/sync.ts +29 -23
- package/src/cfc/withFlickingMethods.ts +3 -2
- package/src/control/StrictControl.ts +10 -0
- package/src/core/AutoResizer.ts +33 -0
- package/src/core/ResizeWatcher.ts +133 -0
- package/src/renderer/Renderer.ts +92 -43
- package/css/flicking-inline.css +0 -38
- package/css/flicking.css +0 -28
- package/dist/flicking-inline.css.map +0 -1
- package/dist/flicking.css.map +0 -1
package/dist/flicking.esm.js
CHANGED
|
@@ -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.
|
|
7
|
+
version: 4.6.1
|
|
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;
|
|
@@ -3467,6 +3496,21 @@ function (_super) {
|
|
|
3467
3496
|
};
|
|
3468
3497
|
return this;
|
|
3469
3498
|
};
|
|
3499
|
+
|
|
3500
|
+
__proto.moveToPanel = function (panel, options) {
|
|
3501
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3502
|
+
var flicking, camera, controller;
|
|
3503
|
+
return __generator(this, function (_a) {
|
|
3504
|
+
flicking = getFlickingAttached(this._flicking);
|
|
3505
|
+
camera = flicking.camera;
|
|
3506
|
+
controller = this._controller;
|
|
3507
|
+
controller.update(camera.controlParams);
|
|
3508
|
+
return [2
|
|
3509
|
+
/*return*/
|
|
3510
|
+
, _super.prototype.moveToPanel.call(this, panel, options)];
|
|
3511
|
+
});
|
|
3512
|
+
});
|
|
3513
|
+
};
|
|
3470
3514
|
/**
|
|
3471
3515
|
* Move {@link Camera} to the given position
|
|
3472
3516
|
* @ko {@link Camera}를 주어진 좌표로 이동합니다
|
|
@@ -4023,7 +4067,7 @@ var Camera =
|
|
|
4023
4067
|
/*#__PURE__*/
|
|
4024
4068
|
function () {
|
|
4025
4069
|
/** */
|
|
4026
|
-
function Camera(_a) {
|
|
4070
|
+
function Camera(flicking, _a) {
|
|
4027
4071
|
var _this = this;
|
|
4028
4072
|
|
|
4029
4073
|
var _b = (_a === void 0 ? {} : _a).align,
|
|
@@ -4063,7 +4107,7 @@ function () {
|
|
|
4063
4107
|
_this._transform = transformName;
|
|
4064
4108
|
};
|
|
4065
4109
|
|
|
4066
|
-
this._flicking =
|
|
4110
|
+
this._flicking = flicking;
|
|
4067
4111
|
|
|
4068
4112
|
this._resetInternalValues(); // Options
|
|
4069
4113
|
|
|
@@ -4358,17 +4402,14 @@ function () {
|
|
|
4358
4402
|
/**
|
|
4359
4403
|
* Initialize Camera
|
|
4360
4404
|
* @ko Camera를 초기화합니다
|
|
4361
|
-
* @param {Flicking} flicking An instance of {@link Flicking}<ko>Flicking의 인스턴스</ko>
|
|
4362
|
-
* @chainable
|
|
4363
4405
|
* @throws {FlickingError}
|
|
4364
4406
|
* {@link ERROR_CODE VAL_MUST_NOT_NULL} If the camera element(`.flicking-camera`) does not exist inside viewport element
|
|
4365
4407
|
* <ko>{@link ERROR_CODE VAL_MUST_NOT_NULL} 뷰포트 엘리먼트 내부에 카메라 엘리먼트(`.flicking-camera`)가 존재하지 않을 경우</ko>
|
|
4366
4408
|
* @return {this}
|
|
4367
4409
|
*/
|
|
4368
4410
|
|
|
4369
|
-
__proto.init = function (
|
|
4370
|
-
this._flicking
|
|
4371
|
-
var viewportEl = flicking.viewport.element;
|
|
4411
|
+
__proto.init = function () {
|
|
4412
|
+
var viewportEl = this._flicking.viewport.element;
|
|
4372
4413
|
checkExistence(viewportEl.firstElementChild, "First element child of the viewport element");
|
|
4373
4414
|
this._el = viewportEl.firstElementChild;
|
|
4374
4415
|
|
|
@@ -4386,8 +4427,6 @@ function () {
|
|
|
4386
4427
|
|
|
4387
4428
|
|
|
4388
4429
|
__proto.destroy = function () {
|
|
4389
|
-
this._flicking = null;
|
|
4390
|
-
|
|
4391
4430
|
this._resetInternalValues();
|
|
4392
4431
|
|
|
4393
4432
|
return this;
|
|
@@ -4418,12 +4457,12 @@ function () {
|
|
|
4418
4457
|
|
|
4419
4458
|
this._checkReachEnd(prevPos, pos);
|
|
4420
4459
|
|
|
4421
|
-
this.applyTransform();
|
|
4422
|
-
|
|
4423
4460
|
if (toggled) {
|
|
4424
4461
|
void flicking.renderer.render().then(function () {
|
|
4425
4462
|
_this.updateOffset();
|
|
4426
4463
|
});
|
|
4464
|
+
} else {
|
|
4465
|
+
this.applyTransform();
|
|
4427
4466
|
}
|
|
4428
4467
|
};
|
|
4429
4468
|
/**
|
|
@@ -4610,7 +4649,6 @@ function () {
|
|
|
4610
4649
|
});
|
|
4611
4650
|
}
|
|
4612
4651
|
|
|
4613
|
-
this.updateOffset();
|
|
4614
4652
|
return this;
|
|
4615
4653
|
};
|
|
4616
4654
|
/**
|
|
@@ -4702,7 +4740,6 @@ function () {
|
|
|
4702
4740
|
/**
|
|
4703
4741
|
* Apply "transform" style with the current position to camera element
|
|
4704
4742
|
* @ko 현재 위치를 기준으로한 transform 스타일을 카메라 엘리먼트에 적용합니다.
|
|
4705
|
-
* @chainable
|
|
4706
4743
|
* @return {this}
|
|
4707
4744
|
*/
|
|
4708
4745
|
|
|
@@ -4710,6 +4747,8 @@ function () {
|
|
|
4710
4747
|
__proto.applyTransform = function () {
|
|
4711
4748
|
var el = this._el;
|
|
4712
4749
|
var flicking = getFlickingAttached(this._flicking);
|
|
4750
|
+
var renderer = flicking.renderer;
|
|
4751
|
+
if (renderer.rendering) return this;
|
|
4713
4752
|
var actualPosition = this._position - this._alignPos - this._offset + this._circularOffset;
|
|
4714
4753
|
el.style[this._transform] = flicking.horizontal ? "translate(" + -actualPosition + "px)" : "translate(0, " + -actualPosition + "px)";
|
|
4715
4754
|
return this;
|
|
@@ -4882,7 +4921,8 @@ function () {
|
|
|
4882
4921
|
align = _b === void 0 ? ALIGN.CENTER : _b,
|
|
4883
4922
|
strategy = _a.strategy;
|
|
4884
4923
|
this._flicking = null;
|
|
4885
|
-
this._panels = [];
|
|
4924
|
+
this._panels = [];
|
|
4925
|
+
this._rendering = false; // Bind options
|
|
4886
4926
|
|
|
4887
4927
|
this._align = align;
|
|
4888
4928
|
this._strategy = strategy;
|
|
@@ -4905,6 +4945,20 @@ function () {
|
|
|
4905
4945
|
enumerable: false,
|
|
4906
4946
|
configurable: true
|
|
4907
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
|
+
});
|
|
4908
4962
|
Object.defineProperty(__proto, "panelCount", {
|
|
4909
4963
|
/**
|
|
4910
4964
|
* Count of panels
|
|
@@ -5036,6 +5090,25 @@ function () {
|
|
|
5036
5090
|
|
|
5037
5091
|
|
|
5038
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 () {
|
|
5039
5112
|
var _this = this;
|
|
5040
5113
|
|
|
5041
5114
|
var items = [];
|
|
@@ -5046,7 +5119,6 @@ function () {
|
|
|
5046
5119
|
|
|
5047
5120
|
var panels = this._panels;
|
|
5048
5121
|
var flicking = getFlickingAttached(this._flicking);
|
|
5049
|
-
var control = flicking.control;
|
|
5050
5122
|
var prevFirstPanel = panels[0];
|
|
5051
5123
|
var align = parsePanelAlign(this._align);
|
|
5052
5124
|
var allPanelsInserted = items.reduce(function (addedPanels, item) {
|
|
@@ -5086,27 +5158,6 @@ function () {
|
|
|
5086
5158
|
});
|
|
5087
5159
|
return __spread(addedPanels, panelsInserted);
|
|
5088
5160
|
}, []);
|
|
5089
|
-
if (allPanelsInserted.length <= 0) return []; // Update camera & control
|
|
5090
|
-
|
|
5091
|
-
this._updateCameraAndControl();
|
|
5092
|
-
|
|
5093
|
-
void this.render(); // Move to the first panel added if no panels existed
|
|
5094
|
-
// FIXME: fix for animating case
|
|
5095
|
-
|
|
5096
|
-
if (allPanelsInserted.length > 0 && !control.animating) {
|
|
5097
|
-
void control.moveToPanel(control.activePanel || allPanelsInserted[0], {
|
|
5098
|
-
duration: 0
|
|
5099
|
-
}).catch(function () {
|
|
5100
|
-
return void 0;
|
|
5101
|
-
});
|
|
5102
|
-
}
|
|
5103
|
-
|
|
5104
|
-
flicking.camera.updateOffset();
|
|
5105
|
-
flicking.trigger(new ComponentEvent(EVENTS.PANEL_CHANGE, {
|
|
5106
|
-
added: allPanelsInserted,
|
|
5107
|
-
removed: []
|
|
5108
|
-
}));
|
|
5109
|
-
this.checkPanelContentsReady(allPanelsInserted);
|
|
5110
5161
|
return allPanelsInserted;
|
|
5111
5162
|
};
|
|
5112
5163
|
/**
|
|
@@ -5123,6 +5174,25 @@ function () {
|
|
|
5123
5174
|
|
|
5124
5175
|
|
|
5125
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 () {
|
|
5126
5196
|
var _this = this;
|
|
5127
5197
|
|
|
5128
5198
|
var items = [];
|
|
@@ -5133,10 +5203,8 @@ function () {
|
|
|
5133
5203
|
|
|
5134
5204
|
var panels = this._panels;
|
|
5135
5205
|
var flicking = getFlickingAttached(this._flicking);
|
|
5136
|
-
var
|
|
5137
|
-
control = flicking.control;
|
|
5206
|
+
var control = flicking.control;
|
|
5138
5207
|
var activePanel = control.activePanel;
|
|
5139
|
-
var activeIndex = control.activeIndex;
|
|
5140
5208
|
var allPanelsRemoved = items.reduce(function (removed, item) {
|
|
5141
5209
|
var index = item.index,
|
|
5142
5210
|
deleteCount = item.deleteCount;
|
|
@@ -5164,33 +5232,61 @@ function () {
|
|
|
5164
5232
|
}
|
|
5165
5233
|
|
|
5166
5234
|
return __spread(removed, panelsRemoved);
|
|
5167
|
-
}, []);
|
|
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
|
|
5168
5251
|
|
|
5169
5252
|
this._updateCameraAndControl();
|
|
5170
5253
|
|
|
5171
|
-
void this.render();
|
|
5254
|
+
void this.render();
|
|
5172
5255
|
|
|
5173
|
-
if (
|
|
5174
|
-
|
|
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;
|
|
5262
|
+
|
|
5263
|
+
if (targetIndex > panels.length - 1) {
|
|
5264
|
+
targetIndex = panels.length - 1;
|
|
5265
|
+
}
|
|
5175
5266
|
|
|
5176
|
-
|
|
5177
|
-
void control.moveToPanel(targetPanel, {
|
|
5267
|
+
void control.moveToPanel(panels[targetIndex], {
|
|
5178
5268
|
duration: 0
|
|
5179
5269
|
}).catch(function () {
|
|
5180
5270
|
return void 0;
|
|
5181
5271
|
});
|
|
5182
|
-
} else {
|
|
5183
|
-
// All panels removed
|
|
5184
|
-
camera.lookAt(0);
|
|
5185
5272
|
}
|
|
5273
|
+
} else {
|
|
5274
|
+
void control.moveToPanel(control.activePanel, {
|
|
5275
|
+
duration: 0
|
|
5276
|
+
}).catch(function () {
|
|
5277
|
+
return void 0;
|
|
5278
|
+
});
|
|
5186
5279
|
}
|
|
5187
5280
|
|
|
5188
5281
|
flicking.camera.updateOffset();
|
|
5189
|
-
|
|
5190
|
-
|
|
5191
|
-
|
|
5192
|
-
|
|
5193
|
-
|
|
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
|
+
}
|
|
5194
5290
|
};
|
|
5195
5291
|
/**
|
|
5196
5292
|
* @internal
|
|
@@ -5235,6 +5331,7 @@ function () {
|
|
|
5235
5331
|
});
|
|
5236
5332
|
if (!flicking.initialized) return;
|
|
5237
5333
|
camera.updateRange();
|
|
5334
|
+
camera.updateOffset();
|
|
5238
5335
|
camera.updateAnchors();
|
|
5239
5336
|
|
|
5240
5337
|
if (control.animating) ; else {
|
|
@@ -5268,6 +5365,7 @@ function () {
|
|
|
5268
5365
|
var camera = flicking.camera,
|
|
5269
5366
|
control = flicking.control;
|
|
5270
5367
|
camera.updateRange();
|
|
5368
|
+
camera.updateOffset();
|
|
5271
5369
|
camera.updateAnchors();
|
|
5272
5370
|
camera.resetNeedPanelHistory();
|
|
5273
5371
|
control.updateInput();
|
|
@@ -6552,10 +6650,14 @@ function (_super) {
|
|
|
6552
6650
|
autoResize = _4 === void 0 ? true : _4,
|
|
6553
6651
|
_5 = _b.useResizeObserver,
|
|
6554
6652
|
useResizeObserver = _5 === void 0 ? true : _5,
|
|
6555
|
-
_6 = _b.
|
|
6556
|
-
|
|
6557
|
-
_7 = _b.
|
|
6558
|
-
|
|
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;
|
|
6559
6661
|
|
|
6560
6662
|
var _this = _super.call(this) || this; // Internal states
|
|
6561
6663
|
|
|
@@ -6591,6 +6693,8 @@ function (_super) {
|
|
|
6591
6693
|
_this._autoInit = autoInit;
|
|
6592
6694
|
_this._autoResize = autoResize;
|
|
6593
6695
|
_this._useResizeObserver = useResizeObserver;
|
|
6696
|
+
_this._resizeDebounce = resizeDebounce;
|
|
6697
|
+
_this._maxResizeDebounce = maxResizeDebounce;
|
|
6594
6698
|
_this._externalRenderer = externalRenderer;
|
|
6595
6699
|
_this._renderExternal = renderExternal; // Create core components
|
|
6596
6700
|
|
|
@@ -7439,6 +7543,38 @@ function (_super) {
|
|
|
7439
7543
|
enumerable: false,
|
|
7440
7544
|
configurable: true
|
|
7441
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
|
+
});
|
|
7442
7578
|
Object.defineProperty(__proto, "externalRenderer", {
|
|
7443
7579
|
/**
|
|
7444
7580
|
* This is an option for the frameworks(React, Vue, Angular, ...). Don't set it as it's automatically managed by Flicking.
|
|
@@ -7474,85 +7610,61 @@ function (_super) {
|
|
|
7474
7610
|
* @ko Flicking을 초기화하고, 디폴트 인덱스로 이동합니다
|
|
7475
7611
|
* 이 메소드는 `autoInit` 옵션이 true(default)일 경우 Flicking이 생성될 때 자동으로 호출됩니다
|
|
7476
7612
|
* @fires Flicking#ready
|
|
7477
|
-
* @return {
|
|
7613
|
+
* @return {Promise<void>}
|
|
7478
7614
|
*/
|
|
7479
7615
|
|
|
7480
7616
|
__proto.init = function () {
|
|
7481
|
-
|
|
7482
|
-
var camera, renderer, control, virtualManager, originalTrigger, preventEventsBeforeInit;
|
|
7483
|
-
|
|
7484
|
-
var _this = this;
|
|
7485
|
-
|
|
7486
|
-
return __generator(this, function (_a) {
|
|
7487
|
-
switch (_a.label) {
|
|
7488
|
-
case 0:
|
|
7489
|
-
if (this._initialized) return [2
|
|
7490
|
-
/*return*/
|
|
7491
|
-
];
|
|
7492
|
-
camera = this._camera;
|
|
7493
|
-
renderer = this._renderer;
|
|
7494
|
-
control = this._control;
|
|
7495
|
-
virtualManager = this._virtualManager;
|
|
7496
|
-
originalTrigger = this.trigger;
|
|
7497
|
-
preventEventsBeforeInit = this._preventEventsBeforeInit;
|
|
7498
|
-
camera.init(this);
|
|
7499
|
-
virtualManager.init();
|
|
7500
|
-
renderer.init(this);
|
|
7501
|
-
control.init(this);
|
|
7502
|
-
|
|
7503
|
-
if (preventEventsBeforeInit) {
|
|
7504
|
-
this.trigger = function () {
|
|
7505
|
-
return _this;
|
|
7506
|
-
};
|
|
7507
|
-
}
|
|
7508
|
-
|
|
7509
|
-
return [4
|
|
7510
|
-
/*yield*/
|
|
7511
|
-
, this.resize()];
|
|
7512
|
-
|
|
7513
|
-
case 1:
|
|
7514
|
-
_a.sent(); // Look at initial panel
|
|
7515
|
-
|
|
7617
|
+
var _this = this;
|
|
7516
7618
|
|
|
7517
|
-
|
|
7518
|
-
|
|
7519
|
-
|
|
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
|
+
}
|
|
7520
7636
|
|
|
7521
|
-
|
|
7522
|
-
// Look at initial panel
|
|
7523
|
-
_a.sent();
|
|
7637
|
+
this._initialResize(); // Look at initial panel
|
|
7524
7638
|
|
|
7525
|
-
if (this._autoResize) {
|
|
7526
|
-
this._autoResizer.enable();
|
|
7527
|
-
}
|
|
7528
7639
|
|
|
7529
|
-
|
|
7530
|
-
control.controller.addPreventClickHandler();
|
|
7531
|
-
}
|
|
7640
|
+
this._moveToInitialPanel();
|
|
7532
7641
|
|
|
7533
|
-
|
|
7534
|
-
|
|
7535
|
-
|
|
7642
|
+
if (this._autoResize) {
|
|
7643
|
+
this._autoResizer.enable();
|
|
7644
|
+
}
|
|
7536
7645
|
|
|
7537
|
-
|
|
7646
|
+
if (this._preventClickOnDrag) {
|
|
7647
|
+
control.controller.addPreventClickHandler();
|
|
7648
|
+
}
|
|
7538
7649
|
|
|
7539
|
-
|
|
7540
|
-
|
|
7541
|
-
|
|
7650
|
+
if (this._disableOnInit) {
|
|
7651
|
+
this.disableInput();
|
|
7652
|
+
}
|
|
7542
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
|
+
});
|
|
7543
7660
|
|
|
7544
|
-
|
|
7661
|
+
_this._initialized = true;
|
|
7545
7662
|
|
|
7546
|
-
|
|
7547
|
-
|
|
7548
|
-
|
|
7663
|
+
if (preventEventsBeforeInit) {
|
|
7664
|
+
_this.trigger = originalTrigger;
|
|
7665
|
+
}
|
|
7549
7666
|
|
|
7550
|
-
|
|
7551
|
-
return [2
|
|
7552
|
-
/*return*/
|
|
7553
|
-
];
|
|
7554
|
-
}
|
|
7555
|
-
});
|
|
7667
|
+
_this.trigger(new ComponentEvent(EVENTS.READY));
|
|
7556
7668
|
});
|
|
7557
7669
|
};
|
|
7558
7670
|
/**
|
|
@@ -8170,7 +8282,7 @@ function (_super) {
|
|
|
8170
8282
|
console.warn("\"circular\" and \"bound\" option cannot be used together, ignoring bound.");
|
|
8171
8283
|
}
|
|
8172
8284
|
|
|
8173
|
-
return new Camera({
|
|
8285
|
+
return new Camera(this, {
|
|
8174
8286
|
align: this._align
|
|
8175
8287
|
});
|
|
8176
8288
|
};
|
|
@@ -8206,23 +8318,59 @@ function (_super) {
|
|
|
8206
8318
|
};
|
|
8207
8319
|
|
|
8208
8320
|
__proto._moveToInitialPanel = function () {
|
|
8209
|
-
|
|
8210
|
-
|
|
8211
|
-
|
|
8212
|
-
|
|
8213
|
-
|
|
8214
|
-
|
|
8215
|
-
|
|
8216
|
-
|
|
8217
|
-
|
|
8218
|
-
|
|
8219
|
-
|
|
8220
|
-
|
|
8221
|
-
|
|
8222
|
-
|
|
8223
|
-
|
|
8224
|
-
|
|
8225
|
-
}
|
|
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
|
+
}));
|
|
8226
8374
|
};
|
|
8227
8375
|
/**
|
|
8228
8376
|
* Version info string
|
|
@@ -8236,7 +8384,7 @@ function (_super) {
|
|
|
8236
8384
|
*/
|
|
8237
8385
|
|
|
8238
8386
|
|
|
8239
|
-
Flicking.VERSION = "4.
|
|
8387
|
+
Flicking.VERSION = "4.6.1";
|
|
8240
8388
|
return Flicking;
|
|
8241
8389
|
}(Component);
|
|
8242
8390
|
|
|
@@ -8259,7 +8407,7 @@ function (_super) {
|
|
|
8259
8407
|
var withFlickingMethods = function (prototype, flickingName) {
|
|
8260
8408
|
[Component.prototype, Flicking.prototype].forEach(function (proto) {
|
|
8261
8409
|
Object.getOwnPropertyNames(proto).filter(function (name) {
|
|
8262
|
-
return !prototype[name] &&
|
|
8410
|
+
return !prototype[name] && name.indexOf("_") !== 0 && name !== "constructor";
|
|
8263
8411
|
}).forEach(function (name) {
|
|
8264
8412
|
var descriptor = Object.getOwnPropertyDescriptor(proto, name);
|
|
8265
8413
|
|
|
@@ -8285,7 +8433,8 @@ var withFlickingMethods = function (prototype, flickingName) {
|
|
|
8285
8433
|
getterDescriptor.get = function () {
|
|
8286
8434
|
var _a;
|
|
8287
8435
|
|
|
8288
|
-
|
|
8436
|
+
var flicking = this[flickingName];
|
|
8437
|
+
return flicking && ((_a = descriptor.get) === null || _a === void 0 ? void 0 : _a.call(flicking));
|
|
8289
8438
|
};
|
|
8290
8439
|
}
|
|
8291
8440
|
|
|
@@ -8315,6 +8464,9 @@ var sync = (function (flicking, diffResult, rendered) {
|
|
|
8315
8464
|
|
|
8316
8465
|
var prevList = __spread(diffResult.prevList);
|
|
8317
8466
|
|
|
8467
|
+
var added = [];
|
|
8468
|
+
var removed = [];
|
|
8469
|
+
|
|
8318
8470
|
if (diffResult.removed.length > 0) {
|
|
8319
8471
|
var endIdx_1 = -1;
|
|
8320
8472
|
var prevIdx_1 = -1;
|
|
@@ -8324,7 +8476,7 @@ var sync = (function (flicking, diffResult, rendered) {
|
|
|
8324
8476
|
}
|
|
8325
8477
|
|
|
8326
8478
|
if (prevIdx_1 >= 0 && removedIdx !== prevIdx_1 - 1) {
|
|
8327
|
-
batchRemove(renderer, prevIdx_1, endIdx_1 + 1);
|
|
8479
|
+
removed.push.apply(removed, __spread(batchRemove(renderer, prevIdx_1, endIdx_1 + 1)));
|
|
8328
8480
|
endIdx_1 = removedIdx;
|
|
8329
8481
|
prevIdx_1 = removedIdx;
|
|
8330
8482
|
} else {
|
|
@@ -8333,39 +8485,34 @@ var sync = (function (flicking, diffResult, rendered) {
|
|
|
8333
8485
|
|
|
8334
8486
|
prevList.splice(removedIdx, 1);
|
|
8335
8487
|
});
|
|
8336
|
-
batchRemove(renderer, prevIdx_1, endIdx_1 + 1);
|
|
8488
|
+
removed.push.apply(removed, __spread(batchRemove(renderer, prevIdx_1, endIdx_1 + 1)));
|
|
8337
8489
|
}
|
|
8338
8490
|
|
|
8339
8491
|
diffResult.ordered.forEach(function (_a) {
|
|
8340
8492
|
var _b = __read(_a, 2),
|
|
8341
|
-
|
|
8342
|
-
|
|
8343
|
-
|
|
8344
|
-
var prevPanel = panels[prevIdx];
|
|
8345
|
-
var indexDiff = newIdx - prevIdx;
|
|
8346
|
-
|
|
8347
|
-
if (indexDiff > 0) {
|
|
8348
|
-
var middlePanels = panels.slice(prevIdx + 1, newIdx + 1);
|
|
8349
|
-
prevPanel.increaseIndex(indexDiff);
|
|
8350
|
-
middlePanels.forEach(function (panel) {
|
|
8351
|
-
return panel.decreaseIndex(1);
|
|
8352
|
-
});
|
|
8353
|
-
} else {
|
|
8354
|
-
var middlePanels = panels.slice(newIdx, prevIdx);
|
|
8355
|
-
prevPanel.decreaseIndex(-indexDiff);
|
|
8356
|
-
middlePanels.forEach(function (panel) {
|
|
8357
|
-
return panel.increaseIndex(1);
|
|
8358
|
-
});
|
|
8359
|
-
} // Update position
|
|
8360
|
-
|
|
8493
|
+
from = _b[0],
|
|
8494
|
+
to = _b[1];
|
|
8361
8495
|
|
|
8362
|
-
prevPanel.
|
|
8496
|
+
var prevPanel = panels.splice(from, 1)[0];
|
|
8497
|
+
panels.splice(to, 0, prevPanel);
|
|
8363
8498
|
});
|
|
8364
8499
|
|
|
8365
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
|
+
});
|
|
8366
8510
|
panels.sort(function (panel1, panel2) {
|
|
8367
8511
|
return panel1.index - panel2.index;
|
|
8368
8512
|
});
|
|
8513
|
+
panels.forEach(function (panel) {
|
|
8514
|
+
panel.updatePosition();
|
|
8515
|
+
});
|
|
8369
8516
|
}
|
|
8370
8517
|
|
|
8371
8518
|
if (diffResult.added.length > 0) {
|
|
@@ -8378,7 +8525,7 @@ var sync = (function (flicking, diffResult, rendered) {
|
|
|
8378
8525
|
}
|
|
8379
8526
|
|
|
8380
8527
|
if (prevIdx_2 >= 0 && addedIdx !== prevIdx_2 + 1) {
|
|
8381
|
-
batchInsert(renderer, diffResult, addedElements_1, startIdx_1, idx + 1);
|
|
8528
|
+
added.push.apply(added, __spread(batchInsert(renderer, diffResult, addedElements_1, startIdx_1, idx + 1)));
|
|
8382
8529
|
startIdx_1 = -1;
|
|
8383
8530
|
prevIdx_2 = -1;
|
|
8384
8531
|
} else {
|
|
@@ -8387,13 +8534,15 @@ var sync = (function (flicking, diffResult, rendered) {
|
|
|
8387
8534
|
});
|
|
8388
8535
|
|
|
8389
8536
|
if (startIdx_1 >= 0) {
|
|
8390
|
-
batchInsert(renderer, diffResult, addedElements_1, startIdx_1);
|
|
8537
|
+
added.push.apply(added, __spread(batchInsert(renderer, diffResult, addedElements_1, startIdx_1)));
|
|
8391
8538
|
}
|
|
8392
8539
|
}
|
|
8540
|
+
|
|
8541
|
+
renderer.updateAfterPanelChange(added, removed);
|
|
8393
8542
|
});
|
|
8394
8543
|
|
|
8395
8544
|
var batchInsert = function (renderer, diffResult, addedElements, startIdx, endIdx) {
|
|
8396
|
-
renderer.
|
|
8545
|
+
return renderer.batchInsertDefer.apply(renderer, __spread(diffResult.added.slice(startIdx, endIdx).map(function (index, elIdx) {
|
|
8397
8546
|
return {
|
|
8398
8547
|
index: index,
|
|
8399
8548
|
elements: [addedElements[elIdx]],
|
|
@@ -8404,7 +8553,7 @@ var batchInsert = function (renderer, diffResult, addedElements, startIdx, endId
|
|
|
8404
8553
|
|
|
8405
8554
|
var batchRemove = function (renderer, startIdx, endIdx) {
|
|
8406
8555
|
var removed = renderer.panels.slice(startIdx, endIdx);
|
|
8407
|
-
renderer.
|
|
8556
|
+
return renderer.batchRemoveDefer({
|
|
8408
8557
|
index: startIdx,
|
|
8409
8558
|
deleteCount: removed.length,
|
|
8410
8559
|
hasDOMInElements: false
|