mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-15 18:01:24 +08:00
22 lines
621 B
TypeScript
22 lines
621 B
TypeScript
// @ts-nocheck
|
|
import normalizeWheel from 'normalize-wheel-es'
|
|
import type { DirectiveBinding, ObjectDirective } from 'vue'
|
|
|
|
const mousewheel = function (element, callback) {
|
|
if (element && element.addEventListener) {
|
|
const fn = function (this: any, event) {
|
|
const normalized = normalizeWheel(event)
|
|
callback && Reflect.apply(callback, this, [event, normalized])
|
|
}
|
|
element.addEventListener('wheel', fn, { passive: true })
|
|
}
|
|
}
|
|
|
|
const Mousewheel: ObjectDirective = {
|
|
beforeMount(el: HTMLElement, binding: DirectiveBinding) {
|
|
mousewheel(el, binding.value)
|
|
},
|
|
}
|
|
|
|
export default Mousewheel
|