Don't recursively update drawer if settings are being changed.

This commit is contained in:
Joachim Bauch 2021-12-17 10:26:50 +01:00
parent b97145adbb
commit 085f421955
No known key found for this signature in database
GPG key ID: 77C1D22D53E15F02

View file

@ -829,7 +829,9 @@ function Annotator(socketurl, id, userid, displayname, token) {
this.storage.set('color', this.color); this.storage.set('color', this.color);
$(".modeButton.colorMode, .modeButton.colorMode:focus") $(".modeButton.colorMode, .modeButton.colorMode:focus")
.css("background-color", this.color); .css("background-color", this.color);
this.drawer.updateSettings(PageAnnotator.prototype.__active); if (!this._updating_settings) {
this.drawer.updateSettings(PageAnnotator.prototype.__active);
}
}.bind(this); }.bind(this);
this.colorPicker.on("color:init", setColor); this.colorPicker.on("color:init", setColor);
this.colorPicker.on("color:change", setColor); this.colorPicker.on("color:change", setColor);
@ -840,7 +842,9 @@ function Annotator(socketurl, id, userid, displayname, token) {
var strokeWidth = parseStrokeWidth(e.target.value); var strokeWidth = parseStrokeWidth(e.target.value);
this.storage.set('strokeWidth', strokeWidth); this.storage.set('strokeWidth', strokeWidth);
this.strokeWidth = strokeWidth; this.strokeWidth = strokeWidth;
this.drawer.updateSettings(PageAnnotator.prototype.__active); if (!this._updating_settings) {
this.drawer.updateSettings(PageAnnotator.prototype.__active);
}
}.bind(this)); }.bind(this));
$('#inputStrokeWidth').on('change', function(e) { $('#inputStrokeWidth').on('change', function(e) {
@ -921,6 +925,7 @@ function Annotator(socketurl, id, userid, displayname, token) {
} }
Annotator.prototype.updateSettings = function(settings) { Annotator.prototype.updateSettings = function(settings) {
this._updating_settings = true;
var prev = { var prev = {
'color': this.colorPicker.color.hex8String, 'color': this.colorPicker.color.hex8String,
'strokeWidth': this.strokeWidth, 'strokeWidth': this.strokeWidth,
@ -928,6 +933,7 @@ Annotator.prototype.updateSettings = function(settings) {
this.colorPicker.color.hex8String = settings.color; this.colorPicker.color.hex8String = settings.color;
$('#inputStrokeWidth').val(settings.strokeWidth); $('#inputStrokeWidth').val(settings.strokeWidth);
$('#strokeWidthValue').text($('#inputStrokeWidth').val()); $('#strokeWidthValue').text($('#inputStrokeWidth').val());
this._updating_settings = false;
return prev; return prev;
}; };