@egjs/flicking 4.13.2-beta.0 → 4.14.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 +75 -0
- package/debug/reactive/index.html +240 -0
- package/declaration/Flicking.d.ts +12 -1
- package/declaration/control/Control.d.ts +1 -1
- package/declaration/core/AutoResizer.d.ts +5 -0
- package/declaration/index.d.ts +1 -0
- package/declaration/reactive/index.d.ts +25 -0
- package/dist/flicking.cjs.js +399 -33
- package/dist/flicking.cjs.js.map +1 -1
- package/dist/flicking.esm.js +393 -31
- package/dist/flicking.esm.js.map +1 -1
- package/dist/flicking.js +403 -35
- 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 +727 -49
- 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 +3 -2
- package/src/Flicking.ts +522 -153
- package/src/camera/mode/CameraMode.ts +2 -1
- package/src/control/Control.ts +1 -1
- package/src/control/SnapControl.ts +1 -8
- package/src/core/AutoResizer.ts +110 -11
- package/src/index.ts +1 -0
- package/src/index.umd.ts +2 -0
- package/src/reactive/index.ts +326 -0
- package/src/renderer/Renderer.ts +13 -0
- package/src/utils.ts +6 -1
package/dist/flicking.esm.js
CHANGED
|
@@ -4,11 +4,12 @@ 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.14.0
|
|
8
8
|
*/
|
|
9
9
|
import Component, { ComponentEvent } from '@egjs/component';
|
|
10
10
|
import Axes, { PanInput } from '@egjs/axes';
|
|
11
11
|
import ImReady from '@egjs/imready';
|
|
12
|
+
import { reactive, adaptReactive } from '@cfcs/core';
|
|
12
13
|
|
|
13
14
|
/******************************************************************************
|
|
14
15
|
Copyright (c) Microsoft Corporation.
|
|
@@ -667,11 +668,14 @@ var findIndex = function (array, checker) {
|
|
|
667
668
|
}
|
|
668
669
|
return -1;
|
|
669
670
|
};
|
|
670
|
-
var getProgress = function (pos, prev, next) {
|
|
671
|
+
var getProgress$1 = function (pos, prev, next) {
|
|
671
672
|
return (pos - prev) / (next - prev);
|
|
672
673
|
};
|
|
673
674
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
674
675
|
var getStyle = function (el) {
|
|
676
|
+
if (!el) {
|
|
677
|
+
return {};
|
|
678
|
+
}
|
|
675
679
|
return window.getComputedStyle(el) || el.currentStyle;
|
|
676
680
|
};
|
|
677
681
|
var setSize = function (el, _a) {
|
|
@@ -944,13 +948,59 @@ var Viewport = /*#__PURE__*/function () {
|
|
|
944
948
|
return Viewport;
|
|
945
949
|
}();
|
|
946
950
|
|
|
951
|
+
/*
|
|
952
|
+
* Copyright (c) 2015 NAVER Corp.
|
|
953
|
+
* egjs projects are licensed under the MIT license
|
|
954
|
+
*/
|
|
955
|
+
/**
|
|
956
|
+
* A component that detects size change and trigger resize method when the autoResize option is used
|
|
957
|
+
* @ko autoResize 옵션을 사용할 때 크기 변화를 감지하고 Flicking의 resize를 호출하는 컴포넌트
|
|
958
|
+
*/
|
|
947
959
|
var AutoResizer = /*#__PURE__*/function () {
|
|
948
960
|
function AutoResizer(flicking) {
|
|
949
961
|
var _this = this;
|
|
950
|
-
this.
|
|
962
|
+
this._onResizeWrapper = function () {
|
|
963
|
+
_this._onResize([]);
|
|
964
|
+
};
|
|
965
|
+
this._onResize = function (entries) {
|
|
951
966
|
var flicking = _this._flicking;
|
|
952
967
|
var resizeDebounce = flicking.resizeDebounce;
|
|
953
968
|
var maxResizeDebounce = flicking.maxResizeDebounce;
|
|
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의 변화가 없다면 이후 로직을 진행하지 않는다.
|
|
980
|
+
var beforeSize = {
|
|
981
|
+
width: flicking.viewport.width,
|
|
982
|
+
height: flicking.viewport.height
|
|
983
|
+
};
|
|
984
|
+
var afterSize = {
|
|
985
|
+
width: getElementSize({
|
|
986
|
+
el: resizedViewportElement,
|
|
987
|
+
horizontal: true,
|
|
988
|
+
useFractionalSize: _this._flicking.useFractionalSize,
|
|
989
|
+
useOffset: false,
|
|
990
|
+
style: getStyle(resizedViewportElement)
|
|
991
|
+
}),
|
|
992
|
+
height: getElementSize({
|
|
993
|
+
el: resizedViewportElement,
|
|
994
|
+
horizontal: false,
|
|
995
|
+
useFractionalSize: _this._flicking.useFractionalSize,
|
|
996
|
+
useOffset: false,
|
|
997
|
+
style: getStyle(resizedViewportElement)
|
|
998
|
+
})
|
|
999
|
+
};
|
|
1000
|
+
if (beforeSize.height === afterSize.height && beforeSize.width === afterSize.width) {
|
|
1001
|
+
return;
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
954
1004
|
if (resizeDebounce <= 0) {
|
|
955
1005
|
void flicking.resize();
|
|
956
1006
|
} else {
|
|
@@ -976,12 +1026,12 @@ var AutoResizer = /*#__PURE__*/function () {
|
|
|
976
1026
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
977
1027
|
this._skipFirstResize = function () {
|
|
978
1028
|
var isFirstResize = true;
|
|
979
|
-
return function () {
|
|
1029
|
+
return function (entries) {
|
|
980
1030
|
if (isFirstResize) {
|
|
981
1031
|
isFirstResize = false;
|
|
982
1032
|
return;
|
|
983
1033
|
}
|
|
984
|
-
_this._onResize();
|
|
1034
|
+
_this._onResize(entries);
|
|
985
1035
|
};
|
|
986
1036
|
}();
|
|
987
1037
|
this._flicking = flicking;
|
|
@@ -1007,14 +1057,46 @@ var AutoResizer = /*#__PURE__*/function () {
|
|
|
1007
1057
|
if (flicking.useResizeObserver && !!window.ResizeObserver) {
|
|
1008
1058
|
var viewportSizeNot0 = viewport.width !== 0 || viewport.height !== 0;
|
|
1009
1059
|
var resizeObserver = viewportSizeNot0 ? new ResizeObserver(this._skipFirstResize) : new ResizeObserver(this._onResize);
|
|
1010
|
-
resizeObserver.observe(flicking.viewport.element);
|
|
1011
1060
|
this._resizeObserver = resizeObserver;
|
|
1061
|
+
this.observe(flicking.viewport.element);
|
|
1062
|
+
if (flicking.observePanelResize) {
|
|
1063
|
+
this.observePanels();
|
|
1064
|
+
}
|
|
1012
1065
|
} else {
|
|
1013
|
-
window.addEventListener("resize", this.
|
|
1066
|
+
window.addEventListener("resize", this._onResizeWrapper);
|
|
1014
1067
|
}
|
|
1015
1068
|
this._enabled = true;
|
|
1016
1069
|
return this;
|
|
1017
1070
|
};
|
|
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 () {
|
|
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
|
+
};
|
|
1018
1100
|
__proto.disable = function () {
|
|
1019
1101
|
if (!this._enabled) return this;
|
|
1020
1102
|
var resizeObserver = this._resizeObserver;
|
|
@@ -1022,7 +1104,7 @@ var AutoResizer = /*#__PURE__*/function () {
|
|
|
1022
1104
|
resizeObserver.disconnect();
|
|
1023
1105
|
this._resizeObserver = null;
|
|
1024
1106
|
} else {
|
|
1025
|
-
window.removeEventListener("resize", this.
|
|
1107
|
+
window.removeEventListener("resize", this._onResizeWrapper);
|
|
1026
1108
|
}
|
|
1027
1109
|
this._enabled = false;
|
|
1028
1110
|
return this;
|
|
@@ -2913,11 +2995,7 @@ var SnapControl = /*#__PURE__*/function (_super) {
|
|
|
2913
2995
|
if (snapDelta >= snapThreshold && snapDelta > 0) {
|
|
2914
2996
|
// Move to anchor at position
|
|
2915
2997
|
targetAnchor = this._findSnappedAnchor(position, anchorAtCamera);
|
|
2916
|
-
|
|
2917
|
-
// const nextPosition = this._getPosition(targetPanel, DIRECTION.NEXT);
|
|
2918
|
-
// const prevPosition = this._getPosition(targetPanel, DIRECTION.PREV);
|
|
2919
|
-
// targetPosition = Math.abs(camera.position - nextPosition) < Math.abs(camera.position - prevPosition) ? nextPosition : prevPosition;
|
|
2920
|
-
} else if (absPosDelta >= flicking.threshold && absPosDelta > 0 && anchorAtCamera === activeAnchor) {
|
|
2998
|
+
} else if (absPosDelta >= flicking.threshold && absPosDelta > 0) {
|
|
2921
2999
|
// Move to the adjacent panel
|
|
2922
3000
|
targetAnchor = this._findAdjacentAnchor(position, posDelta, anchorAtCamera);
|
|
2923
3001
|
} else {
|
|
@@ -2945,7 +3023,6 @@ var SnapControl = /*#__PURE__*/function (_super) {
|
|
|
2945
3023
|
if (!anchorAtCamera || !anchorAtPosition) {
|
|
2946
3024
|
throw new FlickingError(MESSAGE.POSITION_NOT_REACHABLE(position), CODE.POSITION_NOT_REACHABLE);
|
|
2947
3025
|
}
|
|
2948
|
-
// console.log("_findSnappedAnchor", anchorAtPosition);
|
|
2949
3026
|
if (!isFinite(count)) {
|
|
2950
3027
|
return anchorAtPosition;
|
|
2951
3028
|
}
|
|
@@ -3366,7 +3443,10 @@ var CameraMode = /*#__PURE__*/function () {
|
|
|
3366
3443
|
};
|
|
3367
3444
|
__proto.findAnchorIncludePosition = function (position) {
|
|
3368
3445
|
var anchors = this._flicking.camera.anchorPoints;
|
|
3369
|
-
|
|
3446
|
+
var anchorsIncludingPosition = anchors.filter(function (anchor) {
|
|
3447
|
+
return anchor.panel.includePosition(position, true);
|
|
3448
|
+
});
|
|
3449
|
+
return anchorsIncludingPosition.reduce(function (nearest, anchor) {
|
|
3370
3450
|
if (!nearest) return anchor;
|
|
3371
3451
|
return Math.abs(nearest.position - position) < Math.abs(anchor.position - position) ? nearest : anchor;
|
|
3372
3452
|
}, null);
|
|
@@ -4031,7 +4111,7 @@ var Camera = /*#__PURE__*/function () {
|
|
|
4031
4111
|
if (prevPosition > panelPos) {
|
|
4032
4112
|
prevPosition -= rangeDiff;
|
|
4033
4113
|
}
|
|
4034
|
-
return nearestPanel.index - 1 + getProgress(position, prevPosition, panelPos);
|
|
4114
|
+
return nearestPanel.index - 1 + getProgress$1(position, prevPosition, panelPos);
|
|
4035
4115
|
} else {
|
|
4036
4116
|
var nextPanel = nearestPanel.next();
|
|
4037
4117
|
var nextPosition = nextPanel ? nextPanel.position + nextPanel.offset : nextRange + bounceSize[1];
|
|
@@ -4039,7 +4119,7 @@ var Camera = /*#__PURE__*/function () {
|
|
|
4039
4119
|
if (nextPosition < panelPos) {
|
|
4040
4120
|
nextPosition += rangeDiff;
|
|
4041
4121
|
}
|
|
4042
|
-
return nearestPanel.index + getProgress(position, panelPos, nextPosition);
|
|
4122
|
+
return nearestPanel.index + getProgress$1(position, panelPos, nextPosition);
|
|
4043
4123
|
}
|
|
4044
4124
|
},
|
|
4045
4125
|
enumerable: false,
|
|
@@ -4822,6 +4902,18 @@ var Renderer = /*#__PURE__*/function () {
|
|
|
4822
4902
|
var activePanel = control.activePanel;
|
|
4823
4903
|
// Update camera & control
|
|
4824
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
|
+
}
|
|
4825
4917
|
void this.render();
|
|
4826
4918
|
if (!flicking.animating) {
|
|
4827
4919
|
if (!activePanel || activePanel.removed) {
|
|
@@ -5370,10 +5462,10 @@ var Panel = /*#__PURE__*/function () {
|
|
|
5370
5462
|
}
|
|
5371
5463
|
if (camPos < position) {
|
|
5372
5464
|
var disappearPosNext = position + (camera.size - camera.alignPosition) + alignPosition;
|
|
5373
|
-
return -getProgress(camPos, position, disappearPosNext);
|
|
5465
|
+
return -getProgress$1(camPos, position, disappearPosNext);
|
|
5374
5466
|
} else {
|
|
5375
5467
|
var disappearPosPrev = position - (camera.alignPosition + this._size - alignPosition);
|
|
5376
|
-
return 1 - getProgress(camPos, disappearPosPrev, position);
|
|
5468
|
+
return 1 - getProgress$1(camPos, disappearPosPrev, position);
|
|
5377
5469
|
}
|
|
5378
5470
|
},
|
|
5379
5471
|
enumerable: false,
|
|
@@ -6099,18 +6191,23 @@ var Flicking = /*#__PURE__*/function (_super) {
|
|
|
6099
6191
|
useResizeObserver = _9 === void 0 ? true : _9,
|
|
6100
6192
|
_10 = _b.resizeDebounce,
|
|
6101
6193
|
resizeDebounce = _10 === void 0 ? 0 : _10,
|
|
6102
|
-
_11 = _b.
|
|
6103
|
-
|
|
6104
|
-
_12 = _b.
|
|
6105
|
-
|
|
6106
|
-
_13 = _b.
|
|
6107
|
-
|
|
6108
|
-
_14 = _b.
|
|
6109
|
-
|
|
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;
|
|
6110
6206
|
var _this = _super.call(this) || this;
|
|
6111
6207
|
// Internal states
|
|
6112
6208
|
_this._initialized = false;
|
|
6113
6209
|
_this._plugins = [];
|
|
6210
|
+
_this._isResizing = false;
|
|
6114
6211
|
// Bind options
|
|
6115
6212
|
_this._align = align;
|
|
6116
6213
|
_this._defaultIndex = defaultIndex;
|
|
@@ -6146,9 +6243,11 @@ var Flicking = /*#__PURE__*/function (_super) {
|
|
|
6146
6243
|
_this._useResizeObserver = useResizeObserver;
|
|
6147
6244
|
_this._resizeDebounce = resizeDebounce;
|
|
6148
6245
|
_this._maxResizeDebounce = maxResizeDebounce;
|
|
6246
|
+
_this._observePanelResize = observePanelResize;
|
|
6149
6247
|
_this._useFractionalSize = useFractionalSize;
|
|
6150
6248
|
_this._externalRenderer = externalRenderer;
|
|
6151
6249
|
_this._renderExternal = renderExternal;
|
|
6250
|
+
_this._optimizeSizeUpdate = optimizeSizeUpdate;
|
|
6152
6251
|
// Create core components
|
|
6153
6252
|
_this._viewport = new Viewport(_this, getElement(root));
|
|
6154
6253
|
_this._autoResizer = new AutoResizer(_this);
|
|
@@ -6229,6 +6328,19 @@ var Flicking = /*#__PURE__*/function (_super) {
|
|
|
6229
6328
|
enumerable: false,
|
|
6230
6329
|
configurable: true
|
|
6231
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
|
+
});
|
|
6232
6344
|
Object.defineProperty(__proto, "initialized", {
|
|
6233
6345
|
// Internal States
|
|
6234
6346
|
/**
|
|
@@ -7102,6 +7214,9 @@ var Flicking = /*#__PURE__*/function (_super) {
|
|
|
7102
7214
|
// OTHERS
|
|
7103
7215
|
set: function (val) {
|
|
7104
7216
|
this._autoResize = val;
|
|
7217
|
+
if (!this._initialized) {
|
|
7218
|
+
return;
|
|
7219
|
+
}
|
|
7105
7220
|
if (val) {
|
|
7106
7221
|
this._autoResizer.enable();
|
|
7107
7222
|
} else {
|
|
@@ -7124,13 +7239,38 @@ var Flicking = /*#__PURE__*/function (_super) {
|
|
|
7124
7239
|
},
|
|
7125
7240
|
set: function (val) {
|
|
7126
7241
|
this._useResizeObserver = val;
|
|
7127
|
-
if (this._autoResize) {
|
|
7242
|
+
if (this._initialized && this._autoResize) {
|
|
7128
7243
|
this._autoResizer.enable();
|
|
7129
7244
|
}
|
|
7130
7245
|
},
|
|
7131
7246
|
enumerable: false,
|
|
7132
7247
|
configurable: true
|
|
7133
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
|
+
});
|
|
7134
7274
|
Object.defineProperty(__proto, "resizeDebounce", {
|
|
7135
7275
|
/**
|
|
7136
7276
|
* Delays size recalculation from `autoResize` by the given time in milisecond.
|
|
@@ -7212,6 +7352,30 @@ var Flicking = /*#__PURE__*/function (_super) {
|
|
|
7212
7352
|
enumerable: false,
|
|
7213
7353
|
configurable: true
|
|
7214
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
|
+
});
|
|
7215
7379
|
/**
|
|
7216
7380
|
* Initialize Flicking and move to the default index
|
|
7217
7381
|
* This is automatically called on Flicking's constructor when `autoInit` is true(default)
|
|
@@ -7650,6 +7814,8 @@ var Flicking = /*#__PURE__*/function (_super) {
|
|
|
7650
7814
|
return __generator(this, function (_a) {
|
|
7651
7815
|
switch (_a.label) {
|
|
7652
7816
|
case 0:
|
|
7817
|
+
if (this._isResizing) return [2 /*return*/];
|
|
7818
|
+
this._isResizing = true;
|
|
7653
7819
|
viewport = this._viewport;
|
|
7654
7820
|
renderer = this._renderer;
|
|
7655
7821
|
camera = this._camera;
|
|
@@ -7664,9 +7830,20 @@ var Flicking = /*#__PURE__*/function (_super) {
|
|
|
7664
7830
|
element: viewport.element
|
|
7665
7831
|
}));
|
|
7666
7832
|
viewport.resize();
|
|
7833
|
+
if (!this._optimizeSizeUpdate) return [3 /*break*/, 3];
|
|
7834
|
+
if (!(this.horizontal && viewport.width !== prevWidth || !this.horizontal && viewport.height !== prevHeight)) return [3 /*break*/, 2];
|
|
7667
7835
|
return [4 /*yield*/, renderer.forceRenderAllPanels()];
|
|
7668
7836
|
case 1:
|
|
7837
|
+
_a.sent();
|
|
7838
|
+
_a.label = 2;
|
|
7839
|
+
case 2:
|
|
7840
|
+
return [3 /*break*/, 5];
|
|
7841
|
+
case 3:
|
|
7842
|
+
return [4 /*yield*/, renderer.forceRenderAllPanels()];
|
|
7843
|
+
case 4:
|
|
7669
7844
|
_a.sent(); // Render all panel elements, to update sizes
|
|
7845
|
+
_a.label = 5;
|
|
7846
|
+
case 5:
|
|
7670
7847
|
if (!this._initialized) {
|
|
7671
7848
|
return [2 /*return*/];
|
|
7672
7849
|
}
|
|
@@ -7679,7 +7856,7 @@ var Flicking = /*#__PURE__*/function (_super) {
|
|
|
7679
7856
|
camera.updatePanelOrder();
|
|
7680
7857
|
camera.updateOffset();
|
|
7681
7858
|
return [4 /*yield*/, renderer.render()];
|
|
7682
|
-
case
|
|
7859
|
+
case 6:
|
|
7683
7860
|
_a.sent();
|
|
7684
7861
|
if (!this._initialized) {
|
|
7685
7862
|
return [2 /*return*/];
|
|
@@ -7702,6 +7879,7 @@ var Flicking = /*#__PURE__*/function (_super) {
|
|
|
7702
7879
|
sizeChanged: sizeChanged,
|
|
7703
7880
|
element: viewport.element
|
|
7704
7881
|
}));
|
|
7882
|
+
this._isResizing = false;
|
|
7705
7883
|
return [2 /*return*/];
|
|
7706
7884
|
}
|
|
7707
7885
|
});
|
|
@@ -7921,7 +8099,7 @@ var Flicking = /*#__PURE__*/function (_super) {
|
|
|
7921
8099
|
* Flicking.VERSION; // ex) 4.0.0
|
|
7922
8100
|
* ```
|
|
7923
8101
|
*/
|
|
7924
|
-
Flicking.VERSION = "4.
|
|
8102
|
+
Flicking.VERSION = "4.14.0";
|
|
7925
8103
|
return Flicking;
|
|
7926
8104
|
}(Component);
|
|
7927
8105
|
|
|
@@ -8477,10 +8655,194 @@ var parseAlign = function (alignVal) {
|
|
|
8477
8655
|
}
|
|
8478
8656
|
};
|
|
8479
8657
|
|
|
8658
|
+
// Check if Flicking has reached the first panel
|
|
8659
|
+
var getIsReachStart = function (flicking) {
|
|
8660
|
+
return !flicking.circular && flicking.index === 0;
|
|
8661
|
+
};
|
|
8662
|
+
// Check if Flicking has reached the last panel
|
|
8663
|
+
var getIsReachEnd = function (flicking) {
|
|
8664
|
+
return !flicking.circular && flicking.index === flicking.panelCount - 1;
|
|
8665
|
+
};
|
|
8666
|
+
// Get the total number of panels
|
|
8667
|
+
var getTotalPanelCount = function (flicking) {
|
|
8668
|
+
return flicking.panelCount;
|
|
8669
|
+
};
|
|
8670
|
+
// Get the current active panel index
|
|
8671
|
+
var getCurrentPanelIndex = function (flicking) {
|
|
8672
|
+
return flicking.index;
|
|
8673
|
+
};
|
|
8674
|
+
// Calculate the overall scroll progress percentage based on the current camera position
|
|
8675
|
+
var getProgress = function (flicking) {
|
|
8676
|
+
var cam = flicking.camera;
|
|
8677
|
+
var progressRatio = (cam.position - cam.range.min) / (cam.range.max - cam.range.min);
|
|
8678
|
+
var percent = Math.min(Math.max(progressRatio, 0), 1) * 100;
|
|
8679
|
+
return percent;
|
|
8680
|
+
};
|
|
8681
|
+
// Calculate the progress between panels including decimal values
|
|
8682
|
+
var getIndexProgress = function (flicking) {
|
|
8683
|
+
var cam = flicking.camera;
|
|
8684
|
+
var anchorPoints = cam.anchorPoints;
|
|
8685
|
+
var length = anchorPoints.length;
|
|
8686
|
+
var cameraPosition = cam.position;
|
|
8687
|
+
var isCircular = flicking.circularEnabled;
|
|
8688
|
+
var indexProgress = 0;
|
|
8689
|
+
var _a = cam.range,
|
|
8690
|
+
min = _a.min,
|
|
8691
|
+
max = _a.max;
|
|
8692
|
+
var firstAnchorPoint = anchorPoints[0];
|
|
8693
|
+
var lastAnchorPoint = anchorPoints[length - 1];
|
|
8694
|
+
var distanceLastToFirst = max - lastAnchorPoint.position + (firstAnchorPoint.position - min);
|
|
8695
|
+
anchorPoints.some(function (anchorPoint, index) {
|
|
8696
|
+
var anchorPosition = anchorPoint.position;
|
|
8697
|
+
var nextAnchorPoint = anchorPoints[index + 1];
|
|
8698
|
+
if (index === 0 && cameraPosition <= anchorPosition) {
|
|
8699
|
+
if (isCircular) {
|
|
8700
|
+
indexProgress = (cameraPosition - anchorPosition) / distanceLastToFirst;
|
|
8701
|
+
} else {
|
|
8702
|
+
indexProgress = (cameraPosition - anchorPosition) / anchorPoint.panel.size;
|
|
8703
|
+
}
|
|
8704
|
+
} else if (index === length - 1 && cameraPosition >= anchorPosition) {
|
|
8705
|
+
if (isCircular) {
|
|
8706
|
+
indexProgress = index + (cameraPosition - anchorPosition) / distanceLastToFirst;
|
|
8707
|
+
} else {
|
|
8708
|
+
indexProgress = index + (cameraPosition - anchorPosition) / anchorPoint.panel.size;
|
|
8709
|
+
}
|
|
8710
|
+
} else if (nextAnchorPoint && anchorPosition <= cameraPosition && cameraPosition <= nextAnchorPoint.position) {
|
|
8711
|
+
indexProgress = index + (cameraPosition - anchorPosition) / (nextAnchorPoint.position - anchorPosition);
|
|
8712
|
+
} else {
|
|
8713
|
+
return false;
|
|
8714
|
+
}
|
|
8715
|
+
return true;
|
|
8716
|
+
});
|
|
8717
|
+
return indexProgress;
|
|
8718
|
+
};
|
|
8719
|
+
/**
|
|
8720
|
+
* Internal reactive API adapter for Flicking that manages state and event listeners
|
|
8721
|
+
* This adapter is used internally by framework-specific packages (react-flicking, vue-flicking, etc.)
|
|
8722
|
+
* to provide reactive API support. Users rarely need to use this directly.
|
|
8723
|
+
* @ko Flicking의 상태와 이벤트 리스너를 관리하는 내부 반응형 API 어댑터
|
|
8724
|
+
* 이 어댑터는 react-flicking, vue-flicking 등의 프레임워크별 패키지에서 내부적으로 사용되어
|
|
8725
|
+
* 반응형 API 지원을 제공합니다. 사용자가 직접 사용할 일은 거의 없습니다.
|
|
8726
|
+
* @param onInit - Callback when reactive object is initialized<ko>반응형 객체가 초기화될 때 호출되는 콜백</ko>
|
|
8727
|
+
* @param onDestroy - Callback when reactive object is destroyed<ko>반응형 객체가 파괴될 때 호출되는 콜백</ko>
|
|
8728
|
+
* @param setMethods - Function to set available methods<ko>사용 가능한 메서드를 설정하는 함수</ko>
|
|
8729
|
+
* @returns Reactive object with Flicking state and methods<ko>Flicking 상태와 메서드를 포함한 반응형 객체</ko>
|
|
8730
|
+
*/
|
|
8731
|
+
var flickingReactiveAPIAdapter = function (_a) {
|
|
8732
|
+
var _b, _c, _d;
|
|
8733
|
+
var onInit = _a.onInit,
|
|
8734
|
+
onDestroy = _a.onDestroy,
|
|
8735
|
+
setMethods = _a.setMethods,
|
|
8736
|
+
getProps = _a.getProps;
|
|
8737
|
+
var flicking;
|
|
8738
|
+
// Move to a specific panel index
|
|
8739
|
+
var moveTo = function (i) {
|
|
8740
|
+
if (flicking == null) {
|
|
8741
|
+
return Promise.reject(new Error("Flicking instance is not available"));
|
|
8742
|
+
}
|
|
8743
|
+
if (flicking === null || flicking === void 0 ? void 0 : flicking.animating) {
|
|
8744
|
+
return Promise.resolve();
|
|
8745
|
+
}
|
|
8746
|
+
return flicking.moveTo(i);
|
|
8747
|
+
};
|
|
8748
|
+
setMethods(["moveTo"]);
|
|
8749
|
+
var options = getProps().options;
|
|
8750
|
+
// options를 고려하지 않고 초기값을 설정해도 동작에는 아무런 문제가 없으나, 이 시점의 초기값과 컴포넌트 init 단계에서의 초기값이 다르면 화면 리렌더링이 발생할 수 있으므로
|
|
8751
|
+
// 이렇게 미리 옵션을 통해서 예측할 수 있는 부분들은 맞춰둔다.
|
|
8752
|
+
var reactiveObj = reactive({
|
|
8753
|
+
isReachStart: (options === null || options === void 0 ? void 0 : options.defaultIndex) ? (options === null || options === void 0 ? void 0 : options.defaultIndex) === 0 : true,
|
|
8754
|
+
isReachEnd: (options === null || options === void 0 ? void 0 : options.totalPanelCount) && (options === null || options === void 0 ? void 0 : options.defaultIndex) ? options.defaultIndex === options.totalPanelCount - 1 : false,
|
|
8755
|
+
totalPanelCount: (_b = options === null || options === void 0 ? void 0 : options.totalPanelCount) !== null && _b !== void 0 ? _b : 0,
|
|
8756
|
+
currentPanelIndex: (_c = options === null || options === void 0 ? void 0 : options.defaultIndex) !== null && _c !== void 0 ? _c : 0,
|
|
8757
|
+
progress: 0,
|
|
8758
|
+
indexProgress: (_d = options === null || options === void 0 ? void 0 : options.defaultIndex) !== null && _d !== void 0 ? _d : 0,
|
|
8759
|
+
moveTo: moveTo
|
|
8760
|
+
});
|
|
8761
|
+
// Update state when panel changes
|
|
8762
|
+
var onChanged = function () {
|
|
8763
|
+
if (flicking === undefined) return;
|
|
8764
|
+
reactiveObj.isReachStart = getIsReachStart(flicking);
|
|
8765
|
+
reactiveObj.isReachEnd = getIsReachEnd(flicking);
|
|
8766
|
+
reactiveObj.currentPanelIndex = getCurrentPanelIndex(flicking);
|
|
8767
|
+
};
|
|
8768
|
+
// Update state when panel count changes
|
|
8769
|
+
var onPanelChange = function () {
|
|
8770
|
+
if (flicking === undefined) return;
|
|
8771
|
+
onChanged();
|
|
8772
|
+
reactiveObj.totalPanelCount = getTotalPanelCount(flicking);
|
|
8773
|
+
};
|
|
8774
|
+
// Update progress when camera moves
|
|
8775
|
+
var onMove = function () {
|
|
8776
|
+
if (flicking === undefined) return;
|
|
8777
|
+
reactiveObj.progress = getProgress(flicking);
|
|
8778
|
+
reactiveObj.indexProgress = getIndexProgress(flicking);
|
|
8779
|
+
};
|
|
8780
|
+
onInit(function (inst, data) {
|
|
8781
|
+
flicking = data.flicking;
|
|
8782
|
+
if (flicking === undefined) return;
|
|
8783
|
+
reactiveObj.isReachStart = getIsReachStart(flicking);
|
|
8784
|
+
reactiveObj.isReachEnd = getIsReachEnd(flicking);
|
|
8785
|
+
reactiveObj.currentPanelIndex = getCurrentPanelIndex(flicking);
|
|
8786
|
+
reactiveObj.progress = getProgress(flicking);
|
|
8787
|
+
reactiveObj.totalPanelCount = getTotalPanelCount(flicking);
|
|
8788
|
+
flicking === null || flicking === void 0 ? void 0 : flicking.on("changed", onChanged);
|
|
8789
|
+
flicking === null || flicking === void 0 ? void 0 : flicking.on("panelChange", onPanelChange);
|
|
8790
|
+
flicking === null || flicking === void 0 ? void 0 : flicking.on("move", onMove);
|
|
8791
|
+
});
|
|
8792
|
+
onDestroy(function () {
|
|
8793
|
+
flicking === null || flicking === void 0 ? void 0 : flicking.off("changed", onChanged);
|
|
8794
|
+
flicking === null || flicking === void 0 ? void 0 : flicking.off("panelChange", onPanelChange);
|
|
8795
|
+
flicking === null || flicking === void 0 ? void 0 : flicking.off("move", onMove);
|
|
8796
|
+
});
|
|
8797
|
+
return reactiveObj;
|
|
8798
|
+
};
|
|
8799
|
+
/**
|
|
8800
|
+
* Connect Flicking instance to reactive API
|
|
8801
|
+
* @ko Flicking 인스턴스를 반응형 API에 연결합니다
|
|
8802
|
+
* @param {Flicking} flicking - Flicking instance to connect<ko>연결할 Flicking 인스턴스</ko>
|
|
8803
|
+
* @param {FlickingReactiveAPIOptions} [options] - Flicking options<ko>Flicking 옵션</ko>
|
|
8804
|
+
* @returns {FlickingReactiveObject} Reactive object with Flicking state and methods<ko>Flicking 상태와 메서드를 포함한 반응형 객체</ko>
|
|
8805
|
+
* @example
|
|
8806
|
+
* ```js
|
|
8807
|
+
* import Flicking, { connectFlickingReactiveAPI } from "@egjs/flicking";
|
|
8808
|
+
*
|
|
8809
|
+
* const flicking = new Flicking("#el");
|
|
8810
|
+
* const reactiveObj = connectFlickingReactiveAPI(flicking);
|
|
8811
|
+
*
|
|
8812
|
+
* // Access reactive state
|
|
8813
|
+
* console.log("Current panel:", reactiveObj.currentPanelIndex);
|
|
8814
|
+
* console.log("Progress:", reactiveObj.progress + "%");
|
|
8815
|
+
* console.log("Is at start:", reactiveObj.isReachStart);
|
|
8816
|
+
* console.log("Is at end:", reactiveObj.isReachEnd);
|
|
8817
|
+
* console.log("Total panels:", reactiveObj.totalPanelCount);
|
|
8818
|
+
* console.log("Index progress:", reactiveObj.indexProgress);
|
|
8819
|
+
*
|
|
8820
|
+
* // Subscribe to state changes
|
|
8821
|
+
* reactiveObj.subscribe("currentPanelIndex", (nextValue) => {
|
|
8822
|
+
* console.log("Panel changed to:", nextValue);
|
|
8823
|
+
* });
|
|
8824
|
+
*
|
|
8825
|
+
* // Use reactive methods
|
|
8826
|
+
* reactiveObj.moveTo(2); // Move to third panel
|
|
8827
|
+
* ```
|
|
8828
|
+
*/
|
|
8829
|
+
var connectFlickingReactiveAPI = function (flicking, options) {
|
|
8830
|
+
var obj = adaptReactive(flickingReactiveAPIAdapter, function () {
|
|
8831
|
+
return {
|
|
8832
|
+
flicking: flicking,
|
|
8833
|
+
options: options
|
|
8834
|
+
};
|
|
8835
|
+
});
|
|
8836
|
+
obj.mounted();
|
|
8837
|
+
var instance = obj.instance();
|
|
8838
|
+
obj.init();
|
|
8839
|
+
return instance;
|
|
8840
|
+
};
|
|
8841
|
+
|
|
8480
8842
|
/*
|
|
8481
8843
|
* Copyright (c) 2015 NAVER Corp.
|
|
8482
8844
|
* egjs projects are licensed under the MIT license
|
|
8483
8845
|
*/
|
|
8484
8846
|
|
|
8485
|
-
export { ALIGN, AnchorPoint, AnimatingState, AxesController, BoundCameraMode, CIRCULAR_FALLBACK, CLASS, Camera, CircularCameraMode, Control, CrossFlicking, DIRECTION, DisabledState, DraggingState, CODE as ERROR_CODE, EVENTS, ExternalRenderer, FlickingError, FreeControl, HoldingState, IdleState, LinearCameraMode, MOVE_DIRECTION, MOVE_TYPE, NormalRenderingStrategy, ORDER, Panel, Renderer, SIDE_EVENTS, SnapControl, State, StateMachine, StrictControl, VanillaElementProvider, VanillaRenderer, Viewport, VirtualElementProvider, VirtualManager, VirtualPanel, VirtualRenderingStrategy, camelize, checkExistence, circulateIndex, circulatePosition, clamp, Flicking as default, find, findIndex, findRight, getDataAttributes, getDefaultCameraTransform, getDirection, getElement, getElementSize, getFlickingAttached, getMinusCompensatedIndex, getProgress, getRenderingPanels, getStyle, includes, isBetween, isString, merge, parseAlign$1 as parseAlign, parseArithmeticExpression, parseArithmeticSize, parseBounce, parseCSSSizeValue, parseElement, parsePanelAlign, range, setPrototypeOf, setSize, sync, toArray, withFlickingMethods };
|
|
8847
|
+
export { ALIGN, AnchorPoint, AnimatingState, AxesController, BoundCameraMode, CIRCULAR_FALLBACK, CLASS, Camera, CircularCameraMode, Control, CrossFlicking, DIRECTION, DisabledState, DraggingState, CODE as ERROR_CODE, EVENTS, ExternalRenderer, FlickingError, FreeControl, HoldingState, IdleState, LinearCameraMode, MOVE_DIRECTION, MOVE_TYPE, NormalRenderingStrategy, ORDER, Panel, Renderer, SIDE_EVENTS, SnapControl, State, StateMachine, StrictControl, VanillaElementProvider, VanillaRenderer, Viewport, VirtualElementProvider, VirtualManager, VirtualPanel, VirtualRenderingStrategy, camelize, checkExistence, circulateIndex, circulatePosition, clamp, connectFlickingReactiveAPI, Flicking as default, find, findIndex, findRight, flickingReactiveAPIAdapter, getDataAttributes, getDefaultCameraTransform, getDirection, getElement, getElementSize, getFlickingAttached, getMinusCompensatedIndex, getProgress$1 as getProgress, getRenderingPanels, getStyle, includes, isBetween, isString, merge, parseAlign$1 as parseAlign, parseArithmeticExpression, parseArithmeticSize, parseBounce, parseCSSSizeValue, parseElement, parsePanelAlign, range, setPrototypeOf, setSize, sync, toArray, withFlickingMethods };
|
|
8486
8848
|
//# sourceMappingURL=flicking.esm.js.map
|