inokawa / virtua

A zero-config, fast and small (~3kB) virtual list (and grid) component for React, Vue, Solid and Svelte.
https://inokawa.github.io/virtua/
MIT License
1.35k stars 47 forks source link

virtua/svelte: onscroll does not differentiate between vertical and horizontal scroll event #533

Closed Karakatiza666 closed 3 weeks ago

Karakatiza666 commented 3 weeks ago

When using VList for a vertical list, when doing horizontal scroll onscroll callback is fired with effectively scrollTop value. Ideally, either

inokawa commented 3 weeks ago

It was not exposed because it's not related to virtualization and accessing scrollTop/scrollLeft excessively can degrade perf.

If you want scrollLeft while vertical scrolling, use Virtualizer, like:

<div style="overflow: auto; width:XXpx; height:XXpx" onscroll={(e)=>{ e.target.scrollLeft /* access scrollLeft*/ }}>
  <Virtualzer>
    ...
  </Virtualizer>
</div>
Karakatiza666 commented 3 weeks ago

I''ll try Virtualizer, thanks! My main goal is to run some code on vertical scroll, but not horizontal scroll

Karakatiza666 commented 3 weeks ago

@inokawa still, it is confusing that when you use vertical VList and do a horizontal scroll onscroll still gets called with scrollTop value, so you cannot differentiate between vertical and horizontal scrolls

inokawa commented 3 weeks ago

Thanks for the feedback. I updated the docs a bit.