Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export default class NavbarComp extends Component {
- constructor() {
- super();
- this.state = {
- windowHight:"",
- navbarfix: ""
- };
- this.handleScroll = this.handleScroll.bind(this)
- }
- getWindowHight(){
- let deviceWindow = document.getElementById('landing-section');
- let deviceWindowHight = window.getComputedStyle(deviceWindow).getPropertyValue('height');
- console.log("from getinitiatlhight" + deviceWindowHight);
- this.setState({
- windowHight: deviceWindowHight
- });
- componentDidMount(){
- window.addEventListener('scroll', this.handleScroll);
- this.getWindowHight();
- }
- handleScroll() {
- console.log("scrolll" + this.state.windowHight);
- if (window.pageYOffset >= this.state.windowHight) {
- console.log("fix");
- } else if (window.scrollY < this.state.windowHight) {
- console.log("unfix" );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement