CreateApp - Fix active colorPicker to update on selection update

This commit is contained in:
Thijs Wenker 2019-01-07 20:35:09 +01:00
parent 8acae02203
commit 7d9cad3e8e

View file

@ -2151,7 +2151,6 @@ function createColorProperty(property, elProperty) {
submit: false, // We don't want to have a submission button
onShow: function(colpick) {
console.log("Showing");
$(colorPickerID).attr('active', 'true');
// The original color preview within the picker needs to be updated on show because
// prior to the picker being shown we don't have access to the selections' starting color.
colorPickers[colorPickerID].colpickSetColor({
@ -2159,13 +2158,17 @@ function createColorProperty(property, elProperty) {
"g": elNumberG.elInput.value,
"b": elNumberB.elInput.value
});
$(colorPickerID).attr('active', 'true');
},
onHide: function(colpick) {
$(colorPickerID).attr('active', 'false');
},
onChange: function(hsb, hex, rgb, el) {
$(el).css('background-color', '#' + hex);
emitColorPropertyUpdate(propertyName, rgb.r, rgb.g, rgb.b);
if ($(colorPickerID).attr('active') === 'true') {
emitColorPropertyUpdate(propertyName, rgb.r, rgb.g, rgb.b);
}
}
});
@ -3351,6 +3354,16 @@ function loaded() {
property.elColorPicker.style.backgroundColor = "rgb(" + propertyValue.red + "," +
propertyValue.green + "," +
propertyValue.blue + ")";
if ($(property.elColorPicker).attr('active') === 'true') {
$(property.elColorPicker).attr('active', 'false');
colorPickers['#' + property.elementID].colpickSetColor({
"r": propertyValue.red,
"g": propertyValue.green,
"b": propertyValue.blue
});
$(property.elColorPicker).attr('active', 'true');
}
property.elNumberR.setValue(propertyValue.red);
property.elNumberG.setValue(propertyValue.green);
property.elNumberB.setValue(propertyValue.blue);