Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Open
wants to merge 1 commit into from

2 participants

@collin

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.

@collin collin 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.
c85f98d
@tj
Owner
tj commented

we should add some bounds checking too since it kinda goes wonky if you drag out, it would be a lot nicer if we lock it in the rect

@collin

Yes, maybe use Math.min and Math.max in the update function to keep things inside the canvas? Or is there a better place to put it?

@tj
Owner
tj commented

yup that should be fine

@tj tj referenced this pull request
Closed

Color picker mouse out events #24

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 3, 2012
  1. @collin

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

    collin authored
    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.
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 5 deletions.
  1. +6 −5 lib/components/color-picker/color-picker.js
View
11 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;
});
};
Something went wrong with that request. Please try again.