@egjs/flicking 4.13.2-beta.1 → 4.14.1-beta.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 +53 -16
- package/debug/reactive/index.html +240 -0
- package/declaration/index.d.ts +1 -0
- package/declaration/reactive/index.d.ts +25 -0
- package/dist/flicking.cjs.js +202 -10
- package/dist/flicking.cjs.js.map +1 -1
- package/dist/flicking.esm.js +196 -8
- package/dist/flicking.esm.js.map +1 -1
- package/dist/flicking.js +206 -12
- 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 +527 -8
- 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/control/Control.ts +3 -1
- package/src/index.ts +1 -0
- package/src/index.umd.ts +2 -0
- package/src/reactive/index.ts +326 -0
- package/debug/example/index.html +0 -82
package/dist/flicking.js
CHANGED
|
@@ -4,13 +4,13 @@ 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.1-beta.0
|
|
8
8
|
*/
|
|
9
9
|
(function (global, factory) {
|
|
10
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@egjs/component'), require('@egjs/axes'), require('@egjs/imready')) :
|
|
11
|
-
typeof define === 'function' && define.amd ? define(['@egjs/component', '@egjs/axes', '@egjs/imready'], factory) :
|
|
12
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Flicking = factory(global.eg.Component, global.eg.Axes, global.eg.ImReady));
|
|
13
|
-
})(this, (function (Component, Axes, ImReady) { 'use strict';
|
|
10
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@egjs/component'), require('@egjs/axes'), require('@egjs/imready'), require('@cfcs/core')) :
|
|
11
|
+
typeof define === 'function' && define.amd ? define(['@egjs/component', '@egjs/axes', '@egjs/imready', '@cfcs/core'], factory) :
|
|
12
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Flicking = factory(global.eg.Component, global.eg.Axes, global.eg.ImReady, global.core));
|
|
13
|
+
})(this, (function (Component, Axes, ImReady, core) { 'use strict';
|
|
14
14
|
|
|
15
15
|
/******************************************************************************
|
|
16
16
|
Copyright (c) Microsoft Corporation.
|
|
@@ -682,7 +682,7 @@ version: 4.13.2-beta.1
|
|
|
682
682
|
}
|
|
683
683
|
return -1;
|
|
684
684
|
};
|
|
685
|
-
var getProgress = function (pos, prev, next) {
|
|
685
|
+
var getProgress$1 = function (pos, prev, next) {
|
|
686
686
|
return (pos - prev) / (next - prev);
|
|
687
687
|
};
|
|
688
688
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
@@ -803,7 +803,7 @@ version: 4.13.2-beta.1
|
|
|
803
803
|
find: find,
|
|
804
804
|
findRight: findRight,
|
|
805
805
|
findIndex: findIndex,
|
|
806
|
-
getProgress: getProgress,
|
|
806
|
+
getProgress: getProgress$1,
|
|
807
807
|
getStyle: getStyle,
|
|
808
808
|
setSize: setSize,
|
|
809
809
|
isBetween: isBetween,
|
|
@@ -2846,9 +2846,12 @@ version: 4.13.2-beta.1
|
|
|
2846
2846
|
return __generator(this, function (_a) {
|
|
2847
2847
|
switch (_a.label) {
|
|
2848
2848
|
case 0:
|
|
2849
|
+
if (!flicking.initialized) return [3 /*break*/, 2];
|
|
2849
2850
|
return [4 /*yield*/, flicking.renderer.render()];
|
|
2850
2851
|
case 1:
|
|
2851
2852
|
_a.sent();
|
|
2853
|
+
_a.label = 2;
|
|
2854
|
+
case 2:
|
|
2852
2855
|
return [2 /*return*/];
|
|
2853
2856
|
}
|
|
2854
2857
|
});
|
|
@@ -4181,7 +4184,7 @@ version: 4.13.2-beta.1
|
|
|
4181
4184
|
if (prevPosition > panelPos) {
|
|
4182
4185
|
prevPosition -= rangeDiff;
|
|
4183
4186
|
}
|
|
4184
|
-
return nearestPanel.index - 1 + getProgress(position, prevPosition, panelPos);
|
|
4187
|
+
return nearestPanel.index - 1 + getProgress$1(position, prevPosition, panelPos);
|
|
4185
4188
|
} else {
|
|
4186
4189
|
var nextPanel = nearestPanel.next();
|
|
4187
4190
|
var nextPosition = nextPanel ? nextPanel.position + nextPanel.offset : nextRange + bounceSize[1];
|
|
@@ -4189,7 +4192,7 @@ version: 4.13.2-beta.1
|
|
|
4189
4192
|
if (nextPosition < panelPos) {
|
|
4190
4193
|
nextPosition += rangeDiff;
|
|
4191
4194
|
}
|
|
4192
|
-
return nearestPanel.index + getProgress(position, panelPos, nextPosition);
|
|
4195
|
+
return nearestPanel.index + getProgress$1(position, panelPos, nextPosition);
|
|
4193
4196
|
}
|
|
4194
4197
|
},
|
|
4195
4198
|
enumerable: false,
|
|
@@ -5545,10 +5548,10 @@ version: 4.13.2-beta.1
|
|
|
5545
5548
|
}
|
|
5546
5549
|
if (camPos < position) {
|
|
5547
5550
|
var disappearPosNext = position + (camera.size - camera.alignPosition) + alignPosition;
|
|
5548
|
-
return -getProgress(camPos, position, disappearPosNext);
|
|
5551
|
+
return -getProgress$1(camPos, position, disappearPosNext);
|
|
5549
5552
|
} else {
|
|
5550
5553
|
var disappearPosPrev = position - (camera.alignPosition + this._size - alignPosition);
|
|
5551
|
-
return 1 - getProgress(camPos, disappearPosPrev, position);
|
|
5554
|
+
return 1 - getProgress$1(camPos, disappearPosPrev, position);
|
|
5552
5555
|
}
|
|
5553
5556
|
},
|
|
5554
5557
|
enumerable: false,
|
|
@@ -8196,7 +8199,7 @@ version: 4.13.2-beta.1
|
|
|
8196
8199
|
* Flicking.VERSION; // ex) 4.0.0
|
|
8197
8200
|
* ```
|
|
8198
8201
|
*/
|
|
8199
|
-
Flicking.VERSION = "4.
|
|
8202
|
+
Flicking.VERSION = "4.14.1-beta.0";
|
|
8200
8203
|
return Flicking;
|
|
8201
8204
|
}(Component);
|
|
8202
8205
|
|
|
@@ -8783,6 +8786,196 @@ version: 4.13.2-beta.1
|
|
|
8783
8786
|
getDefaultCameraTransform: getDefaultCameraTransform
|
|
8784
8787
|
};
|
|
8785
8788
|
|
|
8789
|
+
// Check if Flicking has reached the first panel
|
|
8790
|
+
var getIsReachStart = function (flicking) {
|
|
8791
|
+
return !flicking.circular && flicking.index === 0;
|
|
8792
|
+
};
|
|
8793
|
+
// Check if Flicking has reached the last panel
|
|
8794
|
+
var getIsReachEnd = function (flicking) {
|
|
8795
|
+
return !flicking.circular && flicking.index === flicking.panelCount - 1;
|
|
8796
|
+
};
|
|
8797
|
+
// Get the total number of panels
|
|
8798
|
+
var getTotalPanelCount = function (flicking) {
|
|
8799
|
+
return flicking.panelCount;
|
|
8800
|
+
};
|
|
8801
|
+
// Get the current active panel index
|
|
8802
|
+
var getCurrentPanelIndex = function (flicking) {
|
|
8803
|
+
return flicking.index;
|
|
8804
|
+
};
|
|
8805
|
+
// Calculate the overall scroll progress percentage based on the current camera position
|
|
8806
|
+
var getProgress = function (flicking) {
|
|
8807
|
+
var cam = flicking.camera;
|
|
8808
|
+
var progressRatio = (cam.position - cam.range.min) / (cam.range.max - cam.range.min);
|
|
8809
|
+
var percent = Math.min(Math.max(progressRatio, 0), 1) * 100;
|
|
8810
|
+
return percent;
|
|
8811
|
+
};
|
|
8812
|
+
// Calculate the progress between panels including decimal values
|
|
8813
|
+
var getIndexProgress = function (flicking) {
|
|
8814
|
+
var cam = flicking.camera;
|
|
8815
|
+
var anchorPoints = cam.anchorPoints;
|
|
8816
|
+
var length = anchorPoints.length;
|
|
8817
|
+
var cameraPosition = cam.position;
|
|
8818
|
+
var isCircular = flicking.circularEnabled;
|
|
8819
|
+
var indexProgress = 0;
|
|
8820
|
+
var _a = cam.range,
|
|
8821
|
+
min = _a.min,
|
|
8822
|
+
max = _a.max;
|
|
8823
|
+
var firstAnchorPoint = anchorPoints[0];
|
|
8824
|
+
var lastAnchorPoint = anchorPoints[length - 1];
|
|
8825
|
+
var distanceLastToFirst = max - lastAnchorPoint.position + (firstAnchorPoint.position - min);
|
|
8826
|
+
anchorPoints.some(function (anchorPoint, index) {
|
|
8827
|
+
var anchorPosition = anchorPoint.position;
|
|
8828
|
+
var nextAnchorPoint = anchorPoints[index + 1];
|
|
8829
|
+
if (index === 0 && cameraPosition <= anchorPosition) {
|
|
8830
|
+
if (isCircular) {
|
|
8831
|
+
indexProgress = (cameraPosition - anchorPosition) / distanceLastToFirst;
|
|
8832
|
+
} else {
|
|
8833
|
+
indexProgress = (cameraPosition - anchorPosition) / anchorPoint.panel.size;
|
|
8834
|
+
}
|
|
8835
|
+
} else if (index === length - 1 && cameraPosition >= anchorPosition) {
|
|
8836
|
+
if (isCircular) {
|
|
8837
|
+
indexProgress = index + (cameraPosition - anchorPosition) / distanceLastToFirst;
|
|
8838
|
+
} else {
|
|
8839
|
+
indexProgress = index + (cameraPosition - anchorPosition) / anchorPoint.panel.size;
|
|
8840
|
+
}
|
|
8841
|
+
} else if (nextAnchorPoint && anchorPosition <= cameraPosition && cameraPosition <= nextAnchorPoint.position) {
|
|
8842
|
+
indexProgress = index + (cameraPosition - anchorPosition) / (nextAnchorPoint.position - anchorPosition);
|
|
8843
|
+
} else {
|
|
8844
|
+
return false;
|
|
8845
|
+
}
|
|
8846
|
+
return true;
|
|
8847
|
+
});
|
|
8848
|
+
return indexProgress;
|
|
8849
|
+
};
|
|
8850
|
+
/**
|
|
8851
|
+
* Internal reactive API adapter for Flicking that manages state and event listeners
|
|
8852
|
+
* This adapter is used internally by framework-specific packages (react-flicking, vue-flicking, etc.)
|
|
8853
|
+
* to provide reactive API support. Users rarely need to use this directly.
|
|
8854
|
+
* @ko Flicking의 상태와 이벤트 리스너를 관리하는 내부 반응형 API 어댑터
|
|
8855
|
+
* 이 어댑터는 react-flicking, vue-flicking 등의 프레임워크별 패키지에서 내부적으로 사용되어
|
|
8856
|
+
* 반응형 API 지원을 제공합니다. 사용자가 직접 사용할 일은 거의 없습니다.
|
|
8857
|
+
* @param onInit - Callback when reactive object is initialized<ko>반응형 객체가 초기화될 때 호출되는 콜백</ko>
|
|
8858
|
+
* @param onDestroy - Callback when reactive object is destroyed<ko>반응형 객체가 파괴될 때 호출되는 콜백</ko>
|
|
8859
|
+
* @param setMethods - Function to set available methods<ko>사용 가능한 메서드를 설정하는 함수</ko>
|
|
8860
|
+
* @returns Reactive object with Flicking state and methods<ko>Flicking 상태와 메서드를 포함한 반응형 객체</ko>
|
|
8861
|
+
*/
|
|
8862
|
+
var flickingReactiveAPIAdapter = function (_a) {
|
|
8863
|
+
var _b, _c, _d;
|
|
8864
|
+
var onInit = _a.onInit,
|
|
8865
|
+
onDestroy = _a.onDestroy,
|
|
8866
|
+
setMethods = _a.setMethods,
|
|
8867
|
+
getProps = _a.getProps;
|
|
8868
|
+
var flicking;
|
|
8869
|
+
// Move to a specific panel index
|
|
8870
|
+
var moveTo = function (i) {
|
|
8871
|
+
if (flicking == null) {
|
|
8872
|
+
return Promise.reject(new Error("Flicking instance is not available"));
|
|
8873
|
+
}
|
|
8874
|
+
if (flicking === null || flicking === void 0 ? void 0 : flicking.animating) {
|
|
8875
|
+
return Promise.resolve();
|
|
8876
|
+
}
|
|
8877
|
+
return flicking.moveTo(i);
|
|
8878
|
+
};
|
|
8879
|
+
setMethods(["moveTo"]);
|
|
8880
|
+
var options = getProps().options;
|
|
8881
|
+
// options를 고려하지 않고 초기값을 설정해도 동작에는 아무런 문제가 없으나, 이 시점의 초기값과 컴포넌트 init 단계에서의 초기값이 다르면 화면 리렌더링이 발생할 수 있으므로
|
|
8882
|
+
// 이렇게 미리 옵션을 통해서 예측할 수 있는 부분들은 맞춰둔다.
|
|
8883
|
+
var reactiveObj = core.reactive({
|
|
8884
|
+
isReachStart: (options === null || options === void 0 ? void 0 : options.defaultIndex) ? (options === null || options === void 0 ? void 0 : options.defaultIndex) === 0 : true,
|
|
8885
|
+
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,
|
|
8886
|
+
totalPanelCount: (_b = options === null || options === void 0 ? void 0 : options.totalPanelCount) !== null && _b !== void 0 ? _b : 0,
|
|
8887
|
+
currentPanelIndex: (_c = options === null || options === void 0 ? void 0 : options.defaultIndex) !== null && _c !== void 0 ? _c : 0,
|
|
8888
|
+
progress: 0,
|
|
8889
|
+
indexProgress: (_d = options === null || options === void 0 ? void 0 : options.defaultIndex) !== null && _d !== void 0 ? _d : 0,
|
|
8890
|
+
moveTo: moveTo
|
|
8891
|
+
});
|
|
8892
|
+
// Update state when panel changes
|
|
8893
|
+
var onChanged = function () {
|
|
8894
|
+
if (flicking === undefined) return;
|
|
8895
|
+
reactiveObj.isReachStart = getIsReachStart(flicking);
|
|
8896
|
+
reactiveObj.isReachEnd = getIsReachEnd(flicking);
|
|
8897
|
+
reactiveObj.currentPanelIndex = getCurrentPanelIndex(flicking);
|
|
8898
|
+
};
|
|
8899
|
+
// Update state when panel count changes
|
|
8900
|
+
var onPanelChange = function () {
|
|
8901
|
+
if (flicking === undefined) return;
|
|
8902
|
+
onChanged();
|
|
8903
|
+
reactiveObj.totalPanelCount = getTotalPanelCount(flicking);
|
|
8904
|
+
};
|
|
8905
|
+
// Update progress when camera moves
|
|
8906
|
+
var onMove = function () {
|
|
8907
|
+
if (flicking === undefined) return;
|
|
8908
|
+
reactiveObj.progress = getProgress(flicking);
|
|
8909
|
+
reactiveObj.indexProgress = getIndexProgress(flicking);
|
|
8910
|
+
};
|
|
8911
|
+
onInit(function (inst, data) {
|
|
8912
|
+
flicking = data.flicking;
|
|
8913
|
+
if (flicking === undefined) return;
|
|
8914
|
+
reactiveObj.isReachStart = getIsReachStart(flicking);
|
|
8915
|
+
reactiveObj.isReachEnd = getIsReachEnd(flicking);
|
|
8916
|
+
reactiveObj.currentPanelIndex = getCurrentPanelIndex(flicking);
|
|
8917
|
+
reactiveObj.progress = getProgress(flicking);
|
|
8918
|
+
reactiveObj.totalPanelCount = getTotalPanelCount(flicking);
|
|
8919
|
+
flicking === null || flicking === void 0 ? void 0 : flicking.on("changed", onChanged);
|
|
8920
|
+
flicking === null || flicking === void 0 ? void 0 : flicking.on("panelChange", onPanelChange);
|
|
8921
|
+
flicking === null || flicking === void 0 ? void 0 : flicking.on("move", onMove);
|
|
8922
|
+
});
|
|
8923
|
+
onDestroy(function () {
|
|
8924
|
+
flicking === null || flicking === void 0 ? void 0 : flicking.off("changed", onChanged);
|
|
8925
|
+
flicking === null || flicking === void 0 ? void 0 : flicking.off("panelChange", onPanelChange);
|
|
8926
|
+
flicking === null || flicking === void 0 ? void 0 : flicking.off("move", onMove);
|
|
8927
|
+
});
|
|
8928
|
+
return reactiveObj;
|
|
8929
|
+
};
|
|
8930
|
+
/**
|
|
8931
|
+
* Connect Flicking instance to reactive API
|
|
8932
|
+
* @ko Flicking 인스턴스를 반응형 API에 연결합니다
|
|
8933
|
+
* @param {Flicking} flicking - Flicking instance to connect<ko>연결할 Flicking 인스턴스</ko>
|
|
8934
|
+
* @param {FlickingReactiveAPIOptions} [options] - Flicking options<ko>Flicking 옵션</ko>
|
|
8935
|
+
* @returns {FlickingReactiveObject} Reactive object with Flicking state and methods<ko>Flicking 상태와 메서드를 포함한 반응형 객체</ko>
|
|
8936
|
+
* @example
|
|
8937
|
+
* ```js
|
|
8938
|
+
* import Flicking, { connectFlickingReactiveAPI } from "@egjs/flicking";
|
|
8939
|
+
*
|
|
8940
|
+
* const flicking = new Flicking("#el");
|
|
8941
|
+
* const reactiveObj = connectFlickingReactiveAPI(flicking);
|
|
8942
|
+
*
|
|
8943
|
+
* // Access reactive state
|
|
8944
|
+
* console.log("Current panel:", reactiveObj.currentPanelIndex);
|
|
8945
|
+
* console.log("Progress:", reactiveObj.progress + "%");
|
|
8946
|
+
* console.log("Is at start:", reactiveObj.isReachStart);
|
|
8947
|
+
* console.log("Is at end:", reactiveObj.isReachEnd);
|
|
8948
|
+
* console.log("Total panels:", reactiveObj.totalPanelCount);
|
|
8949
|
+
* console.log("Index progress:", reactiveObj.indexProgress);
|
|
8950
|
+
*
|
|
8951
|
+
* // Subscribe to state changes
|
|
8952
|
+
* reactiveObj.subscribe("currentPanelIndex", (nextValue) => {
|
|
8953
|
+
* console.log("Panel changed to:", nextValue);
|
|
8954
|
+
* });
|
|
8955
|
+
*
|
|
8956
|
+
* // Use reactive methods
|
|
8957
|
+
* reactiveObj.moveTo(2); // Move to third panel
|
|
8958
|
+
* ```
|
|
8959
|
+
*/
|
|
8960
|
+
var connectFlickingReactiveAPI = function (flicking, options) {
|
|
8961
|
+
var obj = core.adaptReactive(flickingReactiveAPIAdapter, function () {
|
|
8962
|
+
return {
|
|
8963
|
+
flicking: flicking,
|
|
8964
|
+
options: options
|
|
8965
|
+
};
|
|
8966
|
+
});
|
|
8967
|
+
obj.mounted();
|
|
8968
|
+
var instance = obj.instance();
|
|
8969
|
+
obj.init();
|
|
8970
|
+
return instance;
|
|
8971
|
+
};
|
|
8972
|
+
|
|
8973
|
+
var FlickingReactiveAPI = {
|
|
8974
|
+
__proto__: null,
|
|
8975
|
+
flickingReactiveAPIAdapter: flickingReactiveAPIAdapter,
|
|
8976
|
+
connectFlickingReactiveAPI: connectFlickingReactiveAPI
|
|
8977
|
+
};
|
|
8978
|
+
|
|
8786
8979
|
/*
|
|
8787
8980
|
* Copyright (c) 2015 NAVER Corp.
|
|
8788
8981
|
* egjs projects are licensed under the MIT license
|
|
@@ -8795,6 +8988,7 @@ version: 4.13.2-beta.1
|
|
|
8795
8988
|
merge(Flicking, CFC);
|
|
8796
8989
|
merge(Flicking, Utils);
|
|
8797
8990
|
merge(Flicking, CrossFlicking$1);
|
|
8991
|
+
merge(Flicking, FlickingReactiveAPI);
|
|
8798
8992
|
|
|
8799
8993
|
return Flicking;
|
|
8800
8994
|
|