@mptw/skylens-ui 1.4.88 → 1.4.89
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/components/SLContextMenu.vue +38 -13
- package/package.json +1 -1
|
@@ -22,6 +22,18 @@ import { fromEvent, Subscription } from 'rxjs';
|
|
|
22
22
|
import type IDateRange from '~/interface/IDateRange';
|
|
23
23
|
|
|
24
24
|
const WatermarkImage = '/assets/images/commons/watermark-2.svg';
|
|
25
|
+
const keys = { 37: 1, 38: 1, 30: 1, 40: 1 };
|
|
26
|
+
|
|
27
|
+
function preventDefault(e: Event) {
|
|
28
|
+
e.preventDefault();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function preventDefaultForScrollKeys(e: Event) {
|
|
32
|
+
if (keys[e.keyCode]) {
|
|
33
|
+
preventDefault(e);
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
25
37
|
|
|
26
38
|
export default defineComponent({
|
|
27
39
|
name: 'SLContextMenu',
|
|
@@ -57,6 +69,17 @@ export default defineComponent({
|
|
|
57
69
|
},
|
|
58
70
|
emits: ['action'],
|
|
59
71
|
setup(props, { emit }) {
|
|
72
|
+
let supportsPassive = false;
|
|
73
|
+
|
|
74
|
+
try {
|
|
75
|
+
window.addEventListener("test", null, Object.defineProperty({}, 'passive', {
|
|
76
|
+
get: function () { supportsPassive = true; }
|
|
77
|
+
}));
|
|
78
|
+
} catch (e) { }
|
|
79
|
+
|
|
80
|
+
const wheelOpt = supportsPassive ? { passive: false } : false;
|
|
81
|
+
const wheelEvent = 'onwheel' in document.createElement('div') ? 'wheel' : 'mousewheel';
|
|
82
|
+
|
|
60
83
|
const { target, filename, dateRanges, padding, watermark, customFilter, customStyle } = toRefs(props);
|
|
61
84
|
|
|
62
85
|
const el = shallowRef<HTMLDivElement | null>(null);
|
|
@@ -149,26 +172,25 @@ export default defineComponent({
|
|
|
149
172
|
}, 300);
|
|
150
173
|
}
|
|
151
174
|
|
|
152
|
-
function
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}
|
|
175
|
+
function subscribeScrollEvents() {
|
|
176
|
+
window.addEventListener('DOMMouseScroll', preventDefault, false); // older FF
|
|
177
|
+
window.addEventListener(wheelEvent, preventDefault, wheelOpt); // modern desktop
|
|
178
|
+
window.addEventListener('touchmove', preventDefault, wheelOpt); // mobile
|
|
179
|
+
window.addEventListener('keydown', preventDefaultForScrollKeys, false);
|
|
158
180
|
}
|
|
159
181
|
|
|
160
|
-
function
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
182
|
+
function unsubscribeScrollEvents() {
|
|
183
|
+
window.removeEventListener('DOMMouseScroll', preventDefault, false);
|
|
184
|
+
window.removeEventListener(wheelEvent, preventDefault, wheelOpt);
|
|
185
|
+
window.removeEventListener('touchmove', preventDefault, wheelOpt);
|
|
186
|
+
window.removeEventListener('keydown', preventDefaultForScrollKeys, false);
|
|
165
187
|
}
|
|
166
188
|
|
|
167
189
|
watch(isShow, () => {
|
|
168
190
|
if (isShow.value) {
|
|
169
|
-
|
|
191
|
+
subscribeScrollEvents();
|
|
170
192
|
} else {
|
|
171
|
-
|
|
193
|
+
unsubscribeScrollEvents();
|
|
172
194
|
}
|
|
173
195
|
});
|
|
174
196
|
|
|
@@ -211,6 +233,9 @@ export default defineComponent({
|
|
|
211
233
|
</script>
|
|
212
234
|
|
|
213
235
|
<style lang="stylus" scoped>
|
|
236
|
+
.sl-context-menu-wrapper
|
|
237
|
+
@apply hidden
|
|
238
|
+
|
|
214
239
|
.sl-context-menu-container
|
|
215
240
|
@apply fixed top-0 left-0 w-full h-full
|
|
216
241
|
|