react-feather#Crop JavaScript Examples
The following examples show how to use
react-feather#Crop.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Landing.js From popper.js.org with MIT License | 4 votes |
PreventOverflowExample = () => {
const [boundary, setBoundary] = useState();
const scrollContainerRef = useRef();
const { reference, popper } = usePopper({
placement: 'right',
modifiers: [
{
name: 'preventOverflow',
options: {
boundary,
},
},
],
});
useLayoutEffect(() => {
scrollContainerRef.current.scrollTop =
window.innerWidth <= sizes.lg ? 490 : 450;
}, []);
const code = `
import { createPopper } from '@popperjs/core';
const popcorn = document.querySelector('#popcorn');
const tooltip = document.querySelector('#tooltip');
createPopper(popcorn, tooltip, {
placement: 'right',
});
`;
return (
<ExampleBox>
<div
css={css`
position: relative;
overflow: hidden;
`}
ref={setBoundary}
>
<ScrollContainer ref={scrollContainerRef}>
<PopcornBox
ref={reference}
src={popcornBox}
css={css`
position: absolute;
left: 100px;
`}
/>
</ScrollContainer>
<Tooltip ref={popper}>
<TooltipName>Popcorn</TooltipName>
<TooltipName>sizes</TooltipName>
<TooltipName>& Price</TooltipName>
<TooltipPrice>XXS: $1.99</TooltipPrice>
<TooltipPrice>XS: $2.99</TooltipPrice>
<TooltipPrice>S: $3.99</TooltipPrice>
<TooltipPrice>M: $4.99</TooltipPrice>
<TooltipPrice>L: $5.99</TooltipPrice>
<TooltipPrice>XL: $6.99</TooltipPrice>
<TooltipPrice>XXL: $7.99</TooltipPrice>
<Arrow data-popper-arrow />
</Tooltip>
</div>
<ExampleText>
<Heading>
<Crop /> Overflow prevention
</Heading>
<p>
<strong>Scroll the container</strong> (or the whole page) to see the
tooltip stay within the boundary. Once the opposite edges of the
popcorn and tooltip are aligned, the tooltip is allowed to overflow to
prevent detachment.
</p>
<Highlight code={code} />
<span>
<ExternalLinkStyled to="https://codesandbox.io/s/github/popperjs/website/tree/master/examples/overflow-prevention">
Edit on CodeSandbox
</ExternalLinkStyled>
</span>
</ExampleText>
</ExampleBox>
);
}
Example #2
Source File: Landing.js From popper.js.org with MIT License | 4 votes |
Layout = ({ children }) => {
const data = useStaticQuery(graphql`
query LandingTitleQuery {
site {
siteMetadata {
title
}
}
}
`);
return (
<MDXProvider components={components}>
<SEO title="Home" />
<Header siteTitle={data.site.siteMetadata.title} />
<InstallBar />
<CarbonAds
css={css`
${media.lg} {
position: absolute;
top: 0;
right: 15px;
.carbonplaceholder,
#carbonads {
background-color: #ffffff4f;
color: #632f45;
}
}
`}
/>
<Container maxWidth={1400}>
<PlacementExample />
<PreventOverflowExample />
<FlipExample />
</Container>
<Section>
<Container>
<Crop size={50} stroke="#ffe69d" />
<Heading>In a nutshell, Popper:</Heading>
<Ul>
<Li>
<Check />
<strong>
Places your tooltip or popover relative to the reference
</strong>{' '}
taking into account their sizes, and positions its arrow centered
to the reference.
</Li>
<Li>
<Check />
<strong>
Takes into account the many different contexts it can live in
</strong>{' '}
relative to the reference (different offsetParents, different or
nested scrolling containers).
</Li>
<Li>
<Check />
<strong>
Keeps your tooltip or popover in view as best as possible
</strong>
. It prevents it from being clipped or cut off (overflow
prevention) and changes the placement if the original does not fit
(flipping).
</Li>
</Ul>
</Container>
</Section>
<Section>
<Container>
<CloudLightning size={50} stroke="#ffe69d" />
<Heading>Our Sponsors</Heading>
<p>
Popper is proudly sponsored by the following organizations,
<br />
join them on{' '}
<ExternalLinkStyled to="https://opencollective.com/floating-ui">
Open Collective
</ExternalLinkStyled>{' '}
to support us.
</p>
<Sponsors />
</Container>
</Section>
<Section>
<Container>
<Layers size={50} stroke="#ffe69d" />
<Heading>Granular configuration with sensible defaults</Heading>
<p>
Popper aims to "just work" without you needing to configure much. Of
course, there are cases where you need to configure Popper beyond
its defaults – in these cases, Popper shines by offering high
granularity of configuration to fine-tune the position or behavior
of your popper.
</p>
<p>
You can extend Popper with your own modifiers (or plugins) to make
your popper work for you, no matter how advanced the scenario.
</p>
</Container>
</Section>
<Section>
<Container>
<Check size={50} stroke="#ffe69d" />
<Heading>No compromises</Heading>
<Ul>
<Li>
<Check />
<strong>No detachment</strong>. Position updates take less than a
millisecond on average devices. Popper doesn't debounce the
positioning updates of the tooltip to the point where it will{' '}
<em>ever</em> detach from its reference, but this doesn't come at
the cost of poor performance.
</Li>
<Li>
<Check />
<strong>
You don't have to change the DOM context of your tooltip or
popover element
</strong>
; it will work no matter where your popper and reference elements
live, even in the most complex scenarios like nested scrolling
containers or alternative offsetParent contexts.
</Li>
<Li>
<Check />
<strong>Still lightweight</strong>. Handling all of this
complexity is still done in an efficient manner. The base Popper
is only 2 kB minzipped.
</Li>
</Ul>
</Container>
</Section>
<Section>
<Container>
<Heart size={50} stroke="#ffe69d" />
<Heading>Free open-source, used by millions</Heading>
<p>
Popper has billions of hits across the web, is trusted by millions
of developers in production, and used in popular libraries like
Bootstrap and Material UI.
</p>
<Button
href="https://opencollective.com/floating-ui"
target="_blank"
rel="noopener noreferrer"
>
Support us
</Button>
<UsedByContainer>
{USED_BY_LIST.map(({ logo, label, url }) => (
<UsedByLogo href={url} src={logo} alt={label} key={url} />
))}
</UsedByContainer>
</Container>
</Section>
<Section>
<Container>
<ChevronRight size={50} stroke="#ffe69d" />
<Heading>Ready to start?</Heading>
<p>
Start reading{' '}
<LinkStyled to="/docs/">Popper's documentation</LinkStyled>!
</p>
</Container>
</Section>
<Footer>
<Container>
<p>© {new Date().getFullYear()} MIT License</p>
</Container>
</Footer>
</MDXProvider>
);
}