meltingice / CamanJS

Javascript HTML5 (Ca)nvas (Man)ipulation
http://camanjs.com
BSD 3-Clause "New" or "Revised" License
3.56k stars 406 forks source link

Problem supplying DOM object as selector #120

Open sta1r opened 11 years ago

sta1r commented 11 years ago

Hi

I'm trying to use a DOM object as a selector when initializing Caman, i.e.

Caman($img, function () {});

instead of

Caman('#image-id', function () {});

With the object, I get the following console error:

Uncaught TypeError: Cannot call method 'toLowerCase' of undefined 

Here's a bigger snippet of code for info:

$('.projects-cluster li').hover( function() {

   $img = $(this).find('img');

   Caman($img, function () {

      this.greyscale();
      this.exposure(30);
      this.colorize('#FF8080', 50);
      this.render();

   });

}

Thanks

bebraw commented 10 years ago

$img gives you a jQuery object by default. I think you may need to extract the DOM object out of it like this:

Caman($img[0], function () {

Hope that helps!