mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2025-01-12 12:25:16 +08:00
refactor(affix): throttle scroll
This commit is contained in:
parent
eeb48edca4
commit
1fb128b821
@ -8,7 +8,7 @@ import {
|
|||||||
PropType,
|
PropType,
|
||||||
h
|
h
|
||||||
} from 'vue'
|
} from 'vue'
|
||||||
import { getScrollParent, unwrapElement } from 'seemly'
|
import { getScrollParent, unwrapElement, beforeNextFrameOnce } from 'seemly'
|
||||||
import { useConfig, useStyle } from '../../_mixins'
|
import { useConfig, useStyle } from '../../_mixins'
|
||||||
import { warn, keysOf } from '../../_utils'
|
import { warn, keysOf } from '../../_utils'
|
||||||
import type { ExtractPublicPropTypes } from '../../_utils'
|
import type { ExtractPublicPropTypes } from '../../_utils'
|
||||||
@ -108,7 +108,11 @@ export default defineComponent({
|
|||||||
handleScroll()
|
handleScroll()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const handleScroll = (): void => {
|
function handleScroll (): void {
|
||||||
|
beforeNextFrameOnce(_handleScroll)
|
||||||
|
}
|
||||||
|
|
||||||
|
function _handleScroll (): void {
|
||||||
const { value: containerEl } = scrollElementRef
|
const { value: containerEl } = scrollElementRef
|
||||||
const { value: selfEl } = selfRef
|
const { value: selfEl } = selfRef
|
||||||
if (!containerEl || !selfEl) return
|
if (!containerEl || !selfEl) return
|
||||||
|
Loading…
Reference in New Issue
Block a user