MCPcopy Create free account
hub / github.com/adobe/react-spectrum / scroll

Function scroll

packages/@react-spectrum/ai/src/AttachmentList.tsx:499–517  ·  view source on GitHub ↗
(dir: 1 | -1)

Source from the content-addressed store, hash-verified

497 let scrollRef = useRef<HTMLDivElement>(null);
498 let {direction} = useLocale();
499 let scroll = (dir: 1 | -1) => {
500 let el = scrollRef.current;
501 if (!el) {
502 return;
503 }
504
505 // RTL flips the scroll direction convention; flip the sign to match.
506 let sign = direction === 'rtl' ? -1 : 1;
507 el.scrollTo({
508 left: Math.max(
509 0,
510 Math.min(
511 el.scrollWidth - el.clientWidth,
512 el.scrollLeft + sign * dir * (el.clientWidth - 64 * 2)
513 )
514 ),
515 behavior: 'smooth'
516 });
517 };
518
519 return (
520 <TagGroup

Callers 1

AttachmentList.tsxFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected