From aca983fd431e790203591a3ee4b945f6fc66061c Mon Sep 17 00:00:00 2001 From: David Manthey Date: Tue, 31 May 2022 12:25:21 -0400 Subject: [PATCH] Reduce the chance of blinking on annotation layers. When the base image is panned, sometimes an update occurs before the reset features are updated. This forces the update sooner. --- .../web_client/views/imageViewerWidget/geojs.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/girder_annotation/girder_large_image_annotation/web_client/views/imageViewerWidget/geojs.js b/girder_annotation/girder_large_image_annotation/web_client/views/imageViewerWidget/geojs.js index 42d5d58e8..f925662f2 100644 --- a/girder_annotation/girder_large_image_annotation/web_client/views/imageViewerWidget/geojs.js +++ b/girder_annotation/girder_large_image_annotation/web_client/views/imageViewerWidget/geojs.js @@ -251,6 +251,7 @@ var GeojsImageViewerWidgetExtension = function (viewer) { const overlays = annotation.overlays() || []; var present = _.has(this._annotations, annotation.id); var centroidFeature; + let immediateUpdate = false; if (present) { _.each(this._annotations[annotation.id].features, (feature, idx) => { if (idx || !annotation._centroids || feature.data().length !== annotation._centroids.data.length) { @@ -258,6 +259,7 @@ var GeojsImageViewerWidgetExtension = function (viewer) { feature.layer().map().deleteLayer(feature.layer()); } else { this.featureLayer.deleteFeature(feature); + immediateUpdate = true; } } else { centroidFeature = feature; @@ -417,7 +419,7 @@ var GeojsImageViewerWidgetExtension = function (viewer) { }); }); this._featureOpacity[annotation.id] = {}; - geo.createFileReader('jsonReader', {layer: this.featureLayer}) + geo.createFileReader('geojsonReader', {layer: this.featureLayer}) .read(geojson, (features) => { if (features.length === 0) { features = annotation.non_geojson(this.featureLayer); @@ -482,6 +484,9 @@ var GeojsImageViewerWidgetExtension = function (viewer) { } this.viewer.scheduleAnimationFrame(this.viewer.draw, true); }); + if (immediateUpdate) { + this.featureLayer._update(); + } }, /**