Created
February 9, 2011 23:37
-
-
Save namlet/819586 to your computer and use it in GitHub Desktop.
Maintain selection coordinates using a closure. This example using jQuery.
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 boxCoord = function(endCoord) { | |
var coord = endCoord; | |
return function(anotherCoord) { | |
return [anotherCoord, coord]; | |
} | |
} | |
$('body').mousedown(function(e){ | |
var thate = e; | |
$(this).mouseup(function(e){ | |
var box = boxCoord([e.pageX,e.pageY])([thate.pageX,thate.pageY]); | |
console.log(box); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
mouseup.box is namespacing. That way when you unbind it, it only removes the handlers specifically registered with that namespace, mouseup.box.