Skip to content

Instantly share code, notes, and snippets.

@HenningCash
Created August 16, 2014 13:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HenningCash/a60cf0db240119d9dcd8 to your computer and use it in GitHub Desktop.
Save HenningCash/a60cf0db240119d9dcd8 to your computer and use it in GitHub Desktop.
Snap.svg alternate click plugin
/**
* Use like .click() but accepts a second callback
*
* example:
* element.alternateClick(function() {}, function() {});
*/
Snap.plugin(function(Snap, Element) {
Element.prototype.alternateClick = function(first, second) {
var i = 0;
this.click(function() {
if(i++ % 2 === 0) {
first();
}
else {
second();
}
});
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment