Created
March 26, 2019 18:49
-
-
Save ryanflorence/9c781cc493fa10fce8b7fbf8ee4c925f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const transitions = useTransition( | |
{ weeks, startDate }, | |
item => item.startDate, | |
{ | |
from: { y: -100 }, | |
enter: { y: 0 }, | |
leave: { y: 100 }, | |
initial: null | |
} | |
) | |
const transitionDirection = location.state && location.state.direction | |
const handleNav = (addOrSubDays, direction) => { | |
const date = formatDate(addOrSubDays(startDate, 7 * 4), DATE_FORMAT) | |
navigate(".", { state: { startDate: date, direction } }) | |
} | |
const handleEarlierClick = () => handleNav(subDays, "earlier") | |
const handleLaterClick = () => handleNav(addDays, "later") | |
// later | |
<div className="Calendar_animation_overflow"> | |
{transitions.map(({ item, props: { y }, key }) => { | |
if (!item) return null | |
let transform = "translate3d(0px, 0%, 0px)" | |
if (transitionDirection === "earlier") { | |
transform = y.interpolate(y => `translate3d(0px, ${y}%, 0px)`) | |
} else if (transitionDirection === "later") { | |
transform = y.interpolate(y => `translate3d(0px, ${-y}%, 0px)`) | |
} | |
return ( | |
<animated.div | |
key={key} | |
className="Calendar_animation_wrapper" | |
style={{ transform }} | |
> | |
{"..."} | |
</animated.div> | |
) | |
})} | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment