Created
November 5, 2013 15:44
-
-
Save sta1r/7321052 to your computer and use it in GitHub Desktop.
Caman hover states
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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