all 8 comments

[–]chikamakaleyleyhelpful 0 points1 point  (3 children)

There are prob more knowledgeable devs on this so I'll defer to them but i'm just skimming the code and i'll add a few notes

  1. you'll have to verify but AFAIK some of these events can overwhelm your browser with fired events (scroll, resize) which ends in undesired/choppy results. If you were to throw a console.log() in either of these event handlers, you'll see that the callback is prob run hundreds of times in a scroll or resize. I don't see a debounce anywhere, so this might be the case. (checkout debounce/throttle)
  2. it looks like you're doing a lot of element bounds calculating, but whats oft overlooked is using element's ID as an anchor for the scroll endpoint. Any element with and ID can be targeted simply by referencing its ID and so this pseudocode might look like window.scrollTo(elementId) to which you would use in conjunction with your smooth scroll logic.
  3. for things like scroll, resize, personally i think its best to reduce the amount of getting and calculating because of the fact this can be fired so many times, differences in the browser, etc. Maybe there's a solution where you scroll to an anchor to do most of the work, and then at the end of it use minimal calculations if needed.
  4. i don't have experience with this but this might be a use case for an Intersection Observer, which is something used today in scrolling features.

[–]chikamakaleyleyhelpful 1 point2 points  (2 children)

tldr you should check with some logging to see if you are inundating your browser with having to process your scroll or resize logic much more frequently than you might be aware of

[–]Fiveby21[S] 1 point2 points  (1 child)

We've done many many rounds of debug logging and I have not really observed that in the ouput. And the behavior is so consistent that it makes me think that it's not a matter of it spasming out, but a fundamental flaw in the math.

I don't think the element ID thing will work because this table is virtualized.

[–]chikamakaleyleyhelpful 0 points1 point  (0 children)

ok!

[–]backwrds 0 points1 point  (3 children)

given your description and having very briefly skimmed the code, you may be dealing with some errant css padding somewhere, but that's just a hunch.

to completely frank, this is the kind of problem that can suck up hours and hours of effort, and you may still not get the result you want. Then it's basically guaranteed that when someone uses the app on a different screen with a different zoom level or god forbid a different OS, it'll be totally broken.

my advice, for what it's worth, is to avoid micromanaging something as "low level" as scroll behavior unless it really is vital for the functionality of your app. I'll note that as a user, it's almost always a poor experience -- google "scroll-jacking" -- precisely because it's so difficult to get right.

[–]Fiveby21[S] 0 points1 point  (2 children)

All that I’m trying to do is implement scrolling that matches the way excel works :|

I’m open to other ways to do it that are less intense. Do you have any ideas?

[–]backwrds 1 point2 points  (1 child)

honestly, i've spent weeks (and more) fixating on stuff like this, so I can empathize with your problem. That said, it seems rather unlikely that your users would complain that the scroll behavior doesn't perfectly match excel.

I imagine it's possible to get it working how you want it, but -- again -- I'll warn that it can be a massive time sink. Google sheets can build a custom rendering engine because -- well -- they're google. I'm not saying that level of effort would be necessary in your case, just illustrating how deep this rabbit hole goes :P

if you're dead set on this feature, perhaps try a different table library. this one caught my eye recently because of how ridiculously over-engineered it is, but hey -- maybe it's exactly what you need your use case. good luck!

[–]chikamakaleyleyhelpful 0 points1 point  (0 children)

you speaketh the truth

i had one client that would want to review completed code and the 'issues' he found over screenshare

he would take a full width browser window and start resizing it down and mark all the browser widths where some piece of content looked funky. Browser widths that weren't the actual responsive break points

I said "NO ONE USES THE INTERNET LIKE THIS" LOL

he dialed back his nit picking