Skip to content

Commit

Permalink
Fix useScroll trigger once onMounted to get correct inital arrivedSta…
Browse files Browse the repository at this point in the history
…tes values
  • Loading branch information
nicooprat committed Sep 8, 2023
1 parent bf1d823 commit 2838f20
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 2838f20

Please sign in to comment.