Permalink
Browse files

Have color picker bind to $("html") for mousemove/up

This way a drag initiated inside the canvas still work when you end up
going "outside" the lines of the color picker. Otherwise it can be tedious to
get to the very edge of the color picker.
  • Loading branch information...
1 parent a4dd583 commit c85f98d265513a80d8fef5aa1ae45218ebf61fac @collin committed Feb 3, 2012
Showing with 6 additions and 5 deletions.
  1. +6 −5 lib/components/color-picker/color-picker.js
@@ -1,4 +1,3 @@
-
/**
* Expose `ColorPicker`.
*/
@@ -103,6 +102,7 @@ ColorPicker.prototype.height = function(n){
ColorPicker.prototype.spectrumEvents = function(){
var self = this
, canvas = $(this.spectrum)
+ , application = $("html")
, down;
function update(e) {
@@ -118,11 +118,11 @@ ColorPicker.prototype.spectrumEvents = function(){
update(e);
});
- canvas.mousemove(function(e){
+ application.mousemove(function(e){
if (down) update(e);
});
- canvas.mouseup(function(){
+ application.mouseup(function(){
down = false;
});
};
@@ -136,6 +136,7 @@ ColorPicker.prototype.spectrumEvents = function(){
ColorPicker.prototype.mainEvents = function(){
var self = this
, canvas = $(this.main)
+ , application = $("html")
, down;
function update(e) {
@@ -151,11 +152,11 @@ ColorPicker.prototype.mainEvents = function(){
update(e);
});
- canvas.mousemove(function(e){
+ application.mousemove(function(e){
if (down) update(e);
});
- canvas.mouseup(function(){
+ application.mouseup(function(){
down = false;
});
};

0 comments on commit c85f98d

Please sign in to comment.