-
Notifications
You must be signed in to change notification settings - Fork 195
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
Add partialVisiblity
property.
#15
Conversation
Nice idea, thanks @kompot ! Sorry I'm not merging straight away, I'd just like to take a bit of a closer look tomorrow morning and explore more how it impacts existing functionality. Probably write a new test case too. Will respond to this soon. |
Thanks, great! |
Suggestion: rename isVisible property to |
|
@kompot @kof all good suggestions. I'm wondering whether we can find something backwards-compatible. What would you all think about leaving @kompot would that work for your use-case? |
But there might be some confusion. Consider element is fully visible, then it becomes partially visible. Should we fire @kof 's suggestion to make it enum instead of boolean seems reasonable to me. |
@kompot yeah the reason I'm thinking 2 separate callbacks instead of a single with enum value is that question of "when is the callback called?". I'm thinking that in most cases you would either care about full visibility or partial visibility, but not so much the transition from partial-to-full. But I agree the naming I proposed could be tightened up to be clearer. |
Another option that would preserve backwards-compatibility:
What do you think? |
I think with proper versioning and changelog, breaking changes are not an issue at all. 👎 for 2 callbacks, makes api more complex Libs should not be opinionated. I can perfectly think of use cases where its important to know when element changes from partial to visible or hidden states. |
Sure, I agree that we don't want to overly complicate things here. @kompot I've had a closer look and I think the way you've implemented it is good as it won't change the behaviour until you opt-in with the I'd like to consider a more comprehensive solution that allows you to get notifications about both partial and full visibility. Possibly removing the Thanks! |
Add `partialVisiblity` property.
@kompot published as |
Yes, I think it's a good plan. We can also see if there are any other breaking-changes needing to be made to roll into 3.0 Before then, it's a good opportunity to try partial visibility some more and see how it affects things. Eg. I'm thinking a "threshold" prop will definitely be useful because at the moment even 1px of visibility will trigger onChange, and in a lot of cases you'd want it to be less sensitive. I'll create a new issue to discuss any other things people want to see in 3.0 |
If
partialVisibility
is set then element is considered visible if only part of it is visible.