How do you deal with "media queries"
I've just started using react-pose and I'm curious what the best way is to deal with different screen sizes and variations in animations that might depend on screen size.
E.g. a drawer covers perhaps 80% on a mobile screen and a fixed max width on a desktop style screen.
For now you could pass viewport dimensions through as props, but in the near future we’ll provide an object with these On Thu, 14 Jun 2018 at 15:51, Marc Schipperheyn [email protected] wrote:
I've just started using react-pose and I'm curious what the best way is to deal with different screen sizes and variations in animations that might depend on screen size.
E.g. a drawer covers perhaps 80% on a mobile screen and a fixed max width on a desktop style screen.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Popmotion/popmotion/issues/379, or mute the thread https://github.com/notifications/unsubscribe-auth/AHfLKgR2LPGeQwCFbIs-fQEz6P6D3sAyks5t8nhlgaJpZM4UoHCz .
Ok, thx
Have you looked into using the matchMedia function? https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia
Any news on this? I'd like to use a pose transition only on tablets and smaller. Is that possible at this point?
Here's an example of my needs (using react + styled components):
// Cancel link, that shows up when search is in focus
const searchCancelPoseProps = {
visible: {
width: 'auto',
opacity: 1,
transition: { duration: 400, ease: [0.73, 0.09, 0.21, 0.96] },
},
hidden: {
width: '0',
opacity: 0,
transition: { duration: 400, ease: [0.73, 0.09, 0.21, 0.96] },
},
}
export const SearchCancelLink = styled(posed.div(searchCancelPoseProps))`
width: 0;
height: 100%;
overflow: hidden;
// Cancel effects of pose transition, when on md.min
${uMedia.md.min(css`
width: 0 !important;
opacity: 0 !important;
`)};
`
For now I am using a CSS media query to override the styles coming form pose with !important, but I'd prefer something more elegant, if possible 😅
u can pass a function to posed factory so i think u could just return empty config without any poses defined, u would have to pass if poses should be created as a prop to ur component & unfortunately u wouldnt be able to switch between animating or not
im talking about smth like
const searchCancelPoseProps = {
visible: {
width: 'auto',
opacity: 1,
transition: { duration: 400, ease: [0.73, 0.09, 0.21, 0.96] },
},
hidden: {
width: '0',
opacity: 0,
transition: { duration: 400, ease: [0.73, 0.09, 0.21, 0.96] },
},
}
export const SearchCancelLink = styled(
posed.div(
props => props.animate ? searchCancelPoseProps : {}
)
)`
width: 0;
height: 100%;
overflow: hidden;
`