Skip to content

Commit

Permalink
Reduce the chance of blinking on annotation layers.
Browse files Browse the repository at this point in the history
When the base image is panned, sometimes an update occurs before the
reset features are updated.  This forces the update sooner.
  • Loading branch information
manthey committed May 31, 2022
1 parent 0b763e5 commit aca983f
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -251,13 +251,15 @@ 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) {
if (feature._ownLayer) {
feature.layer().map().deleteLayer(feature.layer());
} else {
this.featureLayer.deleteFeature(feature);
immediateUpdate = true;
}
} else {
centroidFeature = feature;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -482,6 +484,9 @@ var GeojsImageViewerWidgetExtension = function (viewer) {
}
this.viewer.scheduleAnimationFrame(this.viewer.draw, true);
});
if (immediateUpdate) {
this.featureLayer._update();
}
},

/**
Expand Down

0 comments on commit aca983f

Please sign in to comment.