@v-c/virtual-list 1.0.5 → 1.0.6

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.
@@ -1,262 +0,0 @@
1
- Object.defineProperties(exports, {
2
- __esModule: { value: true },
3
- [Symbol.toStringTag]: { value: "Module" }
4
- });
5
- const require_rolldown_runtime = require("./_virtual/rolldown_runtime.cjs");
6
- let vue = require("vue");
7
- let _v_c_util_dist_raf = require("@v-c/util/dist/raf");
8
- _v_c_util_dist_raf = require_rolldown_runtime.__toESM(_v_c_util_dist_raf);
9
- function getPageXY(e, horizontal) {
10
- return ("touches" in e ? e.touches[0] : e)[horizontal ? "pageX" : "pageY"] - window[horizontal ? "scrollX" : "scrollY"];
11
- }
12
- var ScrollBar_default = /* @__PURE__ */ (0, vue.defineComponent)({
13
- props: {
14
- prefixCls: {
15
- type: String,
16
- required: true,
17
- default: void 0
18
- },
19
- scrollOffset: {
20
- type: Number,
21
- required: true,
22
- default: void 0
23
- },
24
- scrollRange: {
25
- type: Number,
26
- required: true,
27
- default: void 0
28
- },
29
- rtl: {
30
- type: Boolean,
31
- required: true,
32
- default: void 0
33
- },
34
- onScroll: {
35
- type: Function,
36
- required: true,
37
- default: void 0
38
- },
39
- onStartMove: {
40
- type: Function,
41
- required: true,
42
- default: void 0
43
- },
44
- onStopMove: {
45
- type: Function,
46
- required: true,
47
- default: void 0
48
- },
49
- horizontal: {
50
- type: Boolean,
51
- required: false,
52
- default: void 0
53
- },
54
- style: {
55
- type: Object,
56
- required: false,
57
- default: void 0
58
- },
59
- thumbStyle: {
60
- type: Object,
61
- required: false,
62
- default: void 0
63
- },
64
- spinSize: {
65
- type: Number,
66
- required: true,
67
- default: void 0
68
- },
69
- containerSize: {
70
- type: Number,
71
- required: true,
72
- default: void 0
73
- },
74
- showScrollBar: {
75
- type: [Boolean, String],
76
- required: false,
77
- default: void 0
78
- }
79
- },
80
- name: "ScrollBar",
81
- setup(props, { expose }) {
82
- const dragging = (0, vue.ref)(false);
83
- const pageXY = (0, vue.ref)(null);
84
- const startTop = (0, vue.ref)(null);
85
- const isLTR = (0, vue.computed)(() => !props.rtl);
86
- const scrollbarRef = (0, vue.shallowRef)();
87
- const thumbRef = (0, vue.shallowRef)();
88
- const visible = (0, vue.ref)(props.showScrollBar === "optional" ? true : props.showScrollBar);
89
- let visibleTimeout = null;
90
- const delayHidden = () => {
91
- if (props.showScrollBar === true || props.showScrollBar === false) return;
92
- if (visibleTimeout) clearTimeout(visibleTimeout);
93
- visible.value = true;
94
- visibleTimeout = setTimeout(() => {
95
- visible.value = false;
96
- }, 3e3);
97
- };
98
- const enableScrollRange = (0, vue.computed)(() => props.scrollRange - props.containerSize || 0);
99
- const enableOffsetRange = (0, vue.computed)(() => props.containerSize - props.spinSize || 0);
100
- const top = (0, vue.computed)(() => {
101
- if (props.scrollOffset === 0 || enableScrollRange.value === 0) return 0;
102
- return props.scrollOffset / enableScrollRange.value * enableOffsetRange.value;
103
- });
104
- const stateRef = (0, vue.shallowRef)({
105
- top: top.value,
106
- dragging: dragging.value,
107
- pageY: pageXY.value,
108
- startTop: startTop.value
109
- });
110
- (0, vue.watch)([
111
- top,
112
- dragging,
113
- pageXY,
114
- startTop
115
- ], () => {
116
- stateRef.value = {
117
- top: top.value,
118
- dragging: dragging.value,
119
- pageY: pageXY.value,
120
- startTop: startTop.value
121
- };
122
- });
123
- const onContainerMouseDown = (e) => {
124
- e.stopPropagation();
125
- e.preventDefault();
126
- };
127
- const onThumbMouseDown = (e) => {
128
- dragging.value = true;
129
- pageXY.value = getPageXY(e, props.horizontal || false);
130
- startTop.value = stateRef.value.top;
131
- props?.onStartMove?.();
132
- e.stopPropagation();
133
- e.preventDefault();
134
- };
135
- (0, vue.onMounted)(() => {
136
- const onScrollbarTouchStart = (e) => {
137
- e.preventDefault();
138
- };
139
- const scrollbarEle = scrollbarRef.value;
140
- const thumbEle = thumbRef.value;
141
- if (scrollbarEle && thumbEle) {
142
- scrollbarEle.addEventListener("touchstart", onScrollbarTouchStart, { passive: false });
143
- thumbEle.addEventListener("touchstart", onThumbMouseDown, { passive: false });
144
- (0, vue.onUnmounted)(() => {
145
- scrollbarEle.removeEventListener("touchstart", onScrollbarTouchStart);
146
- thumbEle.removeEventListener("touchstart", onThumbMouseDown);
147
- });
148
- }
149
- });
150
- (0, vue.watch)(dragging, (isDragging, _O, onCleanup) => {
151
- if (isDragging) {
152
- let moveRafId = null;
153
- const onMouseMove = (e) => {
154
- const { dragging: stateDragging, pageY: statePageY, startTop: stateStartTop } = stateRef.value;
155
- _v_c_util_dist_raf.default.cancel(moveRafId);
156
- const rect = scrollbarRef.value.getBoundingClientRect();
157
- const scale = props.containerSize / (props.horizontal ? rect.width : rect.height);
158
- if (stateDragging) {
159
- const offset = (getPageXY(e, props.horizontal || false) - (statePageY || 0)) * scale;
160
- let newTop = stateStartTop || 0;
161
- if (!isLTR.value && props.horizontal) newTop -= offset;
162
- else newTop += offset;
163
- const tmpEnableScrollRange = enableScrollRange.value;
164
- const tmpEnableOffsetRange = enableOffsetRange.value;
165
- const ptg = tmpEnableOffsetRange ? newTop / tmpEnableOffsetRange : 0;
166
- let newScrollTop = Math.ceil(ptg * tmpEnableScrollRange);
167
- newScrollTop = Math.max(newScrollTop, 0);
168
- newScrollTop = Math.min(newScrollTop, tmpEnableScrollRange);
169
- moveRafId = (0, _v_c_util_dist_raf.default)(() => {
170
- props?.onScroll?.(newScrollTop, props.horizontal);
171
- });
172
- }
173
- };
174
- const onMouseUp = () => {
175
- dragging.value = false;
176
- props.onStopMove();
177
- };
178
- window.addEventListener("mousemove", onMouseMove, { passive: true });
179
- window.addEventListener("touchmove", onMouseMove, { passive: true });
180
- window.addEventListener("mouseup", onMouseUp, { passive: true });
181
- window.addEventListener("touchend", onMouseUp, { passive: true });
182
- onCleanup(() => {
183
- window.removeEventListener("mousemove", onMouseMove);
184
- window.removeEventListener("touchmove", onMouseMove);
185
- window.removeEventListener("mouseup", onMouseUp);
186
- window.removeEventListener("touchend", onMouseUp);
187
- _v_c_util_dist_raf.default.cancel(moveRafId);
188
- });
189
- }
190
- });
191
- (0, vue.watch)(() => props.scrollOffset, (_n, _o, onCleanup) => {
192
- delayHidden();
193
- onCleanup(() => {
194
- if (visibleTimeout) clearTimeout(visibleTimeout);
195
- });
196
- });
197
- expose({ delayHidden });
198
- return () => {
199
- const { prefixCls, horizontal } = props;
200
- const scrollbarPrefixCls = `${prefixCls}-scrollbar`;
201
- const containerStyle = {
202
- position: "absolute",
203
- visibility: visible.value ? void 0 : "hidden"
204
- };
205
- const thumbStyle = {
206
- position: "absolute",
207
- borderRadius: "99px",
208
- background: "var(--vc-virtual-list-scrollbar-bg, rgba(0, 0, 0, 0.5))",
209
- cursor: "pointer",
210
- userSelect: "none"
211
- };
212
- if (props.horizontal) {
213
- Object.assign(containerStyle, {
214
- height: "8px",
215
- left: 0,
216
- right: 0,
217
- bottom: 0
218
- });
219
- Object.assign(thumbStyle, {
220
- height: "100%",
221
- width: `${props.spinSize}px`,
222
- [isLTR.value ? "left" : "right"]: `${top.value}px`
223
- });
224
- } else {
225
- Object.assign(containerStyle, {
226
- width: "8px",
227
- top: 0,
228
- bottom: 0,
229
- [isLTR.value ? "right" : "left"]: 0
230
- });
231
- Object.assign(thumbStyle, {
232
- width: "100%",
233
- height: `${props.spinSize}px`,
234
- top: `${top.value}px`
235
- });
236
- }
237
- return (0, vue.createVNode)("div", {
238
- "ref": scrollbarRef,
239
- "class": [scrollbarPrefixCls, {
240
- [`${scrollbarPrefixCls}-horizontal`]: horizontal,
241
- [`${scrollbarPrefixCls}-vertical`]: !horizontal,
242
- [`${scrollbarPrefixCls}-visible`]: visible.value
243
- }],
244
- "style": {
245
- ...containerStyle,
246
- ...props.style
247
- },
248
- "onMousedown": onContainerMouseDown,
249
- "onMousemove": delayHidden
250
- }, [(0, vue.createVNode)("div", {
251
- "ref": thumbRef,
252
- "class": [`${scrollbarPrefixCls}-thumb`, { [`${scrollbarPrefixCls}-thumb-moving`]: dragging.value }],
253
- "style": {
254
- ...thumbStyle,
255
- ...props.thumbStyle
256
- },
257
- "onMousedown": onThumbMouseDown
258
- }, null)]);
259
- };
260
- }
261
- });
262
- exports.default = ScrollBar_default;
@@ -1,21 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __copyProps = (to, from, except, desc) => {
8
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
9
- key = keys[i];
10
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
11
- get: ((k) => from[k]).bind(null, key),
12
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
13
- });
14
- }
15
- return to;
16
- };
17
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
18
- value: mod,
19
- enumerable: true
20
- }) : target, mod));
21
- exports.__toESM = __toESM;
@@ -1,26 +0,0 @@
1
- Object.defineProperties(exports, {
2
- __esModule: { value: true },
3
- [Symbol.toStringTag]: { value: "Module" }
4
- });
5
- const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
6
- const require_Item = require("../Item.cjs");
7
- let vue = require("vue");
8
- function _isSlot(s) {
9
- return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !(0, vue.isVNode)(s);
10
- }
11
- function useChildren(list, startIndex, endIndex, scrollWidth, offsetX, setNodeRef, renderFunc, { getKey }) {
12
- return (0, vue.computed)(() => {
13
- return list.value.slice(startIndex.value, endIndex.value + 1).map((item, index) => {
14
- const node = renderFunc(item, startIndex.value + index, {
15
- style: { width: `${scrollWidth.value}px` },
16
- offsetX: offsetX.value
17
- });
18
- const key = getKey(item);
19
- return (0, vue.createVNode)(require_Item.default, {
20
- "key": key,
21
- "setRef": (ele) => setNodeRef(item, ele)
22
- }, _isSlot(node) ? node : { default: () => [node] });
23
- });
24
- });
25
- }
26
- exports.default = useChildren;
@@ -1,21 +0,0 @@
1
- Object.defineProperties(exports, {
2
- __esModule: { value: true },
3
- [Symbol.toStringTag]: { value: "Module" }
4
- });
5
- const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
6
- const require_algorithmUtil = require("../utils/algorithmUtil.cjs");
7
- let vue = require("vue");
8
- function useDiffItem(data, getKey, onDiff) {
9
- const prevData = (0, vue.shallowRef)(data.value);
10
- const diffItem = (0, vue.shallowRef)();
11
- (0, vue.watch)(data, (newData) => {
12
- const diff = require_algorithmUtil.findListDiffIndex(prevData.value || [], data.value || [], getKey);
13
- if (diff?.index !== void 0) {
14
- onDiff?.(diff.index);
15
- diffItem.value = newData[diff.index];
16
- }
17
- prevData.value = newData;
18
- }, { immediate: true });
19
- return diffItem;
20
- }
21
- exports.default = useDiffItem;
@@ -1,66 +0,0 @@
1
- Object.defineProperties(exports, {
2
- __esModule: { value: true },
3
- [Symbol.toStringTag]: { value: "Module" }
4
- });
5
- const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
6
- const require_isFirefox = require("../utils/isFirefox.cjs");
7
- const require_useOriginScroll = require("./useOriginScroll.cjs");
8
- let vue = require("vue");
9
- function useFrameWheel(inVirtual, isScrollAtTop, isScrollAtBottom, isScrollAtLeft, isScrollAtRight, horizontalScroll, onWheelDelta) {
10
- const offsetRef = (0, vue.ref)(0);
11
- let nextFrame = null;
12
- const wheelValueRef = (0, vue.ref)(null);
13
- const isMouseScrollRef = (0, vue.ref)(false);
14
- const originScroll = require_useOriginScroll.default(isScrollAtTop, isScrollAtBottom, isScrollAtLeft, isScrollAtRight);
15
- function onWheelY(e, deltaY) {
16
- if (nextFrame) cancelAnimationFrame(nextFrame);
17
- if (originScroll(false, deltaY)) return;
18
- const event = e;
19
- if (!event._virtualHandled) event._virtualHandled = true;
20
- else return;
21
- offsetRef.value += deltaY;
22
- wheelValueRef.value = deltaY;
23
- if (!require_isFirefox.default) event.preventDefault();
24
- nextFrame = requestAnimationFrame(() => {
25
- const patchMultiple = isMouseScrollRef.value ? 10 : 1;
26
- onWheelDelta(offsetRef.value * patchMultiple, false);
27
- offsetRef.value = 0;
28
- });
29
- }
30
- function onWheelX(event, deltaX) {
31
- onWheelDelta(deltaX, true);
32
- if (!require_isFirefox.default) event.preventDefault();
33
- }
34
- const wheelDirectionRef = (0, vue.ref)(null);
35
- let wheelDirectionClean = null;
36
- function onWheel(event) {
37
- if (!inVirtual.value) return;
38
- if (wheelDirectionClean) cancelAnimationFrame(wheelDirectionClean);
39
- wheelDirectionClean = requestAnimationFrame(() => {
40
- wheelDirectionRef.value = null;
41
- });
42
- const { deltaX, deltaY, shiftKey } = event;
43
- let mergedDeltaX = deltaX;
44
- let mergedDeltaY = deltaY;
45
- if (wheelDirectionRef.value === "sx" || !wheelDirectionRef.value && (shiftKey || false) && deltaY && !deltaX) {
46
- mergedDeltaX = deltaY;
47
- mergedDeltaY = 0;
48
- wheelDirectionRef.value = "sx";
49
- }
50
- const absX = Math.abs(mergedDeltaX);
51
- const absY = Math.abs(mergedDeltaY);
52
- if (wheelDirectionRef.value === null) wheelDirectionRef.value = horizontalScroll && absX > absY ? "x" : "y";
53
- if (wheelDirectionRef.value === "y") onWheelY(event, mergedDeltaY);
54
- else onWheelX(event, mergedDeltaX);
55
- }
56
- function onFireFoxScroll(event) {
57
- if (!inVirtual.value) return;
58
- isMouseScrollRef.value = event.detail === wheelValueRef.value;
59
- }
60
- (0, vue.onUnmounted)(() => {
61
- if (nextFrame) cancelAnimationFrame(nextFrame);
62
- if (wheelDirectionClean) cancelAnimationFrame(wheelDirectionClean);
63
- });
64
- return [onWheel, onFireFoxScroll];
65
- }
66
- exports.default = useFrameWheel;
@@ -1,38 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
3
- let vue = require("vue");
4
- function useGetSize(mergedData, getKey, heights, itemHeight) {
5
- let key2Index = /* @__PURE__ */ new Map();
6
- let bottomList = [];
7
- (0, vue.watch)([
8
- mergedData,
9
- () => heights.id.value,
10
- itemHeight
11
- ], () => {
12
- key2Index = /* @__PURE__ */ new Map();
13
- bottomList = [];
14
- });
15
- const getSize = (startKey, endKey = startKey) => {
16
- let startIndex = key2Index.get(startKey);
17
- let endIndex = key2Index.get(endKey);
18
- if (startIndex === void 0 || endIndex === void 0) {
19
- const dataLen = mergedData.value.length;
20
- for (let i = bottomList.length; i < dataLen; i += 1) {
21
- const item = mergedData.value[i];
22
- const key = getKey(item);
23
- key2Index.set(key, i);
24
- const cacheHeight = heights.get(key) ?? itemHeight.value;
25
- bottomList[i] = (bottomList[i - 1] || 0) + cacheHeight;
26
- if (key === startKey) startIndex = i;
27
- if (key === endKey) endIndex = i;
28
- if (startIndex !== void 0 && endIndex !== void 0) break;
29
- }
30
- }
31
- return {
32
- top: bottomList[startIndex - 1] || 0,
33
- bottom: bottomList[endIndex]
34
- };
35
- };
36
- return getSize;
37
- }
38
- exports.useGetSize = useGetSize;
@@ -1,87 +0,0 @@
1
- Object.defineProperties(exports, {
2
- __esModule: { value: true },
3
- [Symbol.toStringTag]: { value: "Module" }
4
- });
5
- const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
6
- const require_CacheMap = require("../utils/CacheMap.cjs");
7
- let vue = require("vue");
8
- let _v_c_util_dist_Dom_findDOMNode = require("@v-c/util/dist/Dom/findDOMNode");
9
- function parseNumber(value) {
10
- const num = parseFloat(value);
11
- return isNaN(num) ? 0 : num;
12
- }
13
- function useHeights(getKey, onItemAdd, onItemRemove) {
14
- const updatedMark = (0, vue.ref)(0);
15
- const instanceRef = (0, vue.ref)(/* @__PURE__ */ new Map());
16
- const heightsRef = (0, vue.markRaw)(new require_CacheMap.default());
17
- const promiseIdRef = (0, vue.ref)(0);
18
- const observedElements = /* @__PURE__ */ new Map();
19
- const resizeObserver = typeof window !== "undefined" && "ResizeObserver" in window ? new window.ResizeObserver(() => {
20
- collectHeight();
21
- }) : null;
22
- function cancelRaf() {
23
- promiseIdRef.value += 1;
24
- }
25
- function collectHeight(sync = false) {
26
- cancelRaf();
27
- const doCollect = () => {
28
- let changed = false;
29
- instanceRef.value.forEach((element, key) => {
30
- element = (0, _v_c_util_dist_Dom_findDOMNode.getDOM)(element);
31
- if (element && element.offsetParent) {
32
- const { offsetHeight } = element;
33
- const { marginTop, marginBottom } = getComputedStyle(element);
34
- const marginTopNum = parseNumber(marginTop);
35
- const marginBottomNum = parseNumber(marginBottom);
36
- const totalHeight = offsetHeight + marginTopNum + marginBottomNum;
37
- if (heightsRef.get(key) !== totalHeight) {
38
- heightsRef.set(key, totalHeight);
39
- changed = true;
40
- }
41
- }
42
- });
43
- if (changed) updatedMark.value += 1;
44
- };
45
- if (sync) doCollect();
46
- else {
47
- promiseIdRef.value += 1;
48
- const id = promiseIdRef.value;
49
- Promise.resolve().then(() => {
50
- if (id === promiseIdRef.value) doCollect();
51
- });
52
- }
53
- }
54
- function setInstanceRef(item, instance) {
55
- const key = getKey(item);
56
- const origin = instanceRef.value.get(key);
57
- if (origin === instance) return;
58
- const prevObserved = observedElements.get(key);
59
- if (prevObserved && resizeObserver) {
60
- resizeObserver.unobserve(prevObserved);
61
- observedElements.delete(key);
62
- }
63
- if (instance) {
64
- instanceRef.value.set(key, instance);
65
- collectHeight();
66
- const element = (0, _v_c_util_dist_Dom_findDOMNode.getDOM)(instance);
67
- if (element && element.nodeType === 1 && resizeObserver) {
68
- resizeObserver.observe(element);
69
- observedElements.set(key, element);
70
- }
71
- } else instanceRef.value.delete(key);
72
- if (!origin !== !instance) if (instance) onItemAdd?.(item);
73
- else onItemRemove?.(item);
74
- }
75
- (0, vue.onUnmounted)(() => {
76
- cancelRaf();
77
- resizeObserver?.disconnect?.();
78
- observedElements.clear();
79
- });
80
- return [
81
- setInstanceRef,
82
- collectHeight,
83
- heightsRef,
84
- updatedMark
85
- ];
86
- }
87
- exports.default = useHeights;
@@ -1,85 +0,0 @@
1
- Object.defineProperties(exports, {
2
- __esModule: { value: true },
3
- [Symbol.toStringTag]: { value: "Module" }
4
- });
5
- const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
6
- let vue = require("vue");
7
- var SMOOTH_PTG = 14 / 15;
8
- function useMobileTouchMove(inVirtual, listRef, callback) {
9
- const touchedRef = (0, vue.ref)(false);
10
- const touchXRef = (0, vue.ref)(0);
11
- const touchYRef = (0, vue.ref)(0);
12
- let elementRef = null;
13
- let touchStartElement = null;
14
- let intervalId = null;
15
- let cleanUpEvents;
16
- const onTouchMove = (e) => {
17
- if (touchedRef.value) {
18
- const currentX = Math.ceil(e.touches[0].pageX);
19
- const currentY = Math.ceil(e.touches[0].pageY);
20
- let offsetX = touchXRef.value - currentX;
21
- let offsetY = touchYRef.value - currentY;
22
- const isHorizontal = Math.abs(offsetX) > Math.abs(offsetY);
23
- if (isHorizontal) touchXRef.value = currentX;
24
- else touchYRef.value = currentY;
25
- const scrollHandled = callback(isHorizontal, isHorizontal ? offsetX : offsetY, false, e);
26
- if (scrollHandled) e.preventDefault();
27
- if (intervalId) clearInterval(intervalId);
28
- if (scrollHandled) intervalId = setInterval(() => {
29
- if (isHorizontal) offsetX *= SMOOTH_PTG;
30
- else offsetY *= SMOOTH_PTG;
31
- const offset = Math.floor(isHorizontal ? offsetX : offsetY);
32
- if (!callback(isHorizontal, offset, true) || Math.abs(offset) <= .1) {
33
- if (intervalId) clearInterval(intervalId);
34
- }
35
- }, 16);
36
- }
37
- };
38
- const onTouchEnd = () => {
39
- touchedRef.value = false;
40
- cleanUpEvents();
41
- };
42
- const onTouchStart = (e) => {
43
- cleanUpEvents();
44
- if (e.touches.length === 1 && !touchedRef.value) {
45
- touchedRef.value = true;
46
- touchXRef.value = Math.ceil(e.touches[0].pageX);
47
- touchYRef.value = Math.ceil(e.touches[0].pageY);
48
- elementRef = e.target;
49
- elementRef.addEventListener("touchmove", onTouchMove, { passive: false });
50
- elementRef.addEventListener("touchend", onTouchEnd, { passive: true });
51
- }
52
- };
53
- cleanUpEvents = () => {
54
- if (elementRef) {
55
- elementRef.removeEventListener("touchmove", onTouchMove);
56
- elementRef.removeEventListener("touchend", onTouchEnd);
57
- elementRef = null;
58
- }
59
- };
60
- const removeTouchStartListener = () => {
61
- if (touchStartElement) {
62
- touchStartElement.removeEventListener("touchstart", onTouchStart);
63
- touchStartElement = null;
64
- }
65
- };
66
- const teardown = () => {
67
- removeTouchStartListener();
68
- cleanUpEvents();
69
- if (intervalId) {
70
- clearInterval(intervalId);
71
- intervalId = null;
72
- }
73
- };
74
- (0, vue.onUnmounted)(teardown);
75
- (0, vue.watch)([inVirtual, listRef], ([enabled, ele], _prev, onCleanup) => {
76
- if (enabled && ele) {
77
- touchStartElement = ele;
78
- ele.addEventListener("touchstart", onTouchStart, { passive: true });
79
- onCleanup(() => {
80
- teardown();
81
- });
82
- } else teardown();
83
- }, { immediate: true });
84
- }
85
- exports.default = useMobileTouchMove;
@@ -1,26 +0,0 @@
1
- Object.defineProperties(exports, {
2
- __esModule: { value: true },
3
- [Symbol.toStringTag]: { value: "Module" }
4
- });
5
- const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
6
- let vue = require("vue");
7
- function useOriginScroll(isScrollAtTop, isScrollAtBottom, isScrollAtLeft, isScrollAtRight) {
8
- const lockRef = (0, vue.ref)(false);
9
- let lockTimeout = null;
10
- function lockScroll() {
11
- if (lockTimeout) clearTimeout(lockTimeout);
12
- lockRef.value = true;
13
- lockTimeout = setTimeout(() => {
14
- lockRef.value = false;
15
- }, 50);
16
- }
17
- return (isHorizontal, delta, smoothOffset = false) => {
18
- const originScroll = isHorizontal ? delta < 0 && isScrollAtLeft.value || delta > 0 && isScrollAtRight.value : delta < 0 && isScrollAtTop.value || delta > 0 && isScrollAtBottom.value;
19
- if (smoothOffset && originScroll) {
20
- if (lockTimeout) clearTimeout(lockTimeout);
21
- lockRef.value = false;
22
- } else if (!originScroll || lockRef.value) lockScroll();
23
- return !lockRef.value && originScroll;
24
- };
25
- }
26
- exports.default = useOriginScroll;