Skip to content

Commit

Permalink
Cache hue value locally on ColorPicker
Browse files Browse the repository at this point in the history
Signed-off-by: Valentin <valentin@waldeck.dev>
  • Loading branch information
waldeck-dev committed Feb 20, 2025
1 parent 1a74875 commit 1293efc
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/primevue/src/colorpicker/ColorPicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default {
};
},
hsbValue: null,
localHue: null,
outsideClickListener: null,
documentMouseMoveListener: null,
documentMouseUpListener: null,
Expand Down Expand Up @@ -91,7 +92,7 @@ export default {
let brightness = Math.floor((100 * (150 - Math.max(0, Math.min(150, (event.pageY || event.changedTouches[0].pageY) - top)))) / 150);
this.hsbValue = this.validateHSB({
h: this.hsbValue.h,
h: this.localHue,
s: saturation,
b: brightness
});
Expand All @@ -103,9 +104,10 @@ export default {
},
pickHue(event) {
let top = this.hueView.getBoundingClientRect().top + (window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0);
this.localHue = Math.floor((360 * (150 - Math.max(0, Math.min(150, (event.pageY || event.changedTouches[0].pageY) - top)))) / 150);
this.hsbValue = this.validateHSB({
h: Math.floor((360 * (150 - Math.max(0, Math.min(150, (event.pageY || event.changedTouches[0].pageY) - top)))) / 150),
h: this.localHue,
s: 100,
b: 100
});
Expand Down Expand Up @@ -341,6 +343,12 @@ export default {
hsb = this.HEXtoHSB(this.defaultColor);
}
if (this.localHue == null) {
this.localHue = hsb.h;
} else {
hsb.h = this.localHue;
}
return hsb;
},
onOverlayEnter(el) {
Expand Down

0 comments on commit 1293efc

Please sign in to comment.