title: Lazy loading occasionally doesn't work in angular
body: <p>I am encountering some strange behavior for the following code.</p>
  
  <pre><code>    function linkFunc(scope, element, attribute) {
          var page = angular.element($window);
  
          page.bind('scroll', function() {
  
              var windowHeight = "innerHeight" in window ? window.innerHeight : document.documentElement.offsetHeight;
              var body = document.body, html = document.documentElement;
              var docHeight = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight,  html.scrollHeight, html.offsetHeight);
              var windowBottom = windowHeight + window.pageYOffset;
  
              if (windowBottom &gt;= docHeight) {
                  scope.$apply(attribute.myDirective);
              }
          });
      }
  </code></pre>
  
  <p>The above is a piece of code that detects if the bottom of the page is reached, if its reached it will call whatever function bind to <code>myDirective</code></p>
  
  <p>The main issue is that most of the time the lazy loading works, and <code>myDirective</code> gets sucessfully called. However some of the times the lazy loading won't work, and I wasn't able to reproduce the bug.</p>
  
  <p>I tried different screen size, different browser, but it seems like the bug just happens randomly.</p>
  
  <p>Maybe someone have this happened to them before, and can point me a direction? </p>
  
  <p>Edit: </p>
  
  <p>More information</p>
  
  <p>I was able to reproduce the bug after a bit of experimenting.</p>
  
  <p>Basically, when the zoom in percentage of the browser is <code>&lt; 100 %</code> , <code>window.pageY</code> returns a decimal value that is slightly inaccurate which cause <code>windowBottom</code> to be off by a <code>0.1</code> to <code>0.9</code></p>
  
  <p>eg.</p>
  
  <pre><code>            console.log(windowBottom); // 1646.7747712336175
              console.log(docHeight);    // 1647
  </code></pre>
  
  <p>Does anyone know why this happens?</p>
  
  <p>Edit 2:</p>
  
  <p>The above behavior is also non deterministic, but the decimal part is true.</p>