Skip to content

Commit 07c4698

Browse files
authored
Merge pull request #37 from atomiks/patch-3
2 parents dc86db7 + d782c0c commit 07c4698

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

src/components/Landing.js

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -512,10 +512,19 @@ createPopper(popcorn, tooltip, {
512512
};
513513

514514
const PreventOverflowExample = () => {
515+
const [boundary, setBoundary] = useState();
515516
const scrollContainerRef = useRef();
516517

517518
const { reference, popper } = usePopper({
518519
placement: 'right',
520+
modifiers: [
521+
{
522+
name: 'preventOverflow',
523+
options: {
524+
boundary,
525+
},
526+
},
527+
],
519528
});
520529

521530
useLayoutEffect(() => {
@@ -536,15 +545,23 @@ createPopper(popcorn, tooltip, {
536545

537546
return (
538547
<ExampleBox>
539-
<ScrollContainer ref={scrollContainerRef}>
540-
<PopcornBox
541-
ref={reference}
542-
src={popcornBox}
543-
css={css`
544-
position: absolute;
545-
left: 100px;
546-
`}
547-
/>
548+
<div
549+
css={css`
550+
position: relative;
551+
overflow: hidden;
552+
`}
553+
ref={setBoundary}
554+
>
555+
<ScrollContainer ref={scrollContainerRef}>
556+
<PopcornBox
557+
ref={reference}
558+
src={popcornBox}
559+
css={css`
560+
position: absolute;
561+
left: 100px;
562+
`}
563+
/>
564+
</ScrollContainer>
548565
<Tooltip ref={popper}>
549566
<TooltipName>Popcorn</TooltipName>
550567
<TooltipName>sizes</TooltipName>
@@ -560,7 +577,7 @@ createPopper(popcorn, tooltip, {
560577

561578
<Arrow data-popper-arrow />
562579
</Tooltip>
563-
</ScrollContainer>
580+
</div>
564581
<ExampleText>
565582
<Heading>
566583
<Crop /> Overflow prevention

0 commit comments

Comments
 (0)