mirror of
https://github.com/element-plus/element-plus.git
synced 2024-11-21 01:02:59 +08:00
fix(directives): use standard wheel event with passive option (#7256)
Both DOMMouseScroll and mousewheel event are non-standard now. And "[Violation]" warning will be printed in console without setting `passive: true`. fix #7016 #2016
This commit is contained in:
parent
6f8d8326c3
commit
9b399385e0
@ -1,5 +1,4 @@
|
||||
import normalizeWheel from 'normalize-wheel-es'
|
||||
import { isFirefox } from '@element-plus/utils'
|
||||
import type { DirectiveBinding, ObjectDirective } from 'vue'
|
||||
|
||||
const mousewheel = function (element, callback) {
|
||||
@ -8,11 +7,7 @@ const mousewheel = function (element, callback) {
|
||||
const normalized = normalizeWheel(event)
|
||||
callback && Reflect.apply(callback, this, [event, normalized])
|
||||
}
|
||||
if (isFirefox()) {
|
||||
element.addEventListener('DOMMouseScroll', fn)
|
||||
} else {
|
||||
element.onmousewheel = fn
|
||||
}
|
||||
element.addEventListener('wheel', fn, { passive: true })
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user