NeXTs / Clusterize.js

Tiny vanilla JS plugin to display large data sets easily
https://clusterize.js.org
MIT License
7.22k stars 412 forks source link

Can't scroll to a specific element at the end of a big list #127

Closed TomCorvus closed 7 years ago

TomCorvus commented 7 years ago

Hi,

This plugin is really cool. No laggy scroll with 3000 elements. Very interesting!

I have just one problem. When the page is loaded, I try to scroll to a specific element inside a scrollable container but this element doesn't exist in DOM because clusterize.js is already initialized and this element is at the bottom of this container.

Do you have a solution for that?

Thanks

NeXTs commented 7 years ago

Hi

Does your rows have same height? If yes, you could try to predict scroll position of your element and scroll to it manually after initialization.

document.getElementById('scrollElemId').scrollTop = heightOfYourRow * positionOfYourRow;
TomCorvus commented 7 years ago

Perfect! Same thing for search. I create an array of the elements of my list, then search in when I type on input. Just one thing, why is it preferable to render rows by myself with an array of tags in String? Best performance?

Thanks for your answer

NeXTs commented 7 years ago

Instead of handling DOM nodes directly? Yes, that because of memory allocation

TomCorvus commented 7 years ago

Great. Thanks for your work!