From 36b1f19b78c450285080d741c55c9aba9c1d2bb3 Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Fri, 29 Oct 2021 22:31:00 -0500 Subject: [PATCH] refactor(directives): use util method replace judge firefox (#4086) --- packages/directives/mousewheel/index.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/packages/directives/mousewheel/index.ts b/packages/directives/mousewheel/index.ts index 1c69c1906e..ef2ce55aad 100644 --- a/packages/directives/mousewheel/index.ts +++ b/packages/directives/mousewheel/index.ts @@ -1,18 +1,14 @@ import normalizeWheel from 'normalize-wheel-es' - +import { isFirefox } from '@element-plus/utils/util' import type { ObjectDirective, DirectiveBinding } from 'vue' -const isFirefox = - typeof navigator !== 'undefined' && - navigator.userAgent.toLowerCase().indexOf('firefox') > -1 - const mousewheel = function (element, callback) { if (element && element.addEventListener) { - const fn = function (event) { + const fn = function (this: any, event) { const normalized = normalizeWheel(event) callback && callback.apply(this, [event, normalized]) } - if (isFirefox) { + if (isFirefox()) { element.addEventListener('DOMMouseScroll', fn) } else { element.onmousewheel = fn