When setting the value for the color picker, round it to the closest available value in the layout

This commit is contained in:
Keegan
2016-03-15 04:53:58 +11:00
parent dad8b2a025
commit 4ee5a7361c
3 changed files with 171 additions and 11 deletions
+3 -7
View File
@@ -145,16 +145,12 @@ module.exports = {
},
color: {
get: function() {
return parseInt(this.$manipulatorTarget.get('value'), 16);
return parseInt(this.$manipulatorTarget.get('value'), 10) || 0;
},
set: function(value) {
switch (typeof value) {
case 'number': value = value.toString(16); break;
case 'string': value = value.replace(/^#|^0x/, ''); break;
}
value = value || '000000';
value = this.roundColorToLayout(value || 0);
if (this.get() === parseInt(value, 16)) { return this; }
if (this.get() === value) { return this; }
this.$manipulatorTarget.set('value', value);
return this.trigger('change');
},