title: Javascript - Nightmare.JS infinite scroll action
body: <p>What am I doing wrong here? I want to scroll-down a page until the selector is gone.</p>
  
  <pre><code>    Nightmare.action('scrollPage', function (done) {
            this.evaluate_now(function () {
              var hitRockBottom = false; 
              while (!hitRockBottom) {
                  // console.log("1");
              // Scroll the page (not sure if this is the best way to do so...)
              this.scrollTo(100000, 0);
  
              // Check if we've hit the bottom
              hitRockBottom = this.evaluate(function() {
                  // console.log("0");
                  return this.exists('selector') === null;
              }); }
            }, done)
          })
  </code></pre>
  
  <p>I'm using:</p>
  
  <pre><code>.goto("link")
  .scrollPage()
  </code></pre>