title: TypeError: 'requestAnimationFrame' called on an object that does not implement interface Window
body: <p>I am converting my <code>setInterval</code> code to <code>requestAnimationFrame</code>. I am using it inside a class so I need to bind <code>this</code> to the passed function.</p>
  
  <p>When I assign the correct vendor function to a variable (<code>this.raf</code>), I am getting the error: </p>
  
  <blockquote>
    <p>TypeError: 'requestAnimationFrame' called on an object that does not
    implement interface Window.</p>
  </blockquote>
  
  <p>The code works fine when I call <code>window.requestAnimationFrame</code> directly. Any ideas why the error?</p>
  
  <p>Here is <a href="https://jsfiddle.net/mseifert/zfuzLpo5/" rel="nofollow noreferrer">a fiddle</a></p>
  
  <pre><code>slideshow = (function() {
    function slideshow() {
      this.slideShowRunning = false;
      this.slide = 0;
    }
  
    slideshow.prototype.startSlideshow = function() {
      var newSlide;
      this.slideShowRunning = true;
      this.rafId;
      this.raf = window.requestAnimationFrame ||
        window.mozRequestAnimationFrame ||
        window.webkitRequestAnimationFrame ||
        window.msRequestAnimationFrame ||
        window.oRequestAnimationFrame;
  
      function loop() {
        // stop the loop if fn returned false
        if (this.slideShowRunning !== false) {
          if (this.slide &lt; this.count - 1) {
            newSlide = this.slide + 1;
          }
          this.loadSlide(newSlide);
          // loop until cancelled
          var boundLoop = loop.bind(this);
  
          // THIS GIVES THE ERROR
          this.rafId = this.raf(boundLoop);
  
          // BUT THIS WORKS
          //this.rafId = window.requestAnimationFrame(boundLoop);
        }
      }
      var boundLoop = loop.bind(this);
      boundLoop();
    }
  
    slideshow.prototype.loadSlide = function(slideNumber) {
      // loading the slide
      console.log(slideNumber);
    }
  
    return slideshow;
  
  })();
  
  ss = new slideshow();
  divStart = document.getElementById("start");
  divStart.onclick = function() {
    ss.startSlideshow()
  };
  </code></pre>