Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix visibilityChanged event MountState calculations
Summary: The visibilityChanged event is using the incorrect rectangles to calculate percent visibility. This is visible in the test added and also affects nested LithoView situations (like when used in a VeriticalScroll component). The old calculation used the layoutState and localVisibleRect The new calculation uses the visibilityOutputBounds and the intersection of the visibilityOutputBounds and localVisibleRect See D7377488 where I made a similar fix for the visibleRatio calculation --- `localVisibleRect` represents the full screen (in the test, Rect(left=0, top=0, right=10, bottom=1000)) `visibilityOutputBounds` represents the renderedComponent (in the test, Rect(left=0, top=0, right=10, bottom=10) `sTempRect` represents the intersection of localVisibleRect and visibilityOutputBounds, essentially the part of the component that is visible on screen (in the initial mount of the test, Rect(left=0, top=0, right=10, bottom=10) Therefore it follows if we want to calculate the amount on screen, we use `sTempRect` to get the width/height of the visible component and then divide by visibilityOutputBounds to get the percent of the component that is visible. Reviewed By: mihaelao Differential Revision: D14377550 fbshipit-source-id: 8e98c53f07bbbf1023ea71fbd8dfe82dee02dce1
- Loading branch information