qidian-vue-ui 1.12.13 → 1.12.14
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.
|
@@ -6,6 +6,8 @@ import debounce from "../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodas
|
|
|
6
6
|
function usePerfectScrollbar(target, options) {
|
|
7
7
|
const { watch: watchConfig, onScroll, onScrollY, onScrollX, ...scrollOptions } = options || {};
|
|
8
8
|
const ps = ref();
|
|
9
|
+
const wheelEnabled = scrollOptions.handlers?.includes("wheel") ?? true;
|
|
10
|
+
const shiftKeyDescriptors = /* @__PURE__ */ new WeakMap();
|
|
9
11
|
let unResize;
|
|
10
12
|
let unwatchSource;
|
|
11
13
|
let unwatchCore;
|
|
@@ -17,6 +19,26 @@ function usePerfectScrollbar(target, options) {
|
|
|
17
19
|
if (typeof t === "string") return document.querySelector(t);
|
|
18
20
|
return t;
|
|
19
21
|
});
|
|
22
|
+
function maskShiftWheel(event) {
|
|
23
|
+
if (!event.shiftKey || Math.abs(event.deltaX) <= Math.abs(event.deltaY)) return;
|
|
24
|
+
const descriptor = Object.getOwnPropertyDescriptor(event, "shiftKey");
|
|
25
|
+
try {
|
|
26
|
+
Object.defineProperty(event, "shiftKey", { configurable: true, value: false });
|
|
27
|
+
} catch {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
shiftKeyDescriptors.set(event, descriptor ?? null);
|
|
31
|
+
}
|
|
32
|
+
function restoreShiftWheel(event) {
|
|
33
|
+
const descriptor = shiftKeyDescriptors.get(event);
|
|
34
|
+
if (descriptor === void 0) return;
|
|
35
|
+
try {
|
|
36
|
+
if (descriptor) Object.defineProperty(event, "shiftKey", descriptor);
|
|
37
|
+
else Reflect.deleteProperty(event, "shiftKey");
|
|
38
|
+
} finally {
|
|
39
|
+
shiftKeyDescriptors.delete(event);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
20
42
|
function init() {
|
|
21
43
|
unwatchCore = watch(
|
|
22
44
|
reTarget,
|
|
@@ -35,13 +57,26 @@ function usePerfectScrollbar(target, options) {
|
|
|
35
57
|
if (el === ps.value?.element) return;
|
|
36
58
|
destroyInstance();
|
|
37
59
|
unResize = useResizeObserver(el, debounceUpdate).stop;
|
|
38
|
-
ps.value = new PerfectScrollbar(el, {
|
|
39
|
-
wheelPropagation: true,
|
|
40
|
-
scrollXMarginOffset: 1,
|
|
41
|
-
scrollYMarginOffset: 1,
|
|
42
|
-
...scrollOptions
|
|
43
|
-
});
|
|
44
60
|
listenerController = new AbortController();
|
|
61
|
+
if (wheelEnabled) {
|
|
62
|
+
el.addEventListener("wheel", maskShiftWheel, { signal: listenerController.signal });
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
ps.value = new PerfectScrollbar(el, {
|
|
66
|
+
wheelPropagation: true,
|
|
67
|
+
scrollXMarginOffset: 1,
|
|
68
|
+
scrollYMarginOffset: 1,
|
|
69
|
+
...scrollOptions
|
|
70
|
+
});
|
|
71
|
+
} catch (error) {
|
|
72
|
+
destroyInstance();
|
|
73
|
+
throw error;
|
|
74
|
+
}
|
|
75
|
+
if (wheelEnabled) {
|
|
76
|
+
ps.value.element.addEventListener("wheel", restoreShiftWheel, {
|
|
77
|
+
signal: listenerController.signal
|
|
78
|
+
});
|
|
79
|
+
}
|
|
45
80
|
ps.value.element.addEventListener("scroll", onScroll || noop, {
|
|
46
81
|
signal: listenerController.signal
|
|
47
82
|
});
|