mirror of
https://github.com/element-plus/element-plus.git
synced 2024-12-27 03:01:14 +08:00
55348b30b6
* style: use prettier * style: just prettier format, no code changes * style: eslint fix object-shorthand, prefer-const * style: fix no-void * style: no-console
23 lines
489 B
TypeScript
23 lines
489 B
TypeScript
import sleep from './sleep'
|
|
|
|
const makeScroll = async (
|
|
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 await sleep()
|
|
}
|
|
|
|
export default makeScroll
|