Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Tracking Visibility in Compose #10

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

riggaroo
Copy link
Owner

@riggaroo riggaroo commented Dec 11, 2023

Modifier#onVisibleChange fires events when the visibility of an item changes.

The event includes information such as the bounds of the visible item, and the fraction of the item that's visible. It'll only fire once for when the item enters the screen, and on exit, using the bounds within the current window to determine if an item is visible or not.

Limitations:

  • This modifier has no way to detect if there is something on top of it - obscuring (ie z-index checking).
  • Keyboard visibility, if an item is below the keyboard, this modifier will still track the item as visible, it is recommended that you ensure you are using
  • android:windowSoftInputMode="adjustResize/adjustNothing" to ensure the whole window is resized and then items will not report themselves as being visible.
  • This modifier is tied to the Window Origin, which is fine for the majority of use cases, but be careful when using it inside things such as AlertDialog/ModalBottomSheet etc, as the origin point will be different.

See VisibilityTrackingSample.kt for example usage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant