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

How to scroll to invisible element in the list? #50

Open
rsousacode opened this issue Dec 19, 2020 · 2 comments
Open

How to scroll to invisible element in the list? #50

rsousacode opened this issue Dec 19, 2020 · 2 comments

Comments

@rsousacode
Copy link

How to scroll to invisible element in the list?

Using svelte "this binding" is not possible since the HTML element is null while invisible.

@rsousacode
Copy link
Author

rsousacode commented Dec 19, 2020

I got a very hacky solution (a boolean flag) to make it work with no apparent scrolling bugs with the help of _scrollTo3 provided here: #43.

This basically de-virtualize the list, but at least the load time of the page is still ok.

let handle = true

async function _scrollTo3 (index, opts) {
    // code 

    handle = false

}


async function handle_scroll(event) {
    // ...

    end = i;
    
    if(!handle) return // add this here

    const remaining = items.length - end;
    
    // ...

}

@gitbreaker222
Copy link

I think in the mean time I've removed the _scrollTo3 function in favour for a clean PullRequest, which introduces now the function scrollToIndex. Maybe you like to check out the demo again and see, if the second column fits to your use-case, if you replace the random index with a specific one in App.svelte ln.22 like randomIndex = 100

https://svelte.dev/repl/1c36db7c1e7e4ef2bfb04874321412e5?version=3.20.1

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