Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
goToRect(
{ x, y, width, height }: Bounds,
padding: number = 0,
speed: number
) {
if (!this.viewer) {
return null;
}
const selectHighlight = this.viewer.viewport.imageToViewportRectangle(
new OpenSeadragon.Rect(
x - padding / 2,
y - padding / 2,
width + padding,
height + padding,
0
)
);
this.viewportAction('fitBounds', [selectHighlight, speed === null], speed);
}
return new Promise((resolve, reject) => {
if (!this.viewer) {
return;
}
this.viewer.addTiledImage({
error: event => reject(event),
fitBounds: new OpenSeadragon.Rect(
...canvasWorld.canvasToWorldCoordinates(i),
),
success: event => resolve(event),
tileSource,
});
});
}
fitBounds(x, y, w, h, immediately = true) {
this.viewer.viewport.fitBounds(
new OpenSeadragon.Rect(x, y, w, h),
immediately,
);
}
goToRect({ x, y, width, height }, padding = 0) {
const selectHighlight = this.viewer.viewport.imageToViewportRectangle(new OpenSeadragon.Rect(
x - (padding / 2),
y - (padding / 2),
width + padding,
height + padding,
0
));
this.viewer.viewport.fitBounds(selectHighlight);
}