I want to check my element exist on current page. for example I have a function to check a element is exist and it. but when i leaving the page to another page function is not reload. and I got this error message :
$(document).bind('scroll', function (ev) {
  10 |         var scrollOffset = $(document).scrollTop();
> 11 |         var containerOffset = $('.aboutTop .left').offset().top - window.innerHeight;
  12 |         if (scrollOffset > containerOffset) {
  13 |             $('.aboutTop .left').addClass('load');
  14 |         }
I checked my address with window.location.href
This is my code :
 var $ = require('jquery/dist/jquery.min.js');
    var pathname = window.location.href;
    var p = pathname.replace(/[^a-z0-9A-Z]/gi,'');
    console.log("milad");
    console.log(p);
    if (p != 'httplocalhost3000'){
             console.log("mohammad");
    } else{
        $(document).bind('scroll', function (ev) {
            var scrollOffset = $(document).scrollTop();
            var containerOffset = $('.aboutTop .left').offset().top - window.innerHeight;
            if (scrollOffset > containerOffset) {
                $('.aboutTop .left').addClass('load');
            }
        });
        $(document).bind('scroll', function (ev) {
            var scrollOffset = $(document).scrollTop();
            var containerOffset = $('.download .buttons').offset().top - window.innerHeight;
            if (scrollOffset > containerOffset) {
                $('.download .buttons').addClass('load');
            }
        });
        $(document).bind('scroll', function (ev) {
            var scrollOffset = $(document).scrollTop();
            var containerOffset = $('.download .buttons').offset().top - window.innerHeight;
            if (scrollOffset > containerOffset) {
                $('.download .buttons').addClass('load');
            }
        });
    }
then i want to check element with ref but I cant find offset element in ref.
This is my function :
     var pathname = window.location.href;
        console.log(pathname);
        if (pathname != 'http://localhost:3000/#/') {
        } else if (pathname == 'http://localhost:3000/#/'){
          if(this.state.flag){
            $(document).bind('scroll', (ev) => {
              var scrollOffset = $(document).scrollTop();
              var containerOffset = this.myCountUp.spanElement.offsetTop - window.innerHeight;
              if (scrollOffset > containerOffset) {
                if (this.state.flag) {
                  startAnimation(this.myCountUp);
                  this.setState({
                    flag : false
                  })
                }
              }
            });
          }  
        }
What should I do?
 
     
     
    