-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add browser API to enable page transitions plugins #1415
Add browser API to enable page transitions plugins #1415
Conversation
Deploy preview ready! Built with commit fdf1c51 |
Deploy preview ready! Built with commit fdf1c51 |
Deploy preview ready! Built with commit fdf1c51 |
const React = require('react')
const { Transition } = require('react-move')
exports.componentRenderer = ({currentPage, previousPage}) => {
console.log(currentPage, previousPage)
return (
<Transition
data={[
currentPage,
previousPage
]}
getKey={d => d.location.pathname}
enter={d => ({
transform: `translateX(100%)`,
opacity: 1,
zIndex: 1,
boxShadow: '0 0 20px 0 rgba(0,0,0,0)',
})}
update={d => ({
transform: `translateX(0%)`,
opacity: 1,
zIndex: 1,
boxShadow: '0 0 100px 0 rgba(0,0,0,.5)'
})}
leave={d => ({
transform: `translateX(-33%)`,
opacity: .8,
zIndex: 0
})}
ignore={['zIndex']}
duration={700}
>
{nodes => (
<div>
{nodes.map(node => {
const { component: Component, ...rest } = node.data
return <div key={node.key} style={{
position: 'absolute',
left: 0,
right: 0,
top: 0,
bottom: 0,
background: 'white',
...node.state
}}>
<Component {...rest} />
</div>
})}
</div>
)}
</Transition>
)
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! This is really exciting!
I tried your demo code on www and it mostly worked. I had to add a check if there was a previous page so as to not navigate on the initial render which I think plugins will always need to handle but otherwise it worked as expected! Exciting!
...this.state.pageResources.json, | ||
const pluginResponses = apiRunner('componentRenderer', { | ||
previousPage: { | ||
...this.props, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be this.previousProps
return createElement(this.state.pageResources.component, { | ||
...this.props, | ||
...this.state.pageResources.json, | ||
const pluginResponses = apiRunner('componentRenderer', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's name this API replacePageComponentRenderer
per https://www.gatsbyjs.org/docs/api-specification/#operators
I'll update these changes asap |
When I tried the example code, besides the mentioned previousPage workaround, the props.data of the rendered page seems to be undefined. So the result of the graphql query appears to be missing. I can't quite figure out where it went wrong. |
@tannerlinsley hey I'm going to take a crack at finishing this — a client needs this functionality added ASAP. |
Deploy preview failed. Built with commit fdf1c51 https://app.netlify.com/sites/using-glamor/deploys/5963ed5ecf321c63a9d70aaf |
33a818c
to
fdf1c51
Compare
Ok so didn't end up finishing this as the client and I decided to go with a simple entry animation for components not an exit & entry animation. I did push a commit fixing up some things. Want to push this across the finish line still @tannerlinsley ? |
Is there an update on this? Any sample code? |
Any news on this? 👍 |
Closing this as @stevensurgnier added an API with alternative approach to solving this issue #2557 Thanks to everyone who's participated here! Check out the new API and let us know what you think! |
This is very provisional, but I’m excited where it’s going :)