title: window.requestAnimationFrame() not working in Ionic2 application
body: <p>I'm trying to use an HTML5 canvas for animation in my Ionic 2 app. For this, I have to use <code>window.requestAnimationFrame()</code> to animate my canvas. This is my code: </p>
  
  <pre><code>import { Component, ViewChild, Renderer } from '@angular/core';
  import { Platform } from 'ionic-angular';
  import { IonicPage, NavController, NavParams } from 'ionic-angular';
  
  ...
  
  export class CubePage {
    @ViewChild('glCanvas') canvas: any;
    canvasElement: any;
    ctx: any;
    radius: number;
    leftBallX: number;
    leftBallY: number;
    rightBallX: number;
    rightBallY: number;
  
    constructor(public navCtrl: NavController, public navParams: NavParams, public renderer: Renderer, public platform: Platform) {
    }
  
    ngAfterViewInit() {
      console.log(this.canvas);
      this.radius = 25;
      this.canvasElement = this.canvas.nativeElement;
  
      this.renderer.setElementAttribute(this.canvasElement, 'width', this.platform.width() + "");
      this.renderer.setElementAttribute(this.canvasElement, 'height', this.platform.height() + "");
      this.ctx = this.canvasElement.getContext('2d');
  
      this.leftBallX = 5;
      this.leftBallY = 5;
  
      window.requestAnimationFrame(this.cycle);
    }
  
  
    cycle() {
      if (this.leftBallX &lt; this.platform.width() / 2) {
        this.ctx.clearRect(0, 0, this.platform.width(), this.platform.height());
        this.drawCenterLine();
        this.updateLeftBall(this.leftBallX + 5, this.leftBallY);
        this.drawLeftBall();
      }
      window.requestAnimationFrame(this.cycle);
    }
  ...
      }
  </code></pre>
  
  <p>It gives the runtime error <code>Cannot read property 'leftBallX' of undefined</code> when I load the application in my web browser. However, when I eliminate the <code>window.requestAnimationFrame(this.cycle)</code> lines, replacing the first with <code>this.cycle()</code>, there are no errors. Is there a problem with using <code>window</code> in Ionic/Angular?</p>