Skip to content

Instantly share code, notes, and snippets.

@sta1r
Created November 5, 2013 15:44
Show Gist options
  • Select an option

  • Save sta1r/7321052 to your computer and use it in GitHub Desktop.

Select an option

Save sta1r/7321052 to your computer and use it in GitHub Desktop.
Caman hover states
var imgArray = $('.projects-cluster img');
var size = imgArray.length;
var canvasArray = [];
// loop through images, render them to canvas on document ready (user won't notice)
imgArray.each( function(index, value) {
Caman(this, function () {
this.render( function() {
// once all images are rendered to canvas, fire the doCaman() function
if (index == size - 1) {
doCaman();
}
});
});
});
// hover states on rendered canvas objects
function doCaman() {
$('.projects-cluster canvas').each( function(index, value) {
$(this).hover( function() {
Caman(this, function () {
this.greyscale();
this.exposure(30);
this.colorize('#FF8080', 50);
this.render();
});
}, function() {
Caman(this, function () {
this.revert();
});
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment