From c85f98d265513a80d8fef5aa1ae45218ebf61fac Mon Sep 17 00:00:00 2001 From: Collin T Miller Date: Fri, 3 Feb 2012 12:15:33 -0600 Subject: [PATCH] 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. --- lib/components/color-picker/color-picker.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/components/color-picker/color-picker.js b/lib/components/color-picker/color-picker.js index 03d4da0..ccc5bb4 100644 --- a/lib/components/color-picker/color-picker.js +++ b/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; }); };