Fehler beim ausführen der 'requestAnimationFrame' auf 'Fenster': Der callback bereitgestellt, die als parameter 1 ist keine Funktion.

Nicht sicher, was ich falsch mache hier...

window.requestAnimFrame = function(){
return (
    window.requestAnimationFrame       || 
    window.webkitRequestAnimationFrame || 
    window.mozRequestAnimationFrame    || 
    window.oRequestAnimationFrame      || 
    window.msRequestAnimationFrame     || 
    function(/* function */ callback){
        window.setTimeout(callback, 1000 / 60);
    }
);
}();

function animationSequence(elem, ind) {
    this.ind = ind;
    this.elem = elem;
    this.distance = 450;
    this.duration = 900;
    this.increment = 0;
    this.start = Math.abs(this.ind)*450;
    var requestId = requestAnimFrame(this.animate);
    this.move();

    this.move = function() {
        this.elem.style.left = this.start - this.increment + "px";
    }
    this.animate = function() {
        var self = this;
        this.move();
        this.increment += 5;
        if (this.increment >= 450) { 
            if (this.ind == 0) { console.log("true"); this.elem.style.left = "1350px" }
            cancelAnimFrame(requestId);
        }
    }
    //this.animate();
}
  • Haben Sie versuchen, um Platz var requestId = requestAnimFrame(this.animate); unterhalb der this.animate definition einer Funktion?
InformationsquelleAutor natecraft1 | 2014-02-26
Schreibe einen Kommentar