-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Feature request: context prop to Visibility component #1959
Comments
Yep, we should accept a component and/or DOM node for this. Note, we should also use the |
There is the same issue on the Sticky (#1747), I can fix both of them. @levithomason I would just add a prop that accepts an HTML element. Or do you think of something different using |
Hi there, thank you for adding the context prop for the Visibility component! 👍 👍 for moving so fast on this. However, I've tried using it and |
@frogbandit Beware that React does not support using |
@frogbandit @mariolamacchia Note we are adding a |
@levithomason with the current implementation v0.76.0 on Visibility component scroll event are only atteched to the context property in componentDidMount() so it doesn't work well when the context is changed. handleContextRef = (contextRef) => this.setState({ contextRef })
render() {
const { contextRef } = this.state; // contextRef is undefined no first render() call
return (
<div ref={this.handleContextRef} style={{ height: 700, overflowX: 'auto' }} >
<div style={{ height: 1200 }} />
<Visibility
context={contextRef}
...
<div>
);
} A workaround is to add a check on contextRef so that Visibility component is only mounted when contextRef is defined. render() {
const { contextRef } = this.state; // contextRef is undefined no first render() call
return (
<div ref={this.handleContextRef} style={{ height: 700, overflowX: 'auto' }} >
<div style={{ height: 1200 }} />
{ contextRef &&
<Visibility
context={contextRef}
...
}
<div>
);
} |
If you have an issue, create a new issue. |
Apologies if this is not the right forum to make this request, but it would be great to have a
context
prop for the Visibility component, much like you can change thecontext
in Semantic UI: https://semantic-ui.com/behaviors/visibility.html#/settings.For example. I want to change the
scroll
event listener to listen on the scroll of a surrounding component (i.e. a component which has a height less than the window height, but has an overflow so is scrollable).Currently, when this component is scrolled, none of the Visibility component's props fire because it does not think that the window is being scrolled.
Thanks!
The text was updated successfully, but these errors were encountered: