Skip to content

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

Closed
@wangyi7099

Description

@wangyi7099

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});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions