@egjs/flicking 4.12.1-beta.5 → 4.13.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.
- package/core-packages-link.js +8 -7
- package/declaration/Flicking.d.ts +10 -2
- package/declaration/core/AutoResizer.d.ts +5 -0
- package/dist/flicking.cjs.js +160 -43
- package/dist/flicking.cjs.js.map +1 -1
- package/dist/flicking.esm.js +160 -43
- package/dist/flicking.esm.js.map +1 -1
- package/dist/flicking.js +160 -43
- package/dist/flicking.js.map +1 -1
- package/dist/flicking.min.js +2 -2
- package/dist/flicking.min.js.map +1 -1
- package/dist/flicking.pkgd.js +160 -43
- 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 +1 -1
- package/src/Flicking.ts +191 -83
- package/src/core/AutoResizer.ts +75 -22
- package/src/renderer/Renderer.ts +13 -0
- package/src/utils.ts +6 -1
- package/panel-demo.html +0 -323
- package/panel-visual.md +0 -328
- package/scratch/dist/flicking.css +0 -11
- package/scratch/dist/flicking.js +0 -9059
- package/scratch/dist/flicking.js.map +0 -1
package/dist/flicking.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.13.0
|
|
8
8
|
*/
|
|
9
9
|
(function (global, factory) {
|
|
10
10
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@egjs/component'), require('@egjs/axes'), require('@egjs/imready')) :
|
|
@@ -687,6 +687,9 @@ version: 4.12.1-beta.5
|
|
|
687
687
|
};
|
|
688
688
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
689
689
|
var getStyle = function (el) {
|
|
690
|
+
if (!el) {
|
|
691
|
+
return {};
|
|
692
|
+
}
|
|
690
693
|
return window.getComputedStyle(el) || el.currentStyle;
|
|
691
694
|
};
|
|
692
695
|
var setSize = function (el, _a) {
|
|
@@ -998,41 +1001,53 @@ version: 4.12.1-beta.5
|
|
|
998
1001
|
* Copyright (c) 2015 NAVER Corp.
|
|
999
1002
|
* egjs projects are licensed under the MIT license
|
|
1000
1003
|
*/
|
|
1004
|
+
/**
|
|
1005
|
+
* A component that detects size change and trigger resize method when the autoResize option is used
|
|
1006
|
+
* @ko autoResize 옵션을 사용할 때 크기 변화를 감지하고 Flicking의 resize를 호출하는 컴포넌트
|
|
1007
|
+
*/
|
|
1001
1008
|
var AutoResizer = /*#__PURE__*/function () {
|
|
1009
|
+
/** */
|
|
1002
1010
|
function AutoResizer(flicking) {
|
|
1003
1011
|
var _this = this;
|
|
1012
|
+
this._onResizeWrapper = function () {
|
|
1013
|
+
_this._onResize([]);
|
|
1014
|
+
};
|
|
1004
1015
|
this._onResize = function (entries) {
|
|
1005
1016
|
var flicking = _this._flicking;
|
|
1006
1017
|
var resizeDebounce = flicking.resizeDebounce;
|
|
1007
1018
|
var maxResizeDebounce = flicking.maxResizeDebounce;
|
|
1008
|
-
|
|
1009
|
-
|
|
1019
|
+
var resizedViewportElement = flicking.element;
|
|
1020
|
+
// 현재 구현에서 리사이즈 옵저빙 대상은 패널과 뷰포트 2개만 존재.
|
|
1021
|
+
// 아래는 뷰포트만 변경되었을 때 동작해야하는 로직이 있으므로 아래와 같이 조건문을 건다.
|
|
1022
|
+
// 패널 쪽에서는 리사이즈 감지에 resizeObserver를 사용하지 않는 경우가 없으므로 이 조건은 곧 뷰포트만 리사이즈가 된 경우를 의미한다.
|
|
1023
|
+
var isResizedViewportOnly = entries.find(function (e) {
|
|
1024
|
+
return e.target === flicking.element;
|
|
1025
|
+
}) && entries.length === 1;
|
|
1026
|
+
// 참고: resizeObserver를 사용하지 않은 경우에는 entries.length가 0으로 오는데 이 경우에는 그냥 항상 리사이즈가 진행되도록 한다.
|
|
1027
|
+
// (vw, vh 등을 사용하는 경우 이상 동작이 발생할 여지가 있기 때문이다)
|
|
1028
|
+
if (isResizedViewportOnly) {
|
|
1029
|
+
// resize 이벤트가 발생했으나 이전과 width, height의 변화가 없다면 이후 로직을 진행하지 않는다.
|
|
1010
1030
|
var beforeSize = {
|
|
1011
1031
|
width: flicking.viewport.width,
|
|
1012
1032
|
height: flicking.viewport.height
|
|
1013
1033
|
};
|
|
1014
|
-
|
|
1015
|
-
width: resizeEntryInfo.width,
|
|
1016
|
-
height: resizeEntryInfo.height
|
|
1017
|
-
});
|
|
1018
|
-
var new_afterSize = {
|
|
1034
|
+
var afterSize = {
|
|
1019
1035
|
width: getElementSize({
|
|
1020
|
-
el:
|
|
1036
|
+
el: resizedViewportElement,
|
|
1021
1037
|
horizontal: true,
|
|
1022
1038
|
useFractionalSize: _this._flicking.useFractionalSize,
|
|
1023
1039
|
useOffset: false,
|
|
1024
|
-
style: getStyle(
|
|
1040
|
+
style: getStyle(resizedViewportElement)
|
|
1025
1041
|
}),
|
|
1026
1042
|
height: getElementSize({
|
|
1027
|
-
el:
|
|
1043
|
+
el: resizedViewportElement,
|
|
1028
1044
|
horizontal: false,
|
|
1029
1045
|
useFractionalSize: _this._flicking.useFractionalSize,
|
|
1030
1046
|
useOffset: false,
|
|
1031
|
-
style: getStyle(
|
|
1047
|
+
style: getStyle(resizedViewportElement)
|
|
1032
1048
|
})
|
|
1033
1049
|
};
|
|
1034
|
-
|
|
1035
|
-
if (beforeSize.height === new_afterSize.height && beforeSize.width === new_afterSize.width) {
|
|
1050
|
+
if (beforeSize.height === afterSize.height && beforeSize.width === afterSize.width) {
|
|
1036
1051
|
return;
|
|
1037
1052
|
}
|
|
1038
1053
|
}
|
|
@@ -1084,7 +1099,6 @@ version: 4.12.1-beta.5
|
|
|
1084
1099
|
configurable: true
|
|
1085
1100
|
});
|
|
1086
1101
|
__proto.enable = function () {
|
|
1087
|
-
var _this = this;
|
|
1088
1102
|
var flicking = this._flicking;
|
|
1089
1103
|
var viewport = flicking.viewport;
|
|
1090
1104
|
if (this._enabled) {
|
|
@@ -1092,32 +1106,55 @@ version: 4.12.1-beta.5
|
|
|
1092
1106
|
}
|
|
1093
1107
|
if (flicking.useResizeObserver && !!window.ResizeObserver) {
|
|
1094
1108
|
var viewportSizeNot0 = viewport.width !== 0 || viewport.height !== 0;
|
|
1095
|
-
var resizeObserver = viewportSizeNot0 ? new ResizeObserver(
|
|
1096
|
-
return _this._skipFirstResize(entries);
|
|
1097
|
-
}) : new ResizeObserver(function (entries) {
|
|
1098
|
-
return _this._onResize(entries);
|
|
1099
|
-
});
|
|
1100
|
-
resizeObserver.observe(flicking.viewport.element);
|
|
1109
|
+
var resizeObserver = viewportSizeNot0 ? new ResizeObserver(this._skipFirstResize) : new ResizeObserver(this._onResize);
|
|
1101
1110
|
this._resizeObserver = resizeObserver;
|
|
1111
|
+
this.observe(flicking.viewport.element);
|
|
1112
|
+
if (flicking.observePanelResize) {
|
|
1113
|
+
this.observePanels();
|
|
1114
|
+
}
|
|
1102
1115
|
} else {
|
|
1103
|
-
window.addEventListener("resize",
|
|
1104
|
-
return _this._onResize([]);
|
|
1105
|
-
});
|
|
1116
|
+
window.addEventListener("resize", this._onResizeWrapper);
|
|
1106
1117
|
}
|
|
1107
1118
|
this._enabled = true;
|
|
1108
1119
|
return this;
|
|
1109
1120
|
};
|
|
1110
|
-
__proto.
|
|
1121
|
+
__proto.observePanels = function () {
|
|
1122
|
+
var _this = this;
|
|
1123
|
+
this._flicking.panels.forEach(function (panel) {
|
|
1124
|
+
_this.observe(panel.element);
|
|
1125
|
+
});
|
|
1126
|
+
return this;
|
|
1127
|
+
};
|
|
1128
|
+
__proto.unobservePanels = function () {
|
|
1111
1129
|
var _this = this;
|
|
1130
|
+
this._flicking.panels.forEach(function (panel) {
|
|
1131
|
+
_this.unobserve(panel.element);
|
|
1132
|
+
});
|
|
1133
|
+
return this;
|
|
1134
|
+
};
|
|
1135
|
+
__proto.observe = function (element) {
|
|
1136
|
+
var resizeObserver = this._resizeObserver;
|
|
1137
|
+
if (!resizeObserver) return this;
|
|
1138
|
+
resizeObserver.observe(element);
|
|
1139
|
+
return this;
|
|
1140
|
+
};
|
|
1141
|
+
__proto.unobserve = function (element) {
|
|
1142
|
+
var resizeObserver = this._resizeObserver;
|
|
1143
|
+
if (!resizeObserver) return this;
|
|
1144
|
+
resizeObserver.unobserve(element);
|
|
1145
|
+
if (this._flicking.observePanelResize) {
|
|
1146
|
+
this.unobservePanels();
|
|
1147
|
+
}
|
|
1148
|
+
return this;
|
|
1149
|
+
};
|
|
1150
|
+
__proto.disable = function () {
|
|
1112
1151
|
if (!this._enabled) return this;
|
|
1113
1152
|
var resizeObserver = this._resizeObserver;
|
|
1114
1153
|
if (resizeObserver) {
|
|
1115
1154
|
resizeObserver.disconnect();
|
|
1116
1155
|
this._resizeObserver = null;
|
|
1117
1156
|
} else {
|
|
1118
|
-
window.removeEventListener("resize",
|
|
1119
|
-
return _this._onResize([]);
|
|
1120
|
-
});
|
|
1157
|
+
window.removeEventListener("resize", this._onResizeWrapper);
|
|
1121
1158
|
}
|
|
1122
1159
|
this._enabled = false;
|
|
1123
1160
|
return this;
|
|
@@ -4949,6 +4986,18 @@ version: 4.12.1-beta.5
|
|
|
4949
4986
|
var activePanel = control.activePanel;
|
|
4950
4987
|
// Update camera & control
|
|
4951
4988
|
this._updateCameraAndControl();
|
|
4989
|
+
if (flicking.autoResize && flicking.useResizeObserver) {
|
|
4990
|
+
panelsAdded.forEach(function (panel) {
|
|
4991
|
+
if (panel.element) {
|
|
4992
|
+
flicking.autoResizer.observe(panel.element);
|
|
4993
|
+
}
|
|
4994
|
+
});
|
|
4995
|
+
panelsRemoved.forEach(function (panel) {
|
|
4996
|
+
if (panel.element) {
|
|
4997
|
+
flicking.autoResizer.unobserve(panel.element);
|
|
4998
|
+
}
|
|
4999
|
+
});
|
|
5000
|
+
}
|
|
4952
5001
|
void this.render();
|
|
4953
5002
|
if (!flicking.animating) {
|
|
4954
5003
|
if (!activePanel || activePanel.removed) {
|
|
@@ -6240,16 +6289,18 @@ version: 4.12.1-beta.5
|
|
|
6240
6289
|
useResizeObserver = _9 === void 0 ? true : _9,
|
|
6241
6290
|
_10 = _b.resizeDebounce,
|
|
6242
6291
|
resizeDebounce = _10 === void 0 ? 0 : _10,
|
|
6243
|
-
_11 = _b.
|
|
6244
|
-
|
|
6245
|
-
_12 = _b.
|
|
6246
|
-
|
|
6247
|
-
_13 = _b.
|
|
6248
|
-
|
|
6249
|
-
_14 = _b.
|
|
6250
|
-
|
|
6251
|
-
_15 = _b.
|
|
6252
|
-
|
|
6292
|
+
_11 = _b.observePanelResize,
|
|
6293
|
+
observePanelResize = _11 === void 0 ? false : _11,
|
|
6294
|
+
_12 = _b.maxResizeDebounce,
|
|
6295
|
+
maxResizeDebounce = _12 === void 0 ? 100 : _12,
|
|
6296
|
+
_13 = _b.useFractionalSize,
|
|
6297
|
+
useFractionalSize = _13 === void 0 ? false : _13,
|
|
6298
|
+
_14 = _b.externalRenderer,
|
|
6299
|
+
externalRenderer = _14 === void 0 ? null : _14,
|
|
6300
|
+
_15 = _b.renderExternal,
|
|
6301
|
+
renderExternal = _15 === void 0 ? null : _15,
|
|
6302
|
+
_16 = _b.optimizeSizeUpdate,
|
|
6303
|
+
optimizeSizeUpdate = _16 === void 0 ? false : _16;
|
|
6253
6304
|
var _this = _super.call(this) || this;
|
|
6254
6305
|
// Internal states
|
|
6255
6306
|
_this._initialized = false;
|
|
@@ -6290,6 +6341,7 @@ version: 4.12.1-beta.5
|
|
|
6290
6341
|
_this._useResizeObserver = useResizeObserver;
|
|
6291
6342
|
_this._resizeDebounce = resizeDebounce;
|
|
6292
6343
|
_this._maxResizeDebounce = maxResizeDebounce;
|
|
6344
|
+
_this._observePanelResize = observePanelResize;
|
|
6293
6345
|
_this._useFractionalSize = useFractionalSize;
|
|
6294
6346
|
_this._externalRenderer = externalRenderer;
|
|
6295
6347
|
_this._renderExternal = renderExternal;
|
|
@@ -6374,6 +6426,19 @@ version: 4.12.1-beta.5
|
|
|
6374
6426
|
enumerable: false,
|
|
6375
6427
|
configurable: true
|
|
6376
6428
|
});
|
|
6429
|
+
Object.defineProperty(__proto, "autoResizer", {
|
|
6430
|
+
/**
|
|
6431
|
+
* {@link AutoResizer} instance of the Flicking
|
|
6432
|
+
* @ko 현재 Flicking에 활성화된 {@link AutoResizer} 인스턴스
|
|
6433
|
+
* @internal
|
|
6434
|
+
* @readonly
|
|
6435
|
+
*/
|
|
6436
|
+
get: function () {
|
|
6437
|
+
return this._autoResizer;
|
|
6438
|
+
},
|
|
6439
|
+
enumerable: false,
|
|
6440
|
+
configurable: true
|
|
6441
|
+
});
|
|
6377
6442
|
Object.defineProperty(__proto, "initialized", {
|
|
6378
6443
|
// Internal States
|
|
6379
6444
|
/**
|
|
@@ -7247,6 +7312,9 @@ version: 4.12.1-beta.5
|
|
|
7247
7312
|
// OTHERS
|
|
7248
7313
|
set: function (val) {
|
|
7249
7314
|
this._autoResize = val;
|
|
7315
|
+
if (!this._initialized) {
|
|
7316
|
+
return;
|
|
7317
|
+
}
|
|
7250
7318
|
if (val) {
|
|
7251
7319
|
this._autoResizer.enable();
|
|
7252
7320
|
} else {
|
|
@@ -7269,13 +7337,38 @@ version: 4.12.1-beta.5
|
|
|
7269
7337
|
},
|
|
7270
7338
|
set: function (val) {
|
|
7271
7339
|
this._useResizeObserver = val;
|
|
7272
|
-
if (this._autoResize) {
|
|
7340
|
+
if (this._initialized && this._autoResize) {
|
|
7273
7341
|
this._autoResizer.enable();
|
|
7274
7342
|
}
|
|
7275
7343
|
},
|
|
7276
7344
|
enumerable: false,
|
|
7277
7345
|
configurable: true
|
|
7278
7346
|
});
|
|
7347
|
+
Object.defineProperty(__proto, "observePanelResize", {
|
|
7348
|
+
/**
|
|
7349
|
+
* Whether to use {@link https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver ResizeObserver} to observe the size of the panel element
|
|
7350
|
+
* This is only available when `useResizeObserver` is enabled.
|
|
7351
|
+
* This option garantees that the resize event is triggered when the size of the panel element is changed.
|
|
7352
|
+
* @ko 이 옵션을 활성화할 경우, {@link https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver ResizeObserver}를 사용하여 패널 엘리먼트의 크기를 추적합니다.
|
|
7353
|
+
* 이 옵션은 `useResizeObserver` 옵션이 활성화된 경우에만 사용할 수 있습니다.
|
|
7354
|
+
* 이 옵션은 패널 엘리먼트의 크기가 변경될 경우 resize 이벤트가 발생하도록 보장합니다.
|
|
7355
|
+
*/
|
|
7356
|
+
get: function () {
|
|
7357
|
+
return this._observePanelResize;
|
|
7358
|
+
},
|
|
7359
|
+
set: function (val) {
|
|
7360
|
+
this._observePanelResize = val;
|
|
7361
|
+
if (this._initialized && this._autoResize) {
|
|
7362
|
+
if (val) {
|
|
7363
|
+
this._autoResizer.observePanels();
|
|
7364
|
+
} else {
|
|
7365
|
+
this._autoResizer.unobservePanels();
|
|
7366
|
+
}
|
|
7367
|
+
}
|
|
7368
|
+
},
|
|
7369
|
+
enumerable: false,
|
|
7370
|
+
configurable: true
|
|
7371
|
+
});
|
|
7279
7372
|
Object.defineProperty(__proto, "resizeDebounce", {
|
|
7280
7373
|
/**
|
|
7281
7374
|
* Delays size recalculation from `autoResize` by the given time in milisecond.
|
|
@@ -7357,6 +7450,30 @@ version: 4.12.1-beta.5
|
|
|
7357
7450
|
enumerable: false,
|
|
7358
7451
|
configurable: true
|
|
7359
7452
|
});
|
|
7453
|
+
Object.defineProperty(__proto, "optimizeSizeUpdate", {
|
|
7454
|
+
/**
|
|
7455
|
+
* This option works only when autoResize is set to true.
|
|
7456
|
+
* By default, autoResize listens to changes in both the viewport's width and height, updating all panel sizes accordingly.
|
|
7457
|
+
* When optimizeSizeUpdate is enabled, the update behavior is optimized based on the flicking direction:
|
|
7458
|
+
* If direction is "horizontal", only changes in width will trigger panel size updates.
|
|
7459
|
+
* If direction is "vertical", only changes in height will do so.
|
|
7460
|
+
* This option is useful when panel heights vary and unwanted flickering occurs due to frequent size recalculations during flicking. Enabling optimizeSizeUpdate prevents unnecessary updates and helps maintain visual stability.
|
|
7461
|
+
* @ko optimizeSizeUpdate는 autoResize가 true일 때만 동작합니다.
|
|
7462
|
+
* 기본적으로 autoResize는 뷰포트의 width와 height 변화를 모두 감지하여 패널들의 사이즈를 업데이트합니다.
|
|
7463
|
+
* 이 옵션을 활성화하면 플리킹 방향에 따라 필요한 차원(horizontal → width, vertical → height)에 대해서만 사이즈를 업데이트합니다.
|
|
7464
|
+
* 내부 패널의 높이가 서로 다를 때, 플리킹 중 과도한 리사이징으로 인한 깜빡임 현상을 줄이는 데 유용합니다.
|
|
7465
|
+
* @type {boolean}
|
|
7466
|
+
* @default false
|
|
7467
|
+
*/
|
|
7468
|
+
get: function () {
|
|
7469
|
+
return this._optimizeSizeUpdate;
|
|
7470
|
+
},
|
|
7471
|
+
set: function (val) {
|
|
7472
|
+
this._optimizeSizeUpdate = val;
|
|
7473
|
+
},
|
|
7474
|
+
enumerable: false,
|
|
7475
|
+
configurable: true
|
|
7476
|
+
});
|
|
7360
7477
|
/**
|
|
7361
7478
|
* Initialize Flicking and move to the default index
|
|
7362
7479
|
* This is automatically called on Flicking's constructor when `autoInit` is true(default)
|
|
@@ -7815,7 +7932,7 @@ version: 4.12.1-beta.5
|
|
|
7815
7932
|
if (!(this.horizontal && viewport.width !== prevWidth || !this.horizontal && viewport.height !== prevHeight)) return [3 /*break*/, 2];
|
|
7816
7933
|
return [4 /*yield*/, renderer.forceRenderAllPanels()];
|
|
7817
7934
|
case 1:
|
|
7818
|
-
_a.sent();
|
|
7935
|
+
_a.sent();
|
|
7819
7936
|
_a.label = 2;
|
|
7820
7937
|
case 2:
|
|
7821
7938
|
return [3 /*break*/, 5];
|
|
@@ -7988,7 +8105,7 @@ version: 4.12.1-beta.5
|
|
|
7988
8105
|
__proto._createCamera = function () {
|
|
7989
8106
|
if (this._circular && this._bound) {
|
|
7990
8107
|
// eslint-disable-next-line no-console
|
|
7991
|
-
console.warn(
|
|
8108
|
+
console.warn("\"circular\" and \"bound\" option cannot be used together, ignoring bound.");
|
|
7992
8109
|
}
|
|
7993
8110
|
return new Camera$1(this, {
|
|
7994
8111
|
align: this._align
|
|
@@ -7998,7 +8115,7 @@ version: 4.12.1-beta.5
|
|
|
7998
8115
|
var externalRenderer = this._externalRenderer;
|
|
7999
8116
|
if (this._virtual && this._panelsPerView <= 0) {
|
|
8000
8117
|
// eslint-disable-next-line no-console
|
|
8001
|
-
console.warn(
|
|
8118
|
+
console.warn("\"virtual\" and \"panelsPerView\" option should be used together, ignoring virtual.");
|
|
8002
8119
|
}
|
|
8003
8120
|
return externalRenderer ? externalRenderer : this._renderExternal ? this._createExternalRenderer() : this._createVanillaRenderer();
|
|
8004
8121
|
};
|
|
@@ -8080,7 +8197,7 @@ version: 4.12.1-beta.5
|
|
|
8080
8197
|
* Flicking.VERSION; // ex) 4.0.0
|
|
8081
8198
|
* ```
|
|
8082
8199
|
*/
|
|
8083
|
-
Flicking.VERSION = "4.
|
|
8200
|
+
Flicking.VERSION = "4.13.0";
|
|
8084
8201
|
return Flicking;
|
|
8085
8202
|
}(Component);
|
|
8086
8203
|
|