mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-02 03:08:21 +08:00
b8c38a9fe5
* chore: enhance eslint rules * chore: enhance eslint rules
23 lines
477 B
TypeScript
23 lines
477 B
TypeScript
import sleep from './sleep'
|
|
|
|
const makeScroll = (
|
|
dom: Element,
|
|
name: 'scrollTop' | 'scrollLeft',
|
|
offset: number
|
|
) => {
|
|
const eventTarget = dom === document.documentElement ? window : dom
|
|
dom[name] = offset
|
|
const evt = new CustomEvent('scroll', {
|
|
detail: {
|
|
target: {
|
|
[name]: offset,
|
|
},
|
|
},
|
|
})
|
|
eventTarget.dispatchEvent(evt)
|
|
// must use setTimeout instead of nextTick to wait dom change
|
|
return sleep()
|
|
}
|
|
|
|
export default makeScroll
|