2013-07-08 6 views
1

Je veux utiliser camanjs pour manipuler ma toile sur Phonegap, mais quand j'utilise ce code iciUncaught TypeError: fonction Object {...} n'a pas de méthode « bind »

function applySunrise(){ 
    Caman("#myCanvas", function() { 
    this.sunrise(); 
    this.render(); 
    }); 
} 

Il provoque une erreur comme ceci:

Uncaught TypeError: Object function() { 
    var i, pixel, _i, _len, _ref; 
    if (this.context == null) { 
     this.context = this.canvas.getContext('2d'); 
    } 
    this.originalWidth = this.preScaledWidth 
     = this.width = this.canvas.width; 
    this.originalHeight = this.preScaledHeight 
     = this.height = this.canvas.height; 
    this.hiDPIAdjustments(); 
    if (!this.hasId()) { 
     this.assignId(); 
    } 
    if (this.image != null) { 
     this.context.drawImage(this.image, 0, 0, 
           this.imageWidth(), this.imageHeight(), 0, 
           0, this.preScaledWidth, this.preScaledHeight); 
     } 
    this.imageData = this.context.getImageData(0, 0, 
           this.canvas.width, this.canvas.height); 
    this.pixelData = this.imageData.data; 
    if (Caman.allowRevert) { 
     this.initializedPixelData = Util.dataArray(this.pixelData.length); 
     this.originalPixelData = Util.dataArray(this.pixelData.length); 
     _ref = this.pixelData; 
     for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) { 
      pixel = _ref[i]; 
      this.initializedPixelData[i] = pixel; 
      this.originalPixelData[i] = pixel; 
     } 
    } 
    this.dimensions = { 
     width: this.canvas.width, 
     height: this.canvas.height 
    }; 
    Store.put(this.id, this); 
    this.callback.call(this, this); 
    return this.callback = function() {}; 
} has no method 'bind' at file:///android_asset/www/old/js/caman.full.js:219 

J'utilise cordova 2.8.1.js et caman.full.js, et je l'utilise aussi jquery-1.8.3.min.js et jquery.mobile-1.2.1.min.js si ça aide.

Répondre

0

Il est difficile de dire à partir du code que vous avez donné, mais cela a probablement quelque chose à voir avec votre utilisation de 'ceci' dans this.sunrise(); this.render();. La seule autre chose que je vois est peut-être que vous devez appeler new Caman(...); pour instancier un nouvel objet?

+0

Cela n'a pas fonctionné aussi, j'ai déjà essayé d'insérer une alerte à l'intérieur de la fonction à l'intérieur du Caman et elle n'apparaissait même pas sur mon téléphone portable –

Questions connexes