Browse Source

Avoid multiple change events on style property change

pull/2675/head
Artur Arseniev 6 years ago
parent
commit
f96e46302e
  1. 1
      src/domain_abstract/ui/InputColor.js
  2. 9
      src/style_manager/model/Property.js
  3. 6
      src/style_manager/view/PropertiesView.js

1
src/domain_abstract/ui/InputColor.js

@ -97,6 +97,7 @@ export default Input.extend({
changed = 1;
const cl = getColor(color);
cpStyle.backgroundColor = cl;
model.setValueFromInput(0, 0); // for UndoManager
model.setValueFromInput(cl);
self.noneColor = 0;
},

9
src/style_manager/model/Property.js

@ -73,14 +73,7 @@ const Property = Backbone.Model.extend(
*/
setValue(value, complete = 1, opts = {}) {
const parsed = this.parseValue(value);
this.set(parsed, { ...opts, avoidStore: 1 });
// It's important to set an empty value, otherwise the
// UndoManager won't see the change
if (complete) {
this.set('value', '', opts);
this.set(parsed, opts);
}
this.set(parsed, { ...opts, avoidStore: !complete });
},
/**

6
src/style_manager/view/PropertiesView.js

@ -46,11 +46,13 @@ export default Backbone.View.extend({
},
render() {
const { $el } = this;
this.properties = [];
const fragment = document.createDocumentFragment();
this.collection.each(model => this.add(model, fragment));
this.$el.append(fragment);
this.$el.attr('class', `${this.pfx}properties`);
$el.empty();
$el.append(fragment);
$el.attr('class', `${this.pfx}properties`);
return this;
}
});

Loading…
Cancel
Save