Merge pull request #7291 from waldeck-dev/issue/4720

Cache hue value locally on ColorPicker
pull/7377/head
Tuğçe Küçükoğlu 2025-03-04 15:42:50 +03:00 committed by GitHub
commit 735f7fcc2a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 2 deletions

View File

@ -39,6 +39,7 @@ export default {
};
},
hsbValue: null,
localHue: null,
outsideClickListener: null,
documentMouseMoveListener: null,
documentMouseUpListener: null,
@ -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
});
@ -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
});
@ -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) {