refactor(directives): use util method replace judge firefox (#4086)

This commit is contained in:
btea 2021-10-29 22:31:00 -05:00 committed by GitHub
parent 4b1975ebc9
commit 36b1f19b78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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