Skip to content
This repository was archived by the owner on Jan 13, 2022. It is now read-only.

Conversation

@mikestead
Copy link
Contributor

Adds onScrollStart callback to be paired with FixedDataTable's existing onScrollEnd.

Problem

In order to add a hover state to a row we need to redraw when the mouse enters and leaves each row. This can be done using css hover or using the Table's onRowMouseEnter and onRowMouseLeave. The problem with both of these options is that when mouse wheel scrolling no native mouse leave event seems to fire from the browser (seen at least in FF, Chrome, Safari). This means as the row scrolls off it remains in hovered state even though the mouse is no longer over it. I believe this is a translate/translate3d bug or optimisation.

hover-screencap

Only when you move the mouse again does hover state update. This also means that when you stop wheel scrolling the row under the mouse does not draw its hovered state until you move the mouse.

As mentioned in #17 css hover is preferred for performance reasons, but even if that did work properly you'd still be sacrificing some performance due to constant redraws during scrolling.

Solution

When onScrollStart fires remove current hover state and disable hover updates until onScrollEnd.

As a side note, in order to reapply the hover state when wheel scrolling stops I track the mouse position while the table is mounted and when onScrollEnd fires I do some basic hit detection based on the scroll position to determine which row is under the mouse.

Maybe there's a simpler solution for all this? For now this was the only way I could find to get bug free + performant hover states.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the functionality is very reasonable, but I would like us to avoid having information "isScrolling" in state of component, because we don't inform render by it in any way, so it may mark the table as needing re-render unnecessarily. Could you please move this to private var?

@mikestead
Copy link
Contributor Author

@wlis good point, updated.

wlis added a commit that referenced this pull request Jun 22, 2015
@wlis wlis merged commit e97be92 into facebookarchive:master Jun 22, 2015
@wlis
Copy link
Contributor

wlis commented Jun 22, 2015

Thanks for the pull request!

sepo-one pushed a commit to One-com/fixed-data-table that referenced this pull request Sep 3, 2017
* 15.5 support

* Adding several fixes

* Removing isMounted calls

* Fixing merge conflict

* Adding missing package

* Move prop-types & create-react-class to dependencies

Also update react-docgen version & ExampleImage to not use isMounted
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants