DockYard / ember-in-viewport

Detect if an Ember View or Component is in the viewport @ 60FPS
MIT License
245 stars 91 forks source link

Support % based rootMargin #324

Open Duder-onomy opened 7 months ago

Duder-onomy commented 7 months ago

I would like to use ember-in-viewport in only the horizontal direction.

The product use case here is a VERY large data table with 2000+ rows of 40+ columns, whose column headers have in-viewport checks on them that control if we should render a column's cells.
When the column headers are scrolled off-screen vertically, I don't want to cull the cells. I only want the intersection checking in the horizontal/X direction.

This is possible with IntersectionObservers, by specifying a rootMargin in % values.

This line here: https://github.com/DockYard/ember-in-viewport/blob/58c3f97bcfdac85d862f21730b184c9755355901/addon/services/in-viewport.js#L183

Forces us to use pixel values. If we pass % based values, we get errors like:

image

I suggest we either:

Happy to do the work, but I would like some consensus first.