Waypoint
yarn add react-waypointUses
Example
import { Waypoint } from "react-waypoint";
class MenuBar extends Component {
state = {
scrolled: false
};
handleWaypointEnter = () => {
this.setState({ scrolled: false });
};
handleWaypointLeave = () => {
this.setState({ scrolled: true });
};
render() {
const navClass = classNames(
"navbar",
{ "add-nav-shadow": this.state.scrolled }
);
return (
<Waypoint
onEnter={this.handleWaypointEnter}
onLeave={this.handleWaypointLeave}
/>
)
}Last updated