@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.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.13.0
|
|
8
8
|
*/
|
|
9
9
|
import Component, { ComponentEvent } from '@egjs/component';
|
|
10
10
|
import Axes, { PanInput } from '@egjs/axes';
|
|
@@ -672,6 +672,9 @@ var getProgress = function (pos, prev, next) {
|
|
|
672
672
|
};
|
|
673
673
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
674
674
|
var getStyle = function (el) {
|
|
675
|
+
if (!el) {
|
|
676
|
+
return {};
|
|
677
|
+
}
|
|
675
678
|
return window.getComputedStyle(el) || el.currentStyle;
|
|
676
679
|
};
|
|
677
680
|
var setSize = function (el, _a) {
|
|
@@ -948,41 +951,53 @@ var Viewport = /*#__PURE__*/function () {
|
|
|
948
951
|
* Copyright (c) 2015 NAVER Corp.
|
|
949
952
|
* egjs projects are licensed under the MIT license
|
|
950
953
|
*/
|
|
954
|
+
/**
|
|
955
|
+
* A component that detects size change and trigger resize method when the autoResize option is used
|
|
956
|
+
* @ko autoResize 옵션을 사용할 때 크기 변화를 감지하고 Flicking의 resize를 호출하는 컴포넌트
|
|
957
|
+
*/
|
|
951
958
|
var AutoResizer = /*#__PURE__*/function () {
|
|
959
|
+
/** */
|
|
952
960
|
function AutoResizer(flicking) {
|
|
953
961
|
var _this = this;
|
|
962
|
+
this._onResizeWrapper = function () {
|
|
963
|
+
_this._onResize([]);
|
|
964
|
+
};
|
|
954
965
|
this._onResize = function (entries) {
|
|
955
966
|
var flicking = _this._flicking;
|
|
956
967
|
var resizeDebounce = flicking.resizeDebounce;
|
|
957
968
|
var maxResizeDebounce = flicking.maxResizeDebounce;
|
|
958
|
-
|
|
959
|
-
|
|
969
|
+
var resizedViewportElement = flicking.element;
|
|
970
|
+
// 현재 구현에서 리사이즈 옵저빙 대상은 패널과 뷰포트 2개만 존재.
|
|
971
|
+
// 아래는 뷰포트만 변경되었을 때 동작해야하는 로직이 있으므로 아래와 같이 조건문을 건다.
|
|
972
|
+
// 패널 쪽에서는 리사이즈 감지에 resizeObserver를 사용하지 않는 경우가 없으므로 이 조건은 곧 뷰포트만 리사이즈가 된 경우를 의미한다.
|
|
973
|
+
var isResizedViewportOnly = entries.find(function (e) {
|
|
974
|
+
return e.target === flicking.element;
|
|
975
|
+
}) && entries.length === 1;
|
|
976
|
+
// 참고: resizeObserver를 사용하지 않은 경우에는 entries.length가 0으로 오는데 이 경우에는 그냥 항상 리사이즈가 진행되도록 한다.
|
|
977
|
+
// (vw, vh 등을 사용하는 경우 이상 동작이 발생할 여지가 있기 때문이다)
|
|
978
|
+
if (isResizedViewportOnly) {
|
|
979
|
+
// resize 이벤트가 발생했으나 이전과 width, height의 변화가 없다면 이후 로직을 진행하지 않는다.
|
|
960
980
|
var beforeSize = {
|
|
961
981
|
width: flicking.viewport.width,
|
|
962
982
|
height: flicking.viewport.height
|
|
963
983
|
};
|
|
964
|
-
|
|
965
|
-
width: resizeEntryInfo.width,
|
|
966
|
-
height: resizeEntryInfo.height
|
|
967
|
-
});
|
|
968
|
-
var new_afterSize = {
|
|
984
|
+
var afterSize = {
|
|
969
985
|
width: getElementSize({
|
|
970
|
-
el:
|
|
986
|
+
el: resizedViewportElement,
|
|
971
987
|
horizontal: true,
|
|
972
988
|
useFractionalSize: _this._flicking.useFractionalSize,
|
|
973
989
|
useOffset: false,
|
|
974
|
-
style: getStyle(
|
|
990
|
+
style: getStyle(resizedViewportElement)
|
|
975
991
|
}),
|
|
976
992
|
height: getElementSize({
|
|
977
|
-
el:
|
|
993
|
+
el: resizedViewportElement,
|
|
978
994
|
horizontal: false,
|
|
979
995
|
useFractionalSize: _this._flicking.useFractionalSize,
|
|
980
996
|
useOffset: false,
|
|
981
|
-
style: getStyle(
|
|
997
|
+
style: getStyle(resizedViewportElement)
|
|
982
998
|
})
|
|
983
999
|
};
|
|
984
|
-
|
|
985
|
-
if (beforeSize.height === new_afterSize.height && beforeSize.width === new_afterSize.width) {
|
|
1000
|
+
if (beforeSize.height === afterSize.height && beforeSize.width === afterSize.width) {
|
|
986
1001
|
return;
|
|
987
1002
|
}
|
|
988
1003
|
}
|
|
@@ -1034,7 +1049,6 @@ var AutoResizer = /*#__PURE__*/function () {
|
|
|
1034
1049
|
configurable: true
|
|
1035
1050
|
});
|
|
1036
1051
|
__proto.enable = function () {
|
|
1037
|
-
var _this = this;
|
|
1038
1052
|
var flicking = this._flicking;
|
|
1039
1053
|
var viewport = flicking.viewport;
|
|
1040
1054
|
if (this._enabled) {
|
|
@@ -1042,32 +1056,55 @@ var AutoResizer = /*#__PURE__*/function () {
|
|
|
1042
1056
|
}
|
|
1043
1057
|
if (flicking.useResizeObserver && !!window.ResizeObserver) {
|
|
1044
1058
|
var viewportSizeNot0 = viewport.width !== 0 || viewport.height !== 0;
|
|
1045
|
-
var resizeObserver = viewportSizeNot0 ? new ResizeObserver(
|
|
1046
|
-
return _this._skipFirstResize(entries);
|
|
1047
|
-
}) : new ResizeObserver(function (entries) {
|
|
1048
|
-
return _this._onResize(entries);
|
|
1049
|
-
});
|
|
1050
|
-
resizeObserver.observe(flicking.viewport.element);
|
|
1059
|
+
var resizeObserver = viewportSizeNot0 ? new ResizeObserver(this._skipFirstResize) : new ResizeObserver(this._onResize);
|
|
1051
1060
|
this._resizeObserver = resizeObserver;
|
|
1061
|
+
this.observe(flicking.viewport.element);
|
|
1062
|
+
if (flicking.observePanelResize) {
|
|
1063
|
+
this.observePanels();
|
|
1064
|
+
}
|
|
1052
1065
|
} else {
|
|
1053
|
-
window.addEventListener("resize",
|
|
1054
|
-
return _this._onResize([]);
|
|
1055
|
-
});
|
|
1066
|
+
window.addEventListener("resize", this._onResizeWrapper);
|
|
1056
1067
|
}
|
|
1057
1068
|
this._enabled = true;
|
|
1058
1069
|
return this;
|
|
1059
1070
|
};
|
|
1060
|
-
__proto.
|
|
1071
|
+
__proto.observePanels = function () {
|
|
1072
|
+
var _this = this;
|
|
1073
|
+
this._flicking.panels.forEach(function (panel) {
|
|
1074
|
+
_this.observe(panel.element);
|
|
1075
|
+
});
|
|
1076
|
+
return this;
|
|
1077
|
+
};
|
|
1078
|
+
__proto.unobservePanels = function () {
|
|
1061
1079
|
var _this = this;
|
|
1080
|
+
this._flicking.panels.forEach(function (panel) {
|
|
1081
|
+
_this.unobserve(panel.element);
|
|
1082
|
+
});
|
|
1083
|
+
return this;
|
|
1084
|
+
};
|
|
1085
|
+
__proto.observe = function (element) {
|
|
1086
|
+
var resizeObserver = this._resizeObserver;
|
|
1087
|
+
if (!resizeObserver) return this;
|
|
1088
|
+
resizeObserver.observe(element);
|
|
1089
|
+
return this;
|
|
1090
|
+
};
|
|
1091
|
+
__proto.unobserve = function (element) {
|
|
1092
|
+
var resizeObserver = this._resizeObserver;
|
|
1093
|
+
if (!resizeObserver) return this;
|
|
1094
|
+
resizeObserver.unobserve(element);
|
|
1095
|
+
if (this._flicking.observePanelResize) {
|
|
1096
|
+
this.unobservePanels();
|
|
1097
|
+
}
|
|
1098
|
+
return this;
|
|
1099
|
+
};
|
|
1100
|
+
__proto.disable = function () {
|
|
1062
1101
|
if (!this._enabled) return this;
|
|
1063
1102
|
var resizeObserver = this._resizeObserver;
|
|
1064
1103
|
if (resizeObserver) {
|
|
1065
1104
|
resizeObserver.disconnect();
|
|
1066
1105
|
this._resizeObserver = null;
|
|
1067
1106
|
} else {
|
|
1068
|
-
window.removeEventListener("resize",
|
|
1069
|
-
return _this._onResize([]);
|
|
1070
|
-
});
|
|
1107
|
+
window.removeEventListener("resize", this._onResizeWrapper);
|
|
1071
1108
|
}
|
|
1072
1109
|
this._enabled = false;
|
|
1073
1110
|
return this;
|
|
@@ -4865,6 +4902,18 @@ var Renderer = /*#__PURE__*/function () {
|
|
|
4865
4902
|
var activePanel = control.activePanel;
|
|
4866
4903
|
// Update camera & control
|
|
4867
4904
|
this._updateCameraAndControl();
|
|
4905
|
+
if (flicking.autoResize && flicking.useResizeObserver) {
|
|
4906
|
+
panelsAdded.forEach(function (panel) {
|
|
4907
|
+
if (panel.element) {
|
|
4908
|
+
flicking.autoResizer.observe(panel.element);
|
|
4909
|
+
}
|
|
4910
|
+
});
|
|
4911
|
+
panelsRemoved.forEach(function (panel) {
|
|
4912
|
+
if (panel.element) {
|
|
4913
|
+
flicking.autoResizer.unobserve(panel.element);
|
|
4914
|
+
}
|
|
4915
|
+
});
|
|
4916
|
+
}
|
|
4868
4917
|
void this.render();
|
|
4869
4918
|
if (!flicking.animating) {
|
|
4870
4919
|
if (!activePanel || activePanel.removed) {
|
|
@@ -6142,16 +6191,18 @@ var Flicking = /*#__PURE__*/function (_super) {
|
|
|
6142
6191
|
useResizeObserver = _9 === void 0 ? true : _9,
|
|
6143
6192
|
_10 = _b.resizeDebounce,
|
|
6144
6193
|
resizeDebounce = _10 === void 0 ? 0 : _10,
|
|
6145
|
-
_11 = _b.
|
|
6146
|
-
|
|
6147
|
-
_12 = _b.
|
|
6148
|
-
|
|
6149
|
-
_13 = _b.
|
|
6150
|
-
|
|
6151
|
-
_14 = _b.
|
|
6152
|
-
|
|
6153
|
-
_15 = _b.
|
|
6154
|
-
|
|
6194
|
+
_11 = _b.observePanelResize,
|
|
6195
|
+
observePanelResize = _11 === void 0 ? false : _11,
|
|
6196
|
+
_12 = _b.maxResizeDebounce,
|
|
6197
|
+
maxResizeDebounce = _12 === void 0 ? 100 : _12,
|
|
6198
|
+
_13 = _b.useFractionalSize,
|
|
6199
|
+
useFractionalSize = _13 === void 0 ? false : _13,
|
|
6200
|
+
_14 = _b.externalRenderer,
|
|
6201
|
+
externalRenderer = _14 === void 0 ? null : _14,
|
|
6202
|
+
_15 = _b.renderExternal,
|
|
6203
|
+
renderExternal = _15 === void 0 ? null : _15,
|
|
6204
|
+
_16 = _b.optimizeSizeUpdate,
|
|
6205
|
+
optimizeSizeUpdate = _16 === void 0 ? false : _16;
|
|
6155
6206
|
var _this = _super.call(this) || this;
|
|
6156
6207
|
// Internal states
|
|
6157
6208
|
_this._initialized = false;
|
|
@@ -6192,6 +6243,7 @@ var Flicking = /*#__PURE__*/function (_super) {
|
|
|
6192
6243
|
_this._useResizeObserver = useResizeObserver;
|
|
6193
6244
|
_this._resizeDebounce = resizeDebounce;
|
|
6194
6245
|
_this._maxResizeDebounce = maxResizeDebounce;
|
|
6246
|
+
_this._observePanelResize = observePanelResize;
|
|
6195
6247
|
_this._useFractionalSize = useFractionalSize;
|
|
6196
6248
|
_this._externalRenderer = externalRenderer;
|
|
6197
6249
|
_this._renderExternal = renderExternal;
|
|
@@ -6276,6 +6328,19 @@ var Flicking = /*#__PURE__*/function (_super) {
|
|
|
6276
6328
|
enumerable: false,
|
|
6277
6329
|
configurable: true
|
|
6278
6330
|
});
|
|
6331
|
+
Object.defineProperty(__proto, "autoResizer", {
|
|
6332
|
+
/**
|
|
6333
|
+
* {@link AutoResizer} instance of the Flicking
|
|
6334
|
+
* @ko 현재 Flicking에 활성화된 {@link AutoResizer} 인스턴스
|
|
6335
|
+
* @internal
|
|
6336
|
+
* @readonly
|
|
6337
|
+
*/
|
|
6338
|
+
get: function () {
|
|
6339
|
+
return this._autoResizer;
|
|
6340
|
+
},
|
|
6341
|
+
enumerable: false,
|
|
6342
|
+
configurable: true
|
|
6343
|
+
});
|
|
6279
6344
|
Object.defineProperty(__proto, "initialized", {
|
|
6280
6345
|
// Internal States
|
|
6281
6346
|
/**
|
|
@@ -7149,6 +7214,9 @@ var Flicking = /*#__PURE__*/function (_super) {
|
|
|
7149
7214
|
// OTHERS
|
|
7150
7215
|
set: function (val) {
|
|
7151
7216
|
this._autoResize = val;
|
|
7217
|
+
if (!this._initialized) {
|
|
7218
|
+
return;
|
|
7219
|
+
}
|
|
7152
7220
|
if (val) {
|
|
7153
7221
|
this._autoResizer.enable();
|
|
7154
7222
|
} else {
|
|
@@ -7171,13 +7239,38 @@ var Flicking = /*#__PURE__*/function (_super) {
|
|
|
7171
7239
|
},
|
|
7172
7240
|
set: function (val) {
|
|
7173
7241
|
this._useResizeObserver = val;
|
|
7174
|
-
if (this._autoResize) {
|
|
7242
|
+
if (this._initialized && this._autoResize) {
|
|
7175
7243
|
this._autoResizer.enable();
|
|
7176
7244
|
}
|
|
7177
7245
|
},
|
|
7178
7246
|
enumerable: false,
|
|
7179
7247
|
configurable: true
|
|
7180
7248
|
});
|
|
7249
|
+
Object.defineProperty(__proto, "observePanelResize", {
|
|
7250
|
+
/**
|
|
7251
|
+
* Whether to use {@link https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver ResizeObserver} to observe the size of the panel element
|
|
7252
|
+
* This is only available when `useResizeObserver` is enabled.
|
|
7253
|
+
* This option garantees that the resize event is triggered when the size of the panel element is changed.
|
|
7254
|
+
* @ko 이 옵션을 활성화할 경우, {@link https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver ResizeObserver}를 사용하여 패널 엘리먼트의 크기를 추적합니다.
|
|
7255
|
+
* 이 옵션은 `useResizeObserver` 옵션이 활성화된 경우에만 사용할 수 있습니다.
|
|
7256
|
+
* 이 옵션은 패널 엘리먼트의 크기가 변경될 경우 resize 이벤트가 발생하도록 보장합니다.
|
|
7257
|
+
*/
|
|
7258
|
+
get: function () {
|
|
7259
|
+
return this._observePanelResize;
|
|
7260
|
+
},
|
|
7261
|
+
set: function (val) {
|
|
7262
|
+
this._observePanelResize = val;
|
|
7263
|
+
if (this._initialized && this._autoResize) {
|
|
7264
|
+
if (val) {
|
|
7265
|
+
this._autoResizer.observePanels();
|
|
7266
|
+
} else {
|
|
7267
|
+
this._autoResizer.unobservePanels();
|
|
7268
|
+
}
|
|
7269
|
+
}
|
|
7270
|
+
},
|
|
7271
|
+
enumerable: false,
|
|
7272
|
+
configurable: true
|
|
7273
|
+
});
|
|
7181
7274
|
Object.defineProperty(__proto, "resizeDebounce", {
|
|
7182
7275
|
/**
|
|
7183
7276
|
* Delays size recalculation from `autoResize` by the given time in milisecond.
|
|
@@ -7259,6 +7352,30 @@ var Flicking = /*#__PURE__*/function (_super) {
|
|
|
7259
7352
|
enumerable: false,
|
|
7260
7353
|
configurable: true
|
|
7261
7354
|
});
|
|
7355
|
+
Object.defineProperty(__proto, "optimizeSizeUpdate", {
|
|
7356
|
+
/**
|
|
7357
|
+
* This option works only when autoResize is set to true.
|
|
7358
|
+
* By default, autoResize listens to changes in both the viewport's width and height, updating all panel sizes accordingly.
|
|
7359
|
+
* When optimizeSizeUpdate is enabled, the update behavior is optimized based on the flicking direction:
|
|
7360
|
+
* If direction is "horizontal", only changes in width will trigger panel size updates.
|
|
7361
|
+
* If direction is "vertical", only changes in height will do so.
|
|
7362
|
+
* 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.
|
|
7363
|
+
* @ko optimizeSizeUpdate는 autoResize가 true일 때만 동작합니다.
|
|
7364
|
+
* 기본적으로 autoResize는 뷰포트의 width와 height 변화를 모두 감지하여 패널들의 사이즈를 업데이트합니다.
|
|
7365
|
+
* 이 옵션을 활성화하면 플리킹 방향에 따라 필요한 차원(horizontal → width, vertical → height)에 대해서만 사이즈를 업데이트합니다.
|
|
7366
|
+
* 내부 패널의 높이가 서로 다를 때, 플리킹 중 과도한 리사이징으로 인한 깜빡임 현상을 줄이는 데 유용합니다.
|
|
7367
|
+
* @type {boolean}
|
|
7368
|
+
* @default false
|
|
7369
|
+
*/
|
|
7370
|
+
get: function () {
|
|
7371
|
+
return this._optimizeSizeUpdate;
|
|
7372
|
+
},
|
|
7373
|
+
set: function (val) {
|
|
7374
|
+
this._optimizeSizeUpdate = val;
|
|
7375
|
+
},
|
|
7376
|
+
enumerable: false,
|
|
7377
|
+
configurable: true
|
|
7378
|
+
});
|
|
7262
7379
|
/**
|
|
7263
7380
|
* Initialize Flicking and move to the default index
|
|
7264
7381
|
* This is automatically called on Flicking's constructor when `autoInit` is true(default)
|
|
@@ -7717,7 +7834,7 @@ var Flicking = /*#__PURE__*/function (_super) {
|
|
|
7717
7834
|
if (!(this.horizontal && viewport.width !== prevWidth || !this.horizontal && viewport.height !== prevHeight)) return [3 /*break*/, 2];
|
|
7718
7835
|
return [4 /*yield*/, renderer.forceRenderAllPanels()];
|
|
7719
7836
|
case 1:
|
|
7720
|
-
_a.sent();
|
|
7837
|
+
_a.sent();
|
|
7721
7838
|
_a.label = 2;
|
|
7722
7839
|
case 2:
|
|
7723
7840
|
return [3 /*break*/, 5];
|
|
@@ -7890,7 +8007,7 @@ var Flicking = /*#__PURE__*/function (_super) {
|
|
|
7890
8007
|
__proto._createCamera = function () {
|
|
7891
8008
|
if (this._circular && this._bound) {
|
|
7892
8009
|
// eslint-disable-next-line no-console
|
|
7893
|
-
console.warn(
|
|
8010
|
+
console.warn("\"circular\" and \"bound\" option cannot be used together, ignoring bound.");
|
|
7894
8011
|
}
|
|
7895
8012
|
return new Camera(this, {
|
|
7896
8013
|
align: this._align
|
|
@@ -7900,7 +8017,7 @@ var Flicking = /*#__PURE__*/function (_super) {
|
|
|
7900
8017
|
var externalRenderer = this._externalRenderer;
|
|
7901
8018
|
if (this._virtual && this._panelsPerView <= 0) {
|
|
7902
8019
|
// eslint-disable-next-line no-console
|
|
7903
|
-
console.warn(
|
|
8020
|
+
console.warn("\"virtual\" and \"panelsPerView\" option should be used together, ignoring virtual.");
|
|
7904
8021
|
}
|
|
7905
8022
|
return externalRenderer ? externalRenderer : this._renderExternal ? this._createExternalRenderer() : this._createVanillaRenderer();
|
|
7906
8023
|
};
|
|
@@ -7982,7 +8099,7 @@ var Flicking = /*#__PURE__*/function (_super) {
|
|
|
7982
8099
|
* Flicking.VERSION; // ex) 4.0.0
|
|
7983
8100
|
* ```
|
|
7984
8101
|
*/
|
|
7985
|
-
Flicking.VERSION = "4.
|
|
8102
|
+
Flicking.VERSION = "4.13.0";
|
|
7986
8103
|
return Flicking;
|
|
7987
8104
|
}(Component);
|
|
7988
8105
|
|