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

Can customize scroll element not just window by using scrollBehavior api. #2109

Closed
wangyi7099 opened this issue Mar 15, 2018 · 4 comments
Closed

Comments

@wangyi7099
Copy link
Contributor

wangyi7099 commented Mar 15, 2018

What problem does this feature solve?

When using scrollBehavior api, it seems that only supports window scroll i.e.

const router = new VueRouter({
    routes: [...],
    scrollBehavior(to, from, savedPosition) {
        {
            x: 10,
            y: 10
        }
    }
})

// window triggers scrolling
window.scrollTo({x: 10, y: 10});

, so, I hope add a param into the return object element, that the element triggers scrolling, not only window.

What does the proposed API look like?

const router = new VueRouter({
    routes: [...],
    scrollBehavior(to, from, savedPosition) {
        {
            return {
                element: document.querySelector("#app"),
                x: 10,
                y: 10
            }
        }
    }
})

//
// element triggers scrolling
element.scrollTo({x: 10, y: 10});
@posva
Copy link
Member

posva commented Mar 15, 2018

you can already do that with selector: https://router.vuejs.org/en/advanced/scroll-behavior.html

@posva posva closed this as completed Mar 15, 2018
@wangyi7099
Copy link
Contributor Author

wangyi7099 commented Mar 15, 2018

@posva

But this is not what I want.. FYI, the selector only represents that will scroll to its position, not trigger scrolling itself. The window will still trigger scrolling eventually.
Like:
// window.scrollTo()
I hope the passed element trigger scrolling,
Like:
// element.scrollTo({x: 10, y: 10});

@posva
Copy link
Member

posva commented Mar 15, 2018

Ah sorry, this is a duplicate of #1187

@wangyi7099
Copy link
Contributor Author

Thanks ! Got it:)

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