Skip to content

Commit

Permalink
The picker stays in the same place when the hue slider is moved
Browse files Browse the repository at this point in the history
When the hue slider is moved, two colors are now created. One fully saturated and bright value for the picker area, and one color where only the Hue from the HSV triplet has been changed. The latter is used for the callbacks.

Additionally, the picker dot is no longer moved to the top right corner when the hue slider is moved.
  • Loading branch information
edelooff committed Jun 6, 2013
1 parent b604b7d commit 3cffb07
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions colorpicker.js
Expand Up @@ -188,9 +188,9 @@
evt = evt || window.event;
var mouse = mousePosition(evt);
ctx.h = mouse.y / slideElement.offsetHeight * 360 + hueOffset;
ctx.s = ctx.v = 1;
var c = hsv2rgb({ h: ctx.h, s: 1, v: 1 });
pickerElement.style.backgroundColor = c.hex;
var pickerColor = hsv2rgb({ h: ctx.h, s: 1, v: 1 });
var c = hsv2rgb({ h: ctx.h, s: ctx.s, v: ctx.v });
pickerElement.style.backgroundColor = pickerColor.hex;
ctx.callback && ctx.callback(c.hex, { h: ctx.h - hueOffset, s: ctx.s, v: ctx.v }, { r: c.r, g: c.g, b: c.b }, undefined, mouse);
}
};
Expand Down Expand Up @@ -423,9 +423,6 @@
ColorPicker.positionIndicators = function(slideIndicator, pickerIndicator, mouseSlide, mousePicker) {

if (mouseSlide) {
pickerIndicator.style.left = 'auto';
pickerIndicator.style.right = '0px';
pickerIndicator.style.top = '0px';
slideIndicator.style.top = (mouseSlide.y - slideIndicator.offsetHeight/2) + 'px';
}
if (mousePicker) {
Expand Down

0 comments on commit 3cffb07

Please sign in to comment.