Skip to content
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

Junky page transition animation due to scroll to page top #9507

Closed
d-ivashchuk opened this issue Oct 28, 2018 · 5 comments
Closed

Junky page transition animation due to scroll to page top #9507

d-ivashchuk opened this issue Oct 28, 2018 · 5 comments
Labels
status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. type: bug An issue or pull request relating to a bug in Gatsby

Comments

@d-ivashchuk
Copy link
Contributor

Summary

I am trying to implement transitions between pages in my Gatsby blog. Although they work as expected, there is a problem I can't get rid of : when I scroll the page to the bottom, on click on gatsby-link the page will be scrolled to the top before actually transitioning.

Relevant information

My Transition component is nothing fancy and looks exactly like explained in Gatsby docs

import React from "react"
import {
    TransitionGroup,
    Transition as ReactTransition,
} from "react-transition-group"

const timeout = 1000
const getTransitionStyles = {
    entering: {
        position: 'absolute',
        opacity: 0,
    },
    entered: {
        transition: `opacity ${timeout}ms ease-in-out`,
        opacity: 1,
    },
    exiting: {
        transition: `all ${timeout}ms ease-in-out`,
        opacity: 0,
        transform: 'translateY(-300px)',
    },
}

class Transition extends React.PureComponent {
    render() {
        const { children, location } = this.props

        return (
            <TransitionGroup>
                <ReactTransition
                    key={location.pathname}
                    timeout={{
                        enter: timeout,
                        exit: timeout,
                    }}
                >
                    {status => (
                        <div
                            style={{
                                ...getTransitionStyles[status],
                            }}
                        >
                            {children}
                        </div>
                    )}
                </ReactTransition>
            </TransitionGroup>
        )
    }
}

To reproduce this issue open the following link , scroll to Second Blog and click on its card. Before transitioning to the contents of Second Blog the page will actually scroll to Third Blog.

Expected behavior

Maybe it's default behavior of link but I want to fix this problem so transition will be done from the current position of the view.

Thanks a lot for helping me out and as usual thanks for an amazing job of maintaining Gatsby!

@kakadiadarpan
Copy link
Contributor

@d-ivashchuk can you provide environment information by running gatsby info --clipboard?

This issue is reproducible at https://using-page-transitions.netlify.com/ as well.

/cc @pieh @m-allanson

@kakadiadarpan kakadiadarpan added type: bug An issue or pull request relating to a bug in Gatsby status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. labels Oct 29, 2018
@d-ivashchuk
Copy link
Contributor Author

Here goes env information:

  System:
    OS: macOS Sierra 10.12.6
    CPU: x64 Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 6.10.1 - /usr/local/bin/node
    npm: 6.4.1 - /usr/local/bin/npm
  Browsers:
    Chrome: 69.0.3497.100
    Firefox: 56.0.2
    Safari: 12.0
  npmPackages:
    gatsby: ^2.0.19 => 2.0.19 
    gatsby-image: ^2.0.15 => 2.0.15 
    gatsby-plugin-feed: ^2.0.8 => 2.0.8 
    gatsby-plugin-google-analytics: ^2.0.5 => 2.0.5 
    gatsby-plugin-hotjar: ^1.0.1 => 1.0.1 
    gatsby-plugin-layout: ^1.0.4 => 1.0.4 
    gatsby-plugin-manifest: ^2.0.5 => 2.0.5 
    gatsby-plugin-offline: ^2.0.5 => 2.0.5 
    gatsby-plugin-react-helmet: ^3.0.0 => 3.0.0 
    gatsby-plugin-sharp: ^2.0.6 => 2.0.6 
    gatsby-plugin-styled-components: ^3.0.0 => 3.0.0 
    gatsby-plugin-typography: ^2.2.0 => 2.2.0 
    gatsby-remark-copy-linked-files: ^2.0.5 => 2.0.5 
    gatsby-remark-images: ^2.0.4 => 2.0.4 
    gatsby-remark-prismjs: ^3.0.0 => 3.0.0 
    gatsby-remark-responsive-iframe: ^2.0.5 => 2.0.5 
    gatsby-remark-smartypants: ^2.0.5 => 2.0.5 
    gatsby-source-filesystem: ^2.0.2 => 2.0.2 
    gatsby-source-graphcms: ^1.0.0-alpha.3 => 1.0.0-alpha.3 
    gatsby-transformer-remark: ^2.1.6 => 2.1.6 
    gatsby-transformer-sharp: ^2.1.3 => 2.1.3 
  npmGlobalPackages:
    gatsby-cli: 2.4.3

@stefanprobst
Copy link
Contributor

See #5213 (comment)

@thorn0
Copy link
Contributor

thorn0 commented Oct 29, 2018

Should we close this in favor of #5213?

@kakadiadarpan
Copy link
Contributor

@thorn0 Yes, let's do that.

@d-ivashchuk we'll be closing this issue, please follow #5213 for updates on gatsby-page-transition component.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

No branches or pull requests

4 participants