@egjs/flicking 4.13.2-beta.1 → 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 +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 +199 -10
- package/dist/flicking.cjs.js.map +1 -1
- package/dist/flicking.esm.js +193 -8
- package/dist/flicking.esm.js.map +1 -1
- package/dist/flicking.js +203 -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 -26
- 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/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.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,7 +668,7 @@ 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
|
|
@@ -4110,7 +4111,7 @@ var Camera = /*#__PURE__*/function () {
|
|
|
4110
4111
|
if (prevPosition > panelPos) {
|
|
4111
4112
|
prevPosition -= rangeDiff;
|
|
4112
4113
|
}
|
|
4113
|
-
return nearestPanel.index - 1 + getProgress(position, prevPosition, panelPos);
|
|
4114
|
+
return nearestPanel.index - 1 + getProgress$1(position, prevPosition, panelPos);
|
|
4114
4115
|
} else {
|
|
4115
4116
|
var nextPanel = nearestPanel.next();
|
|
4116
4117
|
var nextPosition = nextPanel ? nextPanel.position + nextPanel.offset : nextRange + bounceSize[1];
|
|
@@ -4118,7 +4119,7 @@ var Camera = /*#__PURE__*/function () {
|
|
|
4118
4119
|
if (nextPosition < panelPos) {
|
|
4119
4120
|
nextPosition += rangeDiff;
|
|
4120
4121
|
}
|
|
4121
|
-
return nearestPanel.index + getProgress(position, panelPos, nextPosition);
|
|
4122
|
+
return nearestPanel.index + getProgress$1(position, panelPos, nextPosition);
|
|
4122
4123
|
}
|
|
4123
4124
|
},
|
|
4124
4125
|
enumerable: false,
|
|
@@ -5461,10 +5462,10 @@ var Panel = /*#__PURE__*/function () {
|
|
|
5461
5462
|
}
|
|
5462
5463
|
if (camPos < position) {
|
|
5463
5464
|
var disappearPosNext = position + (camera.size - camera.alignPosition) + alignPosition;
|
|
5464
|
-
return -getProgress(camPos, position, disappearPosNext);
|
|
5465
|
+
return -getProgress$1(camPos, position, disappearPosNext);
|
|
5465
5466
|
} else {
|
|
5466
5467
|
var disappearPosPrev = position - (camera.alignPosition + this._size - alignPosition);
|
|
5467
|
-
return 1 - getProgress(camPos, disappearPosPrev, position);
|
|
5468
|
+
return 1 - getProgress$1(camPos, disappearPosPrev, position);
|
|
5468
5469
|
}
|
|
5469
5470
|
},
|
|
5470
5471
|
enumerable: false,
|
|
@@ -8098,7 +8099,7 @@ var Flicking = /*#__PURE__*/function (_super) {
|
|
|
8098
8099
|
* Flicking.VERSION; // ex) 4.0.0
|
|
8099
8100
|
* ```
|
|
8100
8101
|
*/
|
|
8101
|
-
Flicking.VERSION = "4.
|
|
8102
|
+
Flicking.VERSION = "4.14.0";
|
|
8102
8103
|
return Flicking;
|
|
8103
8104
|
}(Component);
|
|
8104
8105
|
|
|
@@ -8654,10 +8655,194 @@ var parseAlign = function (alignVal) {
|
|
|
8654
8655
|
}
|
|
8655
8656
|
};
|
|
8656
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
|
+
|
|
8657
8842
|
/*
|
|
8658
8843
|
* Copyright (c) 2015 NAVER Corp.
|
|
8659
8844
|
* egjs projects are licensed under the MIT license
|
|
8660
8845
|
*/
|
|
8661
8846
|
|
|
8662
|
-
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 };
|
|
8663
8848
|
//# sourceMappingURL=flicking.esm.js.map
|