@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.cjs.js
CHANGED
|
@@ -4,13 +4,14 @@ 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
|
'use strict';
|
|
10
10
|
|
|
11
11
|
var Component = require('@egjs/component');
|
|
12
12
|
var Axes = require('@egjs/axes');
|
|
13
13
|
var ImReady = require('@egjs/imready');
|
|
14
|
+
var core = require('@cfcs/core');
|
|
14
15
|
|
|
15
16
|
/******************************************************************************
|
|
16
17
|
Copyright (c) Microsoft Corporation.
|
|
@@ -669,11 +670,14 @@ var findIndex = function (array, checker) {
|
|
|
669
670
|
}
|
|
670
671
|
return -1;
|
|
671
672
|
};
|
|
672
|
-
var getProgress = function (pos, prev, next) {
|
|
673
|
+
var getProgress$1 = function (pos, prev, next) {
|
|
673
674
|
return (pos - prev) / (next - prev);
|
|
674
675
|
};
|
|
675
676
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
676
677
|
var getStyle = function (el) {
|
|
678
|
+
if (!el) {
|
|
679
|
+
return {};
|
|
680
|
+
}
|
|
677
681
|
return window.getComputedStyle(el) || el.currentStyle;
|
|
678
682
|
};
|
|
679
683
|
var setSize = function (el, _a) {
|
|
@@ -946,13 +950,59 @@ var Viewport = /*#__PURE__*/function () {
|
|
|
946
950
|
return Viewport;
|
|
947
951
|
}();
|
|
948
952
|
|
|
953
|
+
/*
|
|
954
|
+
* Copyright (c) 2015 NAVER Corp.
|
|
955
|
+
* egjs projects are licensed under the MIT license
|
|
956
|
+
*/
|
|
957
|
+
/**
|
|
958
|
+
* A component that detects size change and trigger resize method when the autoResize option is used
|
|
959
|
+
* @ko autoResize 옵션을 사용할 때 크기 변화를 감지하고 Flicking의 resize를 호출하는 컴포넌트
|
|
960
|
+
*/
|
|
949
961
|
var AutoResizer = /*#__PURE__*/function () {
|
|
950
962
|
function AutoResizer(flicking) {
|
|
951
963
|
var _this = this;
|
|
952
|
-
this.
|
|
964
|
+
this._onResizeWrapper = function () {
|
|
965
|
+
_this._onResize([]);
|
|
966
|
+
};
|
|
967
|
+
this._onResize = function (entries) {
|
|
953
968
|
var flicking = _this._flicking;
|
|
954
969
|
var resizeDebounce = flicking.resizeDebounce;
|
|
955
970
|
var maxResizeDebounce = flicking.maxResizeDebounce;
|
|
971
|
+
var resizedViewportElement = flicking.element;
|
|
972
|
+
// 현재 구현에서 리사이즈 옵저빙 대상은 패널과 뷰포트 2개만 존재.
|
|
973
|
+
// 아래는 뷰포트만 변경되었을 때 동작해야하는 로직이 있으므로 아래와 같이 조건문을 건다.
|
|
974
|
+
// 패널 쪽에서는 리사이즈 감지에 resizeObserver를 사용하지 않는 경우가 없으므로 이 조건은 곧 뷰포트만 리사이즈가 된 경우를 의미한다.
|
|
975
|
+
var isResizedViewportOnly = entries.find(function (e) {
|
|
976
|
+
return e.target === flicking.element;
|
|
977
|
+
}) && entries.length === 1;
|
|
978
|
+
// 참고: resizeObserver를 사용하지 않은 경우에는 entries.length가 0으로 오는데 이 경우에는 그냥 항상 리사이즈가 진행되도록 한다.
|
|
979
|
+
// (vw, vh 등을 사용하는 경우 이상 동작이 발생할 여지가 있기 때문이다)
|
|
980
|
+
if (isResizedViewportOnly) {
|
|
981
|
+
// resize 이벤트가 발생했으나 이전과 width, height의 변화가 없다면 이후 로직을 진행하지 않는다.
|
|
982
|
+
var beforeSize = {
|
|
983
|
+
width: flicking.viewport.width,
|
|
984
|
+
height: flicking.viewport.height
|
|
985
|
+
};
|
|
986
|
+
var afterSize = {
|
|
987
|
+
width: getElementSize({
|
|
988
|
+
el: resizedViewportElement,
|
|
989
|
+
horizontal: true,
|
|
990
|
+
useFractionalSize: _this._flicking.useFractionalSize,
|
|
991
|
+
useOffset: false,
|
|
992
|
+
style: getStyle(resizedViewportElement)
|
|
993
|
+
}),
|
|
994
|
+
height: getElementSize({
|
|
995
|
+
el: resizedViewportElement,
|
|
996
|
+
horizontal: false,
|
|
997
|
+
useFractionalSize: _this._flicking.useFractionalSize,
|
|
998
|
+
useOffset: false,
|
|
999
|
+
style: getStyle(resizedViewportElement)
|
|
1000
|
+
})
|
|
1001
|
+
};
|
|
1002
|
+
if (beforeSize.height === afterSize.height && beforeSize.width === afterSize.width) {
|
|
1003
|
+
return;
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
956
1006
|
if (resizeDebounce <= 0) {
|
|
957
1007
|
void flicking.resize();
|
|
958
1008
|
} else {
|
|
@@ -978,12 +1028,12 @@ var AutoResizer = /*#__PURE__*/function () {
|
|
|
978
1028
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
979
1029
|
this._skipFirstResize = function () {
|
|
980
1030
|
var isFirstResize = true;
|
|
981
|
-
return function () {
|
|
1031
|
+
return function (entries) {
|
|
982
1032
|
if (isFirstResize) {
|
|
983
1033
|
isFirstResize = false;
|
|
984
1034
|
return;
|
|
985
1035
|
}
|
|
986
|
-
_this._onResize();
|
|
1036
|
+
_this._onResize(entries);
|
|
987
1037
|
};
|
|
988
1038
|
}();
|
|
989
1039
|
this._flicking = flicking;
|
|
@@ -1009,14 +1059,46 @@ var AutoResizer = /*#__PURE__*/function () {
|
|
|
1009
1059
|
if (flicking.useResizeObserver && !!window.ResizeObserver) {
|
|
1010
1060
|
var viewportSizeNot0 = viewport.width !== 0 || viewport.height !== 0;
|
|
1011
1061
|
var resizeObserver = viewportSizeNot0 ? new ResizeObserver(this._skipFirstResize) : new ResizeObserver(this._onResize);
|
|
1012
|
-
resizeObserver.observe(flicking.viewport.element);
|
|
1013
1062
|
this._resizeObserver = resizeObserver;
|
|
1063
|
+
this.observe(flicking.viewport.element);
|
|
1064
|
+
if (flicking.observePanelResize) {
|
|
1065
|
+
this.observePanels();
|
|
1066
|
+
}
|
|
1014
1067
|
} else {
|
|
1015
|
-
window.addEventListener("resize", this.
|
|
1068
|
+
window.addEventListener("resize", this._onResizeWrapper);
|
|
1016
1069
|
}
|
|
1017
1070
|
this._enabled = true;
|
|
1018
1071
|
return this;
|
|
1019
1072
|
};
|
|
1073
|
+
__proto.observePanels = function () {
|
|
1074
|
+
var _this = this;
|
|
1075
|
+
this._flicking.panels.forEach(function (panel) {
|
|
1076
|
+
_this.observe(panel.element);
|
|
1077
|
+
});
|
|
1078
|
+
return this;
|
|
1079
|
+
};
|
|
1080
|
+
__proto.unobservePanels = function () {
|
|
1081
|
+
var _this = this;
|
|
1082
|
+
this._flicking.panels.forEach(function (panel) {
|
|
1083
|
+
_this.unobserve(panel.element);
|
|
1084
|
+
});
|
|
1085
|
+
return this;
|
|
1086
|
+
};
|
|
1087
|
+
__proto.observe = function (element) {
|
|
1088
|
+
var resizeObserver = this._resizeObserver;
|
|
1089
|
+
if (!resizeObserver) return this;
|
|
1090
|
+
resizeObserver.observe(element);
|
|
1091
|
+
return this;
|
|
1092
|
+
};
|
|
1093
|
+
__proto.unobserve = function (element) {
|
|
1094
|
+
var resizeObserver = this._resizeObserver;
|
|
1095
|
+
if (!resizeObserver) return this;
|
|
1096
|
+
resizeObserver.unobserve(element);
|
|
1097
|
+
if (this._flicking.observePanelResize) {
|
|
1098
|
+
this.unobservePanels();
|
|
1099
|
+
}
|
|
1100
|
+
return this;
|
|
1101
|
+
};
|
|
1020
1102
|
__proto.disable = function () {
|
|
1021
1103
|
if (!this._enabled) return this;
|
|
1022
1104
|
var resizeObserver = this._resizeObserver;
|
|
@@ -1024,7 +1106,7 @@ var AutoResizer = /*#__PURE__*/function () {
|
|
|
1024
1106
|
resizeObserver.disconnect();
|
|
1025
1107
|
this._resizeObserver = null;
|
|
1026
1108
|
} else {
|
|
1027
|
-
window.removeEventListener("resize", this.
|
|
1109
|
+
window.removeEventListener("resize", this._onResizeWrapper);
|
|
1028
1110
|
}
|
|
1029
1111
|
this._enabled = false;
|
|
1030
1112
|
return this;
|
|
@@ -2915,11 +2997,7 @@ var SnapControl = /*#__PURE__*/function (_super) {
|
|
|
2915
2997
|
if (snapDelta >= snapThreshold && snapDelta > 0) {
|
|
2916
2998
|
// Move to anchor at position
|
|
2917
2999
|
targetAnchor = this._findSnappedAnchor(position, anchorAtCamera);
|
|
2918
|
-
|
|
2919
|
-
// const nextPosition = this._getPosition(targetPanel, DIRECTION.NEXT);
|
|
2920
|
-
// const prevPosition = this._getPosition(targetPanel, DIRECTION.PREV);
|
|
2921
|
-
// targetPosition = Math.abs(camera.position - nextPosition) < Math.abs(camera.position - prevPosition) ? nextPosition : prevPosition;
|
|
2922
|
-
} else if (absPosDelta >= flicking.threshold && absPosDelta > 0 && anchorAtCamera === activeAnchor) {
|
|
3000
|
+
} else if (absPosDelta >= flicking.threshold && absPosDelta > 0) {
|
|
2923
3001
|
// Move to the adjacent panel
|
|
2924
3002
|
targetAnchor = this._findAdjacentAnchor(position, posDelta, anchorAtCamera);
|
|
2925
3003
|
} else {
|
|
@@ -2947,7 +3025,6 @@ var SnapControl = /*#__PURE__*/function (_super) {
|
|
|
2947
3025
|
if (!anchorAtCamera || !anchorAtPosition) {
|
|
2948
3026
|
throw new FlickingError(MESSAGE.POSITION_NOT_REACHABLE(position), CODE.POSITION_NOT_REACHABLE);
|
|
2949
3027
|
}
|
|
2950
|
-
// console.log("_findSnappedAnchor", anchorAtPosition);
|
|
2951
3028
|
if (!isFinite(count)) {
|
|
2952
3029
|
return anchorAtPosition;
|
|
2953
3030
|
}
|
|
@@ -3368,7 +3445,10 @@ var CameraMode = /*#__PURE__*/function () {
|
|
|
3368
3445
|
};
|
|
3369
3446
|
__proto.findAnchorIncludePosition = function (position) {
|
|
3370
3447
|
var anchors = this._flicking.camera.anchorPoints;
|
|
3371
|
-
|
|
3448
|
+
var anchorsIncludingPosition = anchors.filter(function (anchor) {
|
|
3449
|
+
return anchor.panel.includePosition(position, true);
|
|
3450
|
+
});
|
|
3451
|
+
return anchorsIncludingPosition.reduce(function (nearest, anchor) {
|
|
3372
3452
|
if (!nearest) return anchor;
|
|
3373
3453
|
return Math.abs(nearest.position - position) < Math.abs(anchor.position - position) ? nearest : anchor;
|
|
3374
3454
|
}, null);
|
|
@@ -4033,7 +4113,7 @@ var Camera = /*#__PURE__*/function () {
|
|
|
4033
4113
|
if (prevPosition > panelPos) {
|
|
4034
4114
|
prevPosition -= rangeDiff;
|
|
4035
4115
|
}
|
|
4036
|
-
return nearestPanel.index - 1 + getProgress(position, prevPosition, panelPos);
|
|
4116
|
+
return nearestPanel.index - 1 + getProgress$1(position, prevPosition, panelPos);
|
|
4037
4117
|
} else {
|
|
4038
4118
|
var nextPanel = nearestPanel.next();
|
|
4039
4119
|
var nextPosition = nextPanel ? nextPanel.position + nextPanel.offset : nextRange + bounceSize[1];
|
|
@@ -4041,7 +4121,7 @@ var Camera = /*#__PURE__*/function () {
|
|
|
4041
4121
|
if (nextPosition < panelPos) {
|
|
4042
4122
|
nextPosition += rangeDiff;
|
|
4043
4123
|
}
|
|
4044
|
-
return nearestPanel.index + getProgress(position, panelPos, nextPosition);
|
|
4124
|
+
return nearestPanel.index + getProgress$1(position, panelPos, nextPosition);
|
|
4045
4125
|
}
|
|
4046
4126
|
},
|
|
4047
4127
|
enumerable: false,
|
|
@@ -4824,6 +4904,18 @@ var Renderer = /*#__PURE__*/function () {
|
|
|
4824
4904
|
var activePanel = control.activePanel;
|
|
4825
4905
|
// Update camera & control
|
|
4826
4906
|
this._updateCameraAndControl();
|
|
4907
|
+
if (flicking.autoResize && flicking.useResizeObserver) {
|
|
4908
|
+
panelsAdded.forEach(function (panel) {
|
|
4909
|
+
if (panel.element) {
|
|
4910
|
+
flicking.autoResizer.observe(panel.element);
|
|
4911
|
+
}
|
|
4912
|
+
});
|
|
4913
|
+
panelsRemoved.forEach(function (panel) {
|
|
4914
|
+
if (panel.element) {
|
|
4915
|
+
flicking.autoResizer.unobserve(panel.element);
|
|
4916
|
+
}
|
|
4917
|
+
});
|
|
4918
|
+
}
|
|
4827
4919
|
void this.render();
|
|
4828
4920
|
if (!flicking.animating) {
|
|
4829
4921
|
if (!activePanel || activePanel.removed) {
|
|
@@ -5372,10 +5464,10 @@ var Panel = /*#__PURE__*/function () {
|
|
|
5372
5464
|
}
|
|
5373
5465
|
if (camPos < position) {
|
|
5374
5466
|
var disappearPosNext = position + (camera.size - camera.alignPosition) + alignPosition;
|
|
5375
|
-
return -getProgress(camPos, position, disappearPosNext);
|
|
5467
|
+
return -getProgress$1(camPos, position, disappearPosNext);
|
|
5376
5468
|
} else {
|
|
5377
5469
|
var disappearPosPrev = position - (camera.alignPosition + this._size - alignPosition);
|
|
5378
|
-
return 1 - getProgress(camPos, disappearPosPrev, position);
|
|
5470
|
+
return 1 - getProgress$1(camPos, disappearPosPrev, position);
|
|
5379
5471
|
}
|
|
5380
5472
|
},
|
|
5381
5473
|
enumerable: false,
|
|
@@ -6101,18 +6193,23 @@ var Flicking = /*#__PURE__*/function (_super) {
|
|
|
6101
6193
|
useResizeObserver = _9 === void 0 ? true : _9,
|
|
6102
6194
|
_10 = _b.resizeDebounce,
|
|
6103
6195
|
resizeDebounce = _10 === void 0 ? 0 : _10,
|
|
6104
|
-
_11 = _b.
|
|
6105
|
-
|
|
6106
|
-
_12 = _b.
|
|
6107
|
-
|
|
6108
|
-
_13 = _b.
|
|
6109
|
-
|
|
6110
|
-
_14 = _b.
|
|
6111
|
-
|
|
6196
|
+
_11 = _b.observePanelResize,
|
|
6197
|
+
observePanelResize = _11 === void 0 ? false : _11,
|
|
6198
|
+
_12 = _b.maxResizeDebounce,
|
|
6199
|
+
maxResizeDebounce = _12 === void 0 ? 100 : _12,
|
|
6200
|
+
_13 = _b.useFractionalSize,
|
|
6201
|
+
useFractionalSize = _13 === void 0 ? false : _13,
|
|
6202
|
+
_14 = _b.externalRenderer,
|
|
6203
|
+
externalRenderer = _14 === void 0 ? null : _14,
|
|
6204
|
+
_15 = _b.renderExternal,
|
|
6205
|
+
renderExternal = _15 === void 0 ? null : _15,
|
|
6206
|
+
_16 = _b.optimizeSizeUpdate,
|
|
6207
|
+
optimizeSizeUpdate = _16 === void 0 ? false : _16;
|
|
6112
6208
|
var _this = _super.call(this) || this;
|
|
6113
6209
|
// Internal states
|
|
6114
6210
|
_this._initialized = false;
|
|
6115
6211
|
_this._plugins = [];
|
|
6212
|
+
_this._isResizing = false;
|
|
6116
6213
|
// Bind options
|
|
6117
6214
|
_this._align = align;
|
|
6118
6215
|
_this._defaultIndex = defaultIndex;
|
|
@@ -6148,9 +6245,11 @@ var Flicking = /*#__PURE__*/function (_super) {
|
|
|
6148
6245
|
_this._useResizeObserver = useResizeObserver;
|
|
6149
6246
|
_this._resizeDebounce = resizeDebounce;
|
|
6150
6247
|
_this._maxResizeDebounce = maxResizeDebounce;
|
|
6248
|
+
_this._observePanelResize = observePanelResize;
|
|
6151
6249
|
_this._useFractionalSize = useFractionalSize;
|
|
6152
6250
|
_this._externalRenderer = externalRenderer;
|
|
6153
6251
|
_this._renderExternal = renderExternal;
|
|
6252
|
+
_this._optimizeSizeUpdate = optimizeSizeUpdate;
|
|
6154
6253
|
// Create core components
|
|
6155
6254
|
_this._viewport = new Viewport(_this, getElement(root));
|
|
6156
6255
|
_this._autoResizer = new AutoResizer(_this);
|
|
@@ -6231,6 +6330,19 @@ var Flicking = /*#__PURE__*/function (_super) {
|
|
|
6231
6330
|
enumerable: false,
|
|
6232
6331
|
configurable: true
|
|
6233
6332
|
});
|
|
6333
|
+
Object.defineProperty(__proto, "autoResizer", {
|
|
6334
|
+
/**
|
|
6335
|
+
* {@link AutoResizer} instance of the Flicking
|
|
6336
|
+
* @ko 현재 Flicking에 활성화된 {@link AutoResizer} 인스턴스
|
|
6337
|
+
* @internal
|
|
6338
|
+
* @readonly
|
|
6339
|
+
*/
|
|
6340
|
+
get: function () {
|
|
6341
|
+
return this._autoResizer;
|
|
6342
|
+
},
|
|
6343
|
+
enumerable: false,
|
|
6344
|
+
configurable: true
|
|
6345
|
+
});
|
|
6234
6346
|
Object.defineProperty(__proto, "initialized", {
|
|
6235
6347
|
// Internal States
|
|
6236
6348
|
/**
|
|
@@ -7104,6 +7216,9 @@ var Flicking = /*#__PURE__*/function (_super) {
|
|
|
7104
7216
|
// OTHERS
|
|
7105
7217
|
set: function (val) {
|
|
7106
7218
|
this._autoResize = val;
|
|
7219
|
+
if (!this._initialized) {
|
|
7220
|
+
return;
|
|
7221
|
+
}
|
|
7107
7222
|
if (val) {
|
|
7108
7223
|
this._autoResizer.enable();
|
|
7109
7224
|
} else {
|
|
@@ -7126,13 +7241,38 @@ var Flicking = /*#__PURE__*/function (_super) {
|
|
|
7126
7241
|
},
|
|
7127
7242
|
set: function (val) {
|
|
7128
7243
|
this._useResizeObserver = val;
|
|
7129
|
-
if (this._autoResize) {
|
|
7244
|
+
if (this._initialized && this._autoResize) {
|
|
7130
7245
|
this._autoResizer.enable();
|
|
7131
7246
|
}
|
|
7132
7247
|
},
|
|
7133
7248
|
enumerable: false,
|
|
7134
7249
|
configurable: true
|
|
7135
7250
|
});
|
|
7251
|
+
Object.defineProperty(__proto, "observePanelResize", {
|
|
7252
|
+
/**
|
|
7253
|
+
* Whether to use {@link https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver ResizeObserver} to observe the size of the panel element
|
|
7254
|
+
* This is only available when `useResizeObserver` is enabled.
|
|
7255
|
+
* This option garantees that the resize event is triggered when the size of the panel element is changed.
|
|
7256
|
+
* @ko 이 옵션을 활성화할 경우, {@link https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver ResizeObserver}를 사용하여 패널 엘리먼트의 크기를 추적합니다.
|
|
7257
|
+
* 이 옵션은 `useResizeObserver` 옵션이 활성화된 경우에만 사용할 수 있습니다.
|
|
7258
|
+
* 이 옵션은 패널 엘리먼트의 크기가 변경될 경우 resize 이벤트가 발생하도록 보장합니다.
|
|
7259
|
+
*/
|
|
7260
|
+
get: function () {
|
|
7261
|
+
return this._observePanelResize;
|
|
7262
|
+
},
|
|
7263
|
+
set: function (val) {
|
|
7264
|
+
this._observePanelResize = val;
|
|
7265
|
+
if (this._initialized && this._autoResize) {
|
|
7266
|
+
if (val) {
|
|
7267
|
+
this._autoResizer.observePanels();
|
|
7268
|
+
} else {
|
|
7269
|
+
this._autoResizer.unobservePanels();
|
|
7270
|
+
}
|
|
7271
|
+
}
|
|
7272
|
+
},
|
|
7273
|
+
enumerable: false,
|
|
7274
|
+
configurable: true
|
|
7275
|
+
});
|
|
7136
7276
|
Object.defineProperty(__proto, "resizeDebounce", {
|
|
7137
7277
|
/**
|
|
7138
7278
|
* Delays size recalculation from `autoResize` by the given time in milisecond.
|
|
@@ -7214,6 +7354,30 @@ var Flicking = /*#__PURE__*/function (_super) {
|
|
|
7214
7354
|
enumerable: false,
|
|
7215
7355
|
configurable: true
|
|
7216
7356
|
});
|
|
7357
|
+
Object.defineProperty(__proto, "optimizeSizeUpdate", {
|
|
7358
|
+
/**
|
|
7359
|
+
* This option works only when autoResize is set to true.
|
|
7360
|
+
* By default, autoResize listens to changes in both the viewport's width and height, updating all panel sizes accordingly.
|
|
7361
|
+
* When optimizeSizeUpdate is enabled, the update behavior is optimized based on the flicking direction:
|
|
7362
|
+
* If direction is "horizontal", only changes in width will trigger panel size updates.
|
|
7363
|
+
* If direction is "vertical", only changes in height will do so.
|
|
7364
|
+
* 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.
|
|
7365
|
+
* @ko optimizeSizeUpdate는 autoResize가 true일 때만 동작합니다.
|
|
7366
|
+
* 기본적으로 autoResize는 뷰포트의 width와 height 변화를 모두 감지하여 패널들의 사이즈를 업데이트합니다.
|
|
7367
|
+
* 이 옵션을 활성화하면 플리킹 방향에 따라 필요한 차원(horizontal → width, vertical → height)에 대해서만 사이즈를 업데이트합니다.
|
|
7368
|
+
* 내부 패널의 높이가 서로 다를 때, 플리킹 중 과도한 리사이징으로 인한 깜빡임 현상을 줄이는 데 유용합니다.
|
|
7369
|
+
* @type {boolean}
|
|
7370
|
+
* @default false
|
|
7371
|
+
*/
|
|
7372
|
+
get: function () {
|
|
7373
|
+
return this._optimizeSizeUpdate;
|
|
7374
|
+
},
|
|
7375
|
+
set: function (val) {
|
|
7376
|
+
this._optimizeSizeUpdate = val;
|
|
7377
|
+
},
|
|
7378
|
+
enumerable: false,
|
|
7379
|
+
configurable: true
|
|
7380
|
+
});
|
|
7217
7381
|
/**
|
|
7218
7382
|
* Initialize Flicking and move to the default index
|
|
7219
7383
|
* This is automatically called on Flicking's constructor when `autoInit` is true(default)
|
|
@@ -7652,6 +7816,8 @@ var Flicking = /*#__PURE__*/function (_super) {
|
|
|
7652
7816
|
return __generator(this, function (_a) {
|
|
7653
7817
|
switch (_a.label) {
|
|
7654
7818
|
case 0:
|
|
7819
|
+
if (this._isResizing) return [2 /*return*/];
|
|
7820
|
+
this._isResizing = true;
|
|
7655
7821
|
viewport = this._viewport;
|
|
7656
7822
|
renderer = this._renderer;
|
|
7657
7823
|
camera = this._camera;
|
|
@@ -7666,9 +7832,20 @@ var Flicking = /*#__PURE__*/function (_super) {
|
|
|
7666
7832
|
element: viewport.element
|
|
7667
7833
|
}));
|
|
7668
7834
|
viewport.resize();
|
|
7835
|
+
if (!this._optimizeSizeUpdate) return [3 /*break*/, 3];
|
|
7836
|
+
if (!(this.horizontal && viewport.width !== prevWidth || !this.horizontal && viewport.height !== prevHeight)) return [3 /*break*/, 2];
|
|
7669
7837
|
return [4 /*yield*/, renderer.forceRenderAllPanels()];
|
|
7670
7838
|
case 1:
|
|
7839
|
+
_a.sent();
|
|
7840
|
+
_a.label = 2;
|
|
7841
|
+
case 2:
|
|
7842
|
+
return [3 /*break*/, 5];
|
|
7843
|
+
case 3:
|
|
7844
|
+
return [4 /*yield*/, renderer.forceRenderAllPanels()];
|
|
7845
|
+
case 4:
|
|
7671
7846
|
_a.sent(); // Render all panel elements, to update sizes
|
|
7847
|
+
_a.label = 5;
|
|
7848
|
+
case 5:
|
|
7672
7849
|
if (!this._initialized) {
|
|
7673
7850
|
return [2 /*return*/];
|
|
7674
7851
|
}
|
|
@@ -7681,7 +7858,7 @@ var Flicking = /*#__PURE__*/function (_super) {
|
|
|
7681
7858
|
camera.updatePanelOrder();
|
|
7682
7859
|
camera.updateOffset();
|
|
7683
7860
|
return [4 /*yield*/, renderer.render()];
|
|
7684
|
-
case
|
|
7861
|
+
case 6:
|
|
7685
7862
|
_a.sent();
|
|
7686
7863
|
if (!this._initialized) {
|
|
7687
7864
|
return [2 /*return*/];
|
|
@@ -7704,6 +7881,7 @@ var Flicking = /*#__PURE__*/function (_super) {
|
|
|
7704
7881
|
sizeChanged: sizeChanged,
|
|
7705
7882
|
element: viewport.element
|
|
7706
7883
|
}));
|
|
7884
|
+
this._isResizing = false;
|
|
7707
7885
|
return [2 /*return*/];
|
|
7708
7886
|
}
|
|
7709
7887
|
});
|
|
@@ -7923,7 +8101,7 @@ var Flicking = /*#__PURE__*/function (_super) {
|
|
|
7923
8101
|
* Flicking.VERSION; // ex) 4.0.0
|
|
7924
8102
|
* ```
|
|
7925
8103
|
*/
|
|
7926
|
-
Flicking.VERSION = "4.
|
|
8104
|
+
Flicking.VERSION = "4.14.0";
|
|
7927
8105
|
return Flicking;
|
|
7928
8106
|
}(Component);
|
|
7929
8107
|
|
|
@@ -8479,6 +8657,190 @@ var parseAlign = function (alignVal) {
|
|
|
8479
8657
|
}
|
|
8480
8658
|
};
|
|
8481
8659
|
|
|
8660
|
+
// Check if Flicking has reached the first panel
|
|
8661
|
+
var getIsReachStart = function (flicking) {
|
|
8662
|
+
return !flicking.circular && flicking.index === 0;
|
|
8663
|
+
};
|
|
8664
|
+
// Check if Flicking has reached the last panel
|
|
8665
|
+
var getIsReachEnd = function (flicking) {
|
|
8666
|
+
return !flicking.circular && flicking.index === flicking.panelCount - 1;
|
|
8667
|
+
};
|
|
8668
|
+
// Get the total number of panels
|
|
8669
|
+
var getTotalPanelCount = function (flicking) {
|
|
8670
|
+
return flicking.panelCount;
|
|
8671
|
+
};
|
|
8672
|
+
// Get the current active panel index
|
|
8673
|
+
var getCurrentPanelIndex = function (flicking) {
|
|
8674
|
+
return flicking.index;
|
|
8675
|
+
};
|
|
8676
|
+
// Calculate the overall scroll progress percentage based on the current camera position
|
|
8677
|
+
var getProgress = function (flicking) {
|
|
8678
|
+
var cam = flicking.camera;
|
|
8679
|
+
var progressRatio = (cam.position - cam.range.min) / (cam.range.max - cam.range.min);
|
|
8680
|
+
var percent = Math.min(Math.max(progressRatio, 0), 1) * 100;
|
|
8681
|
+
return percent;
|
|
8682
|
+
};
|
|
8683
|
+
// Calculate the progress between panels including decimal values
|
|
8684
|
+
var getIndexProgress = function (flicking) {
|
|
8685
|
+
var cam = flicking.camera;
|
|
8686
|
+
var anchorPoints = cam.anchorPoints;
|
|
8687
|
+
var length = anchorPoints.length;
|
|
8688
|
+
var cameraPosition = cam.position;
|
|
8689
|
+
var isCircular = flicking.circularEnabled;
|
|
8690
|
+
var indexProgress = 0;
|
|
8691
|
+
var _a = cam.range,
|
|
8692
|
+
min = _a.min,
|
|
8693
|
+
max = _a.max;
|
|
8694
|
+
var firstAnchorPoint = anchorPoints[0];
|
|
8695
|
+
var lastAnchorPoint = anchorPoints[length - 1];
|
|
8696
|
+
var distanceLastToFirst = max - lastAnchorPoint.position + (firstAnchorPoint.position - min);
|
|
8697
|
+
anchorPoints.some(function (anchorPoint, index) {
|
|
8698
|
+
var anchorPosition = anchorPoint.position;
|
|
8699
|
+
var nextAnchorPoint = anchorPoints[index + 1];
|
|
8700
|
+
if (index === 0 && cameraPosition <= anchorPosition) {
|
|
8701
|
+
if (isCircular) {
|
|
8702
|
+
indexProgress = (cameraPosition - anchorPosition) / distanceLastToFirst;
|
|
8703
|
+
} else {
|
|
8704
|
+
indexProgress = (cameraPosition - anchorPosition) / anchorPoint.panel.size;
|
|
8705
|
+
}
|
|
8706
|
+
} else if (index === length - 1 && cameraPosition >= anchorPosition) {
|
|
8707
|
+
if (isCircular) {
|
|
8708
|
+
indexProgress = index + (cameraPosition - anchorPosition) / distanceLastToFirst;
|
|
8709
|
+
} else {
|
|
8710
|
+
indexProgress = index + (cameraPosition - anchorPosition) / anchorPoint.panel.size;
|
|
8711
|
+
}
|
|
8712
|
+
} else if (nextAnchorPoint && anchorPosition <= cameraPosition && cameraPosition <= nextAnchorPoint.position) {
|
|
8713
|
+
indexProgress = index + (cameraPosition - anchorPosition) / (nextAnchorPoint.position - anchorPosition);
|
|
8714
|
+
} else {
|
|
8715
|
+
return false;
|
|
8716
|
+
}
|
|
8717
|
+
return true;
|
|
8718
|
+
});
|
|
8719
|
+
return indexProgress;
|
|
8720
|
+
};
|
|
8721
|
+
/**
|
|
8722
|
+
* Internal reactive API adapter for Flicking that manages state and event listeners
|
|
8723
|
+
* This adapter is used internally by framework-specific packages (react-flicking, vue-flicking, etc.)
|
|
8724
|
+
* to provide reactive API support. Users rarely need to use this directly.
|
|
8725
|
+
* @ko Flicking의 상태와 이벤트 리스너를 관리하는 내부 반응형 API 어댑터
|
|
8726
|
+
* 이 어댑터는 react-flicking, vue-flicking 등의 프레임워크별 패키지에서 내부적으로 사용되어
|
|
8727
|
+
* 반응형 API 지원을 제공합니다. 사용자가 직접 사용할 일은 거의 없습니다.
|
|
8728
|
+
* @param onInit - Callback when reactive object is initialized<ko>반응형 객체가 초기화될 때 호출되는 콜백</ko>
|
|
8729
|
+
* @param onDestroy - Callback when reactive object is destroyed<ko>반응형 객체가 파괴될 때 호출되는 콜백</ko>
|
|
8730
|
+
* @param setMethods - Function to set available methods<ko>사용 가능한 메서드를 설정하는 함수</ko>
|
|
8731
|
+
* @returns Reactive object with Flicking state and methods<ko>Flicking 상태와 메서드를 포함한 반응형 객체</ko>
|
|
8732
|
+
*/
|
|
8733
|
+
var flickingReactiveAPIAdapter = function (_a) {
|
|
8734
|
+
var _b, _c, _d;
|
|
8735
|
+
var onInit = _a.onInit,
|
|
8736
|
+
onDestroy = _a.onDestroy,
|
|
8737
|
+
setMethods = _a.setMethods,
|
|
8738
|
+
getProps = _a.getProps;
|
|
8739
|
+
var flicking;
|
|
8740
|
+
// Move to a specific panel index
|
|
8741
|
+
var moveTo = function (i) {
|
|
8742
|
+
if (flicking == null) {
|
|
8743
|
+
return Promise.reject(new Error("Flicking instance is not available"));
|
|
8744
|
+
}
|
|
8745
|
+
if (flicking === null || flicking === void 0 ? void 0 : flicking.animating) {
|
|
8746
|
+
return Promise.resolve();
|
|
8747
|
+
}
|
|
8748
|
+
return flicking.moveTo(i);
|
|
8749
|
+
};
|
|
8750
|
+
setMethods(["moveTo"]);
|
|
8751
|
+
var options = getProps().options;
|
|
8752
|
+
// options를 고려하지 않고 초기값을 설정해도 동작에는 아무런 문제가 없으나, 이 시점의 초기값과 컴포넌트 init 단계에서의 초기값이 다르면 화면 리렌더링이 발생할 수 있으므로
|
|
8753
|
+
// 이렇게 미리 옵션을 통해서 예측할 수 있는 부분들은 맞춰둔다.
|
|
8754
|
+
var reactiveObj = core.reactive({
|
|
8755
|
+
isReachStart: (options === null || options === void 0 ? void 0 : options.defaultIndex) ? (options === null || options === void 0 ? void 0 : options.defaultIndex) === 0 : true,
|
|
8756
|
+
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,
|
|
8757
|
+
totalPanelCount: (_b = options === null || options === void 0 ? void 0 : options.totalPanelCount) !== null && _b !== void 0 ? _b : 0,
|
|
8758
|
+
currentPanelIndex: (_c = options === null || options === void 0 ? void 0 : options.defaultIndex) !== null && _c !== void 0 ? _c : 0,
|
|
8759
|
+
progress: 0,
|
|
8760
|
+
indexProgress: (_d = options === null || options === void 0 ? void 0 : options.defaultIndex) !== null && _d !== void 0 ? _d : 0,
|
|
8761
|
+
moveTo: moveTo
|
|
8762
|
+
});
|
|
8763
|
+
// Update state when panel changes
|
|
8764
|
+
var onChanged = function () {
|
|
8765
|
+
if (flicking === undefined) return;
|
|
8766
|
+
reactiveObj.isReachStart = getIsReachStart(flicking);
|
|
8767
|
+
reactiveObj.isReachEnd = getIsReachEnd(flicking);
|
|
8768
|
+
reactiveObj.currentPanelIndex = getCurrentPanelIndex(flicking);
|
|
8769
|
+
};
|
|
8770
|
+
// Update state when panel count changes
|
|
8771
|
+
var onPanelChange = function () {
|
|
8772
|
+
if (flicking === undefined) return;
|
|
8773
|
+
onChanged();
|
|
8774
|
+
reactiveObj.totalPanelCount = getTotalPanelCount(flicking);
|
|
8775
|
+
};
|
|
8776
|
+
// Update progress when camera moves
|
|
8777
|
+
var onMove = function () {
|
|
8778
|
+
if (flicking === undefined) return;
|
|
8779
|
+
reactiveObj.progress = getProgress(flicking);
|
|
8780
|
+
reactiveObj.indexProgress = getIndexProgress(flicking);
|
|
8781
|
+
};
|
|
8782
|
+
onInit(function (inst, data) {
|
|
8783
|
+
flicking = data.flicking;
|
|
8784
|
+
if (flicking === undefined) return;
|
|
8785
|
+
reactiveObj.isReachStart = getIsReachStart(flicking);
|
|
8786
|
+
reactiveObj.isReachEnd = getIsReachEnd(flicking);
|
|
8787
|
+
reactiveObj.currentPanelIndex = getCurrentPanelIndex(flicking);
|
|
8788
|
+
reactiveObj.progress = getProgress(flicking);
|
|
8789
|
+
reactiveObj.totalPanelCount = getTotalPanelCount(flicking);
|
|
8790
|
+
flicking === null || flicking === void 0 ? void 0 : flicking.on("changed", onChanged);
|
|
8791
|
+
flicking === null || flicking === void 0 ? void 0 : flicking.on("panelChange", onPanelChange);
|
|
8792
|
+
flicking === null || flicking === void 0 ? void 0 : flicking.on("move", onMove);
|
|
8793
|
+
});
|
|
8794
|
+
onDestroy(function () {
|
|
8795
|
+
flicking === null || flicking === void 0 ? void 0 : flicking.off("changed", onChanged);
|
|
8796
|
+
flicking === null || flicking === void 0 ? void 0 : flicking.off("panelChange", onPanelChange);
|
|
8797
|
+
flicking === null || flicking === void 0 ? void 0 : flicking.off("move", onMove);
|
|
8798
|
+
});
|
|
8799
|
+
return reactiveObj;
|
|
8800
|
+
};
|
|
8801
|
+
/**
|
|
8802
|
+
* Connect Flicking instance to reactive API
|
|
8803
|
+
* @ko Flicking 인스턴스를 반응형 API에 연결합니다
|
|
8804
|
+
* @param {Flicking} flicking - Flicking instance to connect<ko>연결할 Flicking 인스턴스</ko>
|
|
8805
|
+
* @param {FlickingReactiveAPIOptions} [options] - Flicking options<ko>Flicking 옵션</ko>
|
|
8806
|
+
* @returns {FlickingReactiveObject} Reactive object with Flicking state and methods<ko>Flicking 상태와 메서드를 포함한 반응형 객체</ko>
|
|
8807
|
+
* @example
|
|
8808
|
+
* ```js
|
|
8809
|
+
* import Flicking, { connectFlickingReactiveAPI } from "@egjs/flicking";
|
|
8810
|
+
*
|
|
8811
|
+
* const flicking = new Flicking("#el");
|
|
8812
|
+
* const reactiveObj = connectFlickingReactiveAPI(flicking);
|
|
8813
|
+
*
|
|
8814
|
+
* // Access reactive state
|
|
8815
|
+
* console.log("Current panel:", reactiveObj.currentPanelIndex);
|
|
8816
|
+
* console.log("Progress:", reactiveObj.progress + "%");
|
|
8817
|
+
* console.log("Is at start:", reactiveObj.isReachStart);
|
|
8818
|
+
* console.log("Is at end:", reactiveObj.isReachEnd);
|
|
8819
|
+
* console.log("Total panels:", reactiveObj.totalPanelCount);
|
|
8820
|
+
* console.log("Index progress:", reactiveObj.indexProgress);
|
|
8821
|
+
*
|
|
8822
|
+
* // Subscribe to state changes
|
|
8823
|
+
* reactiveObj.subscribe("currentPanelIndex", (nextValue) => {
|
|
8824
|
+
* console.log("Panel changed to:", nextValue);
|
|
8825
|
+
* });
|
|
8826
|
+
*
|
|
8827
|
+
* // Use reactive methods
|
|
8828
|
+
* reactiveObj.moveTo(2); // Move to third panel
|
|
8829
|
+
* ```
|
|
8830
|
+
*/
|
|
8831
|
+
var connectFlickingReactiveAPI = function (flicking, options) {
|
|
8832
|
+
var obj = core.adaptReactive(flickingReactiveAPIAdapter, function () {
|
|
8833
|
+
return {
|
|
8834
|
+
flicking: flicking,
|
|
8835
|
+
options: options
|
|
8836
|
+
};
|
|
8837
|
+
});
|
|
8838
|
+
obj.mounted();
|
|
8839
|
+
var instance = obj.instance();
|
|
8840
|
+
obj.init();
|
|
8841
|
+
return instance;
|
|
8842
|
+
};
|
|
8843
|
+
|
|
8482
8844
|
/*
|
|
8483
8845
|
* Copyright (c) 2015 NAVER Corp.
|
|
8484
8846
|
* egjs projects are licensed under the MIT license
|
|
@@ -8552,7 +8914,7 @@ var modules = {
|
|
|
8552
8914
|
find: find,
|
|
8553
8915
|
findRight: findRight,
|
|
8554
8916
|
findIndex: findIndex,
|
|
8555
|
-
getProgress: getProgress,
|
|
8917
|
+
getProgress: getProgress$1,
|
|
8556
8918
|
getStyle: getStyle,
|
|
8557
8919
|
setSize: setSize,
|
|
8558
8920
|
isBetween: isBetween,
|
|
@@ -8561,7 +8923,9 @@ var modules = {
|
|
|
8561
8923
|
getElementSize: getElementSize,
|
|
8562
8924
|
setPrototypeOf: setPrototypeOf,
|
|
8563
8925
|
camelize: camelize,
|
|
8564
|
-
getDataAttributes: getDataAttributes
|
|
8926
|
+
getDataAttributes: getDataAttributes,
|
|
8927
|
+
flickingReactiveAPIAdapter: flickingReactiveAPIAdapter,
|
|
8928
|
+
connectFlickingReactiveAPI: connectFlickingReactiveAPI
|
|
8565
8929
|
};
|
|
8566
8930
|
|
|
8567
8931
|
/*
|
|
@@ -8618,10 +8982,12 @@ exports.checkExistence = checkExistence;
|
|
|
8618
8982
|
exports.circulateIndex = circulateIndex;
|
|
8619
8983
|
exports.circulatePosition = circulatePosition;
|
|
8620
8984
|
exports.clamp = clamp;
|
|
8985
|
+
exports.connectFlickingReactiveAPI = connectFlickingReactiveAPI;
|
|
8621
8986
|
exports["default"] = Flicking;
|
|
8622
8987
|
exports.find = find;
|
|
8623
8988
|
exports.findIndex = findIndex;
|
|
8624
8989
|
exports.findRight = findRight;
|
|
8990
|
+
exports.flickingReactiveAPIAdapter = flickingReactiveAPIAdapter;
|
|
8625
8991
|
exports.getDataAttributes = getDataAttributes;
|
|
8626
8992
|
exports.getDefaultCameraTransform = getDefaultCameraTransform;
|
|
8627
8993
|
exports.getDirection = getDirection;
|
|
@@ -8629,7 +8995,7 @@ exports.getElement = getElement;
|
|
|
8629
8995
|
exports.getElementSize = getElementSize;
|
|
8630
8996
|
exports.getFlickingAttached = getFlickingAttached;
|
|
8631
8997
|
exports.getMinusCompensatedIndex = getMinusCompensatedIndex;
|
|
8632
|
-
exports.getProgress = getProgress;
|
|
8998
|
+
exports.getProgress = getProgress$1;
|
|
8633
8999
|
exports.getRenderingPanels = getRenderingPanels;
|
|
8634
9000
|
exports.getStyle = getStyle;
|
|
8635
9001
|
exports.includes = includes;
|