Skip to content

Commit

Permalink
Merge pull request #3986 from ProjectMirador/viewer-external-props
Browse files Browse the repository at this point in the history
Allow externally updated props to change the viewer even if OSD is still animating a change.
  • Loading branch information
jcoyne authored Nov 14, 2024
2 parents 7d85ce6 + 27f7a08 commit 38899c8
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions src/components/OpenSeadragonViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export class OpenSeadragonViewer extends Component {
this.onCanvasMouseMove = debounce(this.onCanvasMouseMove.bind(this), 10);
this.onViewportChange = this.onViewportChange.bind(this);
this.zoomToWorld = this.zoomToWorld.bind(this);
this.osdUpdating = false;
}

/**
Expand Down Expand Up @@ -72,14 +71,7 @@ export class OpenSeadragonViewer extends Component {
this.setState({ grabbing: false });
});

// Set a flag when OSD starts animating (so that viewer updates are not used)
viewer.addHandler('animation-start', () => {
this.osdUpdating = true;
});
viewer.addHandler('animation-finish', this.onViewportChange);
viewer.addHandler('animation-finish', () => {
this.osdUpdating = false;
});

if (viewer.innerTracker) {
viewer.innerTracker.moveHandler = this.onCanvasMouseMove;
Expand Down Expand Up @@ -127,7 +119,7 @@ export class OpenSeadragonViewer extends Component {
}
} else if (!isEqual(canvasWorld.layers, prevProps.canvasWorld.layers)) {
this.refreshTileProperties();
} else if (viewerConfig && !this.osdUpdating) {
} else if (viewerConfig !== prevProps.viewerConfig) {
const { viewport } = viewer;

if (viewerConfig.x !== viewport.centerSpringX.target.value
Expand Down

0 comments on commit 38899c8

Please sign in to comment.