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

Disable smooth scroll in navigation attempts #43529

Closed
wants to merge 2 commits into from

Commits on Nov 29, 2022

  1. Disable smooth scroll in navigation attempts

    Disable smooth scroll in navigation attempts, restore scroll behaviour when the navigation completes.
    
    The current implementation seems to be wrong, as the scroll behaviour "auto" immediately or during scrolling switches back to "smooth" or the globally defined behaviour of the html tag.
    
    Local experiments showed that the scrolling behaviour "auto" must be initiated at the start of a route change "routeChangeStart" and must be maintained until a route change is completed "routeChangeComplete".
    
    Pre-condition:
    The scroll behaviour "smooth" must either be defined globally in css for the html element. From the hook provided this is done once in the effect-lifecycle, however a user defined configuration seems better, especially as the behaviour can be integrated into Next as described in the next step.
    
    Summary of the lifecycle:
    - Subscribe to routeChangeStart, routeChangeComplete events.
    - The route change starts
       Switch the scroll behavior to 'auto'
       Scroll immediately to the top and hold the value until the route change finishes.
    - The route change finishes
       Switch back to the default value specified in global css for the html element.
       For smooth-scrolling smooth, the behavior is 'smooth'. Hash changes are no route changes;
       the result is smooth scrolling on hash changes.
    Gritsch Markus committed Nov 29, 2022
    Configuration menu
    Copy the full SHA
    d33b98f View commit details
    Browse the repository at this point in the history
  2. Extend type with router property

    Gritsch Markus committed Nov 29, 2022
    Configuration menu
    Copy the full SHA
    8c40a32 View commit details
    Browse the repository at this point in the history