Skip to content

Commit

Permalink
fix(useScroll): trigger once onMounted to get correct inital arrive…
Browse files Browse the repository at this point in the history
…dStates values (#3384)

Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
  • Loading branch information
nicooprat and antfu committed Nov 9, 2023
1 parent 165c88a commit 86bd8e8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/core/useScroll/index.ts
@@ -1,6 +1,6 @@
import { computed, reactive, ref } from 'vue-demi'
import type { MaybeRefOrGetter } from '@vueuse/shared'
import { noop, toValue, useDebounceFn, useThrottleFn } from '@vueuse/shared'
import { noop, toValue, tryOnMounted, useDebounceFn, useThrottleFn } from '@vueuse/shared'
import { useEventListener } from '../useEventListener'
import type { ConfigurableWindow } from '../_configurable'
import { defaultWindow } from '../_configurable'
Expand Down Expand Up @@ -250,6 +250,10 @@ export function useScroll(
eventListenerOptions,
)

tryOnMounted(() => {
setArrivedState(toValue(element))
})

useEventListener(
element,
'scrollend',
Expand Down

0 comments on commit 86bd8e8

Please sign in to comment.