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

Function sync

packages/effect/src/ui/kit/ScrollArea.ts:749–809  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

747 }
748
749 const sync = () => {
750 const nextViewport = find(viewportAttr)
751 if (nextViewport !== viewport) {
752 viewportListening?.abort()
753 viewport = observe(viewport, nextViewport)
754 if (viewport !== null) {
755 viewportListening = new AbortController()
756 const options = {
757 signal: viewportListening.signal,
758 passive: true
759 }
760 viewport.addEventListener("scroll", onViewportScroll, options)
761 for (
762 const name of [
763 "wheel",
764 "pointermove",
765 "pointerenter",
766 "keydown"
767 ]
768 ) {
769 viewport.addEventListener(name, onUserInteraction, options)
770 }
771 }
772 }
773 const nextContent = find(contentAttr)
774 if (nextContent !== content) content = observe(content, nextContent)
775 corner = find(cornerAttr)
776 for (const axis of [y, x]) {
777 const thumb = find(thumbAttr(axis.orientation))
778 const scrollbar = find(scrollbarAttr(axis.orientation))
779 if (
780 drag !== null && drag.axis === axis &&
781 (scrollbar !== axis.scrollbar || thumb !== axis.thumb)
782 ) {
783 clearDrag()
784 }
785 axis.thumb = thumb
786 if (scrollbar === axis.scrollbar) continue
787 axis.listening?.abort()
788 axis.scrollbar = scrollbar
789 if (scrollbar === null) continue
790 axis.listening = new AbortController()
791 const { signal } = axis.listening
792 scrollbar.addEventListener("wheel", onWheel(axis), {
793 signal,
794 passive: false
795 })
796 scrollbar.addEventListener("pointerdown", onPointerDown(axis), {
797 signal
798 })
799 scrollbar.addEventListener("pointermove", onPointerMove, { signal })
800 scrollbar.addEventListener("pointerup", endDrag, { signal })
801 scrollbar.addEventListener("pointercancel", endDrag, { signal })
802 // A native scrollbar doesn't take focus when pressed.
803 scrollbar.addEventListener(
804 "mousedown",
805 (event) => event.preventDefault(),
806 { signal }

Callers 9

measureFunction · 0.70
fiberAwaitFunction · 0.50
fiberAwaitAllFunction · 0.50
fiberJoinFunction · 0.50
fiberJoinAllFunction · 0.50
effect.tsFile · 0.50
LatchClass · 0.50
ClockImplClass · 0.50
sleepMillisMethod · 0.50

Calls 9

thumbAttrFunction · 0.85
scrollbarAttrFunction · 0.85
clearDragFunction · 0.85
findFunction · 0.70
observeFunction · 0.70
onWheelFunction · 0.70
onPointerDownFunction · 0.70
abortMethod · 0.65
addEventListenerMethod · 0.65

Tested by

no test coverage detected