From 586070afc1c44d646d42971b6eab4bce46f900f2 Mon Sep 17 00:00:00 2001
From: guoyuji <guoyujie@ng.com>
Date: 星期四, 09 五月 2024 16:32:48 +0800
Subject: [PATCH] Merge branch 'master' of http://bore.pub:10439/r/ERP_override
---
north-glass-erp/node_modules/default-passive-events/src/index.js | 46 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 46 insertions(+), 0 deletions(-)
diff --git a/north-glass-erp/node_modules/default-passive-events/src/index.js b/north-glass-erp/node_modules/default-passive-events/src/index.js
new file mode 100644
index 0000000..1c68aac
--- /dev/null
+++ b/north-glass-erp/node_modules/default-passive-events/src/index.js
@@ -0,0 +1,46 @@
+import { eventListenerOptionsSupported } from './utils';
+
+const defaultOptions = {
+ passive: true,
+ capture: false
+};
+const supportedPassiveTypes = [
+ 'scroll', 'wheel',
+ 'touchstart', 'touchmove', 'touchenter', 'touchend', 'touchleave',
+ 'mouseout', 'mouseleave', 'mouseup', 'mousedown', 'mousemove', 'mouseenter', 'mousewheel', 'mouseover'
+];
+const getDefaultPassiveOption = (passive, eventName) => {
+ if (passive !== undefined) return passive;
+
+ return supportedPassiveTypes.indexOf(eventName) === -1 ? false : defaultOptions.passive;
+};
+
+const getWritableOptions = (options) => {
+ const passiveDescriptor = Object.getOwnPropertyDescriptor(options, 'passive');
+
+ return passiveDescriptor && passiveDescriptor.writable !== true && passiveDescriptor.set === undefined
+ ? Object.assign({}, options)
+ : options;
+};
+
+const overwriteAddEvent = (superMethod) => {
+ EventTarget.prototype.addEventListener = function (type, listener, options) {
+ const usesListenerOptions = typeof options === 'object' && options !== null;
+ const useCapture = usesListenerOptions ? options.capture : options;
+
+ options = usesListenerOptions ? getWritableOptions(options) : {};
+ options.passive = getDefaultPassiveOption(options.passive, type);
+ options.capture = useCapture === undefined ? defaultOptions.capture : useCapture;
+
+ superMethod.call(this, type, listener, options);
+ };
+
+ EventTarget.prototype.addEventListener._original = superMethod;
+};
+
+const supportsPassive = eventListenerOptionsSupported();
+
+if (supportsPassive) {
+ const addEvent = EventTarget.prototype.addEventListener;
+ overwriteAddEvent(addEvent);
+}
--
Gitblit v1.8.0