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

LiquidRoute breaks the normal scrolling behavior #2

Open
savaryt opened this issue Jul 14, 2017 · 2 comments
Open

LiquidRoute breaks the normal scrolling behavior #2

savaryt opened this issue Jul 14, 2017 · 2 comments

Comments

@savaryt
Copy link

savaryt commented Jul 14, 2017

When routing, the scroll position of the new route seems to be the one from the previous route.
For example if I have a List of 500 articles and I scroll to the #300 and route to the article details the scroll position is a the bottom of the page.

Note
I'm using preact-mdl LayoutContent, this bug may only be present in this case.

Workaround for now:

  handleRouting = event => {
    this.currentUrl = event.url
    const content = document.querySelector('.mdl-layout__content')
    if (content) content.scrollTop = 0
  }
@prateekbh
Copy link
Owner

No i guess, its with this package only, but do you think that default scroll to 0 would be good or doing it in a callback would be better?

@savaryt
Copy link
Author

savaryt commented Jul 14, 2017

Hm, I'm not sure I understand what you mean.

No I guess, it's with this package only

You mean the bug is only present with preact-mdl ? Or it's related to liquid-route ?

but do you think that default scroll to 0 would be good or doing it in a callback would be better?

I'm not sure what you mean by doing it in a callback ?
Scrolling to the last scroll position known for this route would be the best behavior I think.

Taking back the article example, if I'm actually at #300 and navigate to the details for the first time:
Then read half the article.
Then navigate back to the article list.
At this point I should be back at the scrolling position of article #300.
Then if I navigate to the article #300 details again, I should be where at the article, which was the last known position for this route.

But, I'm not sure this is possible at all since it's related to MDL, moreover using component like a virtual-list will break the behavior I think.

In the end that's the reason why I went with the simple scrollTop method as it behave the same as using the default route instead of liquid-route.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants