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

Scroll Behaviour #108

Closed
mwasigala opened this issue Feb 19, 2021 · 11 comments
Closed

Scroll Behaviour #108

mwasigala opened this issue Feb 19, 2021 · 11 comments
Labels
feature New feature or request

Comments

@mwasigala
Copy link

I have a list within the tab, i want to remember the position of the list as i navigate.... please help its urgent
Sorry i didn't see an option to submit a question

@mwasigala mwasigala added the bug Something isn't working label Feb 19, 2021
@bhuh12
Copy link
Owner

bhuh12 commented Feb 20, 2021

@mwasigala
Copy link
Author

I have done so and it's not working with router tab when I scroll a list then I navigate to other tab then return back to the. List it doesn't show from the last position

@bhuh12
Copy link
Owner

bhuh12 commented Feb 20, 2021

Presumably the scroll element is not specified

scrollBehavior (to, from, savedPosition) {
   if (to.meta.scrollElement) {
     return {
       selector: to.meta.scrollElement
     }
   }
}

Reference:
https://router.vuejs.org/guide/advanced/scroll-behavior.html
https://github.com/vuejs/vue-router/blob/dev/examples/scroll-behavior/app.js

@mwasigala
Copy link
Author

mwasigala commented Feb 23, 2021

I think this has all to do with how i define my tabs... with the :tabs attribute (default tabs);
because i have tried it in a normal tabs without using attributes it works ,
The above solution doesn't help my list is dynamic and list elements are created on fly..,

@bhuh12
Copy link
Owner

bhuh12 commented Feb 25, 2021

Is it the tab list or the content on the page that has the problem with scroll positioning?

@mwasigala
Copy link
Author

The list content within the tab

@bhuh12
Copy link
Owner

bhuh12 commented Mar 4, 2021

Can you provide screenshots, screen recordings, or code to reproduce the problem?

@mwasigala
Copy link
Author

Before navigation

Screenshot 2021-04-14 235610

After Scrolling
Screenshot 2021-04-14 235704

Navigating back to the Tab again
Screenshot 2021-04-14 235610

It is as if the page doesn't save the scroll position

@bhuh12
Copy link
Owner

bhuh12 commented Apr 16, 2021

RouterTab does not save the scrolling position of the page, because the 'scrollbehavior' provided by vue-router implements this function.

If the page data will be reloaded when the tab is activated, you may need to implement it yourself

  1. When "deactivated", record the scrolling position of the scroll element

  2. When "activated", set the recorded scroll position to the scroll element after the page data is updated

@mwasigala
Copy link
Author

@bhuh12 okay thanks for the info

@bhuh12 bhuh12 added feature New feature or request and removed bug Something isn't working labels Apr 21, 2021
@bhuh12
Copy link
Owner

bhuh12 commented May 9, 2021

v1.2.6 already supports this feature.

Doc: https://bhuh12.github.io/vue-router-tab/guide/custom/scroll.html
Demo: https://bhuh12.github.io/vue-router-tab/demo/#/page-scroller/

This version provides component syntax hints for the Vetur extension, welcome to update and experience.

image

Changelog: https://bhuh12.github.io/vue-router-tab/guide/changelog.html

@bhuh12 bhuh12 closed this as completed May 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants