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

Function onPointerDown

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

Source from the content-addressed store, hash-verified

661 }
662
663 const onPointerDown = (axis: Axis) => (event: PointerEvent) => {
664 if (event.button !== 0) return
665 if (axis.thumb?.contains(event.target as Node | null) !== true) {
666 const track = trackOf(axis)
667 if (track === null || track.maxThumbOffset <= 0) return
668 const rect = track.scrollbar.getBoundingClientRect()
669 const at = along(axis, event) -
670 (axis.vertical ? rect.top : rect.left) - track.thumbSize / 2 -
671 track.scrollbarOffset + track.thumbOffset / 2
672 const ratio = at / track.maxThumbOffset
673 disableViewportSnap()
674 setScroll(
675 axis,
676 track.viewport,
677 !axis.vertical && isRtl(track.viewport)
678 ? -(1 - ratio) * track.maxScroll
679 : ratio * track.maxScroll
680 )
681 reportScroll()
682 }
683 startDrag(axis, event)
684 }
685
686 const onPointerMove = (event: PointerEvent) => {
687 if (drag === null || event.pointerId !== drag.pointerId) return

Callers 1

syncFunction · 0.70

Calls 8

isRtlFunction · 0.90
trackOfFunction · 0.85
disableViewportSnapFunction · 0.85
setScrollFunction · 0.85
reportScrollFunction · 0.85
getBoundingClientRectMethod · 0.80
alongFunction · 0.70
startDragFunction · 0.70

Tested by

no test coverage detected