MCPcopy Create free account
hub / github.com/Effect-TS/effect / onWheel

Function onWheel

packages/effect/src/ui/kit/ScrollArea.ts:704–717  ·  view source on GitHub ↗
(axis: Axis)

Source from the content-addressed store, hash-verified

702 }
703
704 const onWheel = (axis: Axis) => (event: WheelEvent) => {
705 if (viewport === null || event.ctrlKey) return
706 const delta = axis.vertical ? event.deltaY : event.deltaX
707 if (delta === 0) return
708 const maxScroll = maxScrollOf(axis, viewport)
709 const rtl = !axis.vertical && isRtl(viewport)
710 const min = rtl ? -maxScroll : 0
711 const max = rtl ? 0 : maxScroll
712 const value = scrollOf(axis, viewport)
713 if ((value <= min && delta < 0) || (value >= max && delta > 0)) return
714 event.preventDefault()
715 setScroll(axis, viewport, clamp(value + delta, min, max))
716 reportScroll()
717 }
718
719 const onUserInteraction = () => {
720 programmaticScroll = false

Callers 1

syncFunction · 0.70

Calls 6

isRtlFunction · 0.90
clampFunction · 0.90
setScrollFunction · 0.85
reportScrollFunction · 0.85
maxScrollOfFunction · 0.70
scrollOfFunction · 0.70

Tested by

no test coverage detected