Created
March 20, 2015 18:33
-
-
Save devcem/fe0c1ca2a216a3f34a26 to your computer and use it in GitHub Desktop.
Just click
This file contains 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 lastEvent;(function($) {$.fn.justClick = function(callback) {this.bind('mousemove mousedown mouseup', function(e) {if(e.type == 'mouseup' && lastEvent == 'mousedown'){callback()}lastEvent = e.type;});}}(jQuery)); | |
$('#obj').justClick(function(){ | |
console.log("Not move, not drag. It is just click!"); | |
}); | |
//Similar threads | |
//http://stackoverflow.com/questions/1572483/jquery-mousedown-mousemove | |
//http://stackoverflow.com/questions/2928161/binding-mousemove-within-mousedown-function-with-jquery |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment