useWindowScroll ​
Reactive window scroll
Demo ​
See scroll values in the lower right corner of the screen.
Scroll value
x: 0y: 0
Usage ​
js
import { useWindowScroll } from '@vueuse/core'
const { x, y } = useWindowScroll()
console.log(x.value) // read current x scroll value
y.value = 100 // scroll y to 100
Type Declarations ​
typescript
export interface UseWindowScrollOptions
extends ConfigurableWindow,
UseScrollOptions {}
/**
* Reactive window scroll.
*
* @see https://vueuse.org/useWindowScroll
* @param options
*/
export declare function useWindowScroll(options?: UseWindowScrollOptions): {
x: WritableComputedRef<number, number>
y: WritableComputedRef<number, number>
isScrolling: Ref<boolean, boolean>
arrivedState: {
left: boolean
right: boolean
top: boolean
bottom: boolean
}
directions: {
left: boolean
right: boolean
top: boolean
bottom: boolean
}
measure(): void
}
export type UseWindowScrollReturn = ReturnType<typeof useWindowScroll>
Source ​
Contributors ​
Anthony Fu
Nurettin Kaya
Antério Vieira
Robin
Anthony Fu
Chen
Jelf
webfansplz
Maik Kowol
Shinigami
Alex Kozack
Changelog ​
v12.3.0
on 1/2/2025v12.0.0-beta.1
on 11/21/2024v10.6.0
on 11/9/2023v9.13.0
on 2/18/2023v9.7.0
on 12/16/2022