Skip to main content

Scroll event

Scroll values

PropertydefaultDescription
deviceType of device
activefalseWhether drag is active.
_activefalseWhether drag is active.
value[0, 0]Current position
_value[0, 0]Previous position
delta[0, 0]Delta of position
offset[0, 0]Offset of position
movement[0, 0]Movement of position
targetnullTarget element

Scroll events

Event nameArgumentDescription
onScrollScrollStateCalled on all scroll events. Mainly events specified
onScrollStartEventCalled only once when the scroll starts
onScrollingEventCalled every time the scroll is moved
onScrollEndEventCalled only once when the scroll ends
onMountElementCalled when the component is mounted
onCleannullCalled when the component is removed

Scroll state

export type Vec2 = [x: number, y: number]

export interface ScrollState<El extends Element = Element> {
_active: boolean
active: boolean
_value: Vec2
value: Vec2
delta: Vec2
offset: Vec2
movement: Vec2
target: El
event: Event
memo: any
isScrollStart: boolean
isScrolling: boolean
isScrollEnd: boolean
onScroll(self: ScrollState<El>): void
onScrollStart(e: Event): void
onScrolling(e: Event): void
onScrollEnd(e: Event): void
onMount(target: Element): void
onClean(target: null): void
ref(traget: Element): void
tick?: () => void
}