Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
renderLayout() {
const { world } = this.viewer
const { mangaMode, bookMode } = this.props
const pos = new OpenSeaDragon.Point(0, 0)
const count = world.getItemCount()
// Cache tile data
let bounds = null
// first page
let firstPage = null
let firstPageIndex = bookMode && mangaMode && count > 1 ? 1 : 0
let firstPageBounds = null
// Next page
let nextPage = null
let nextPageBounds = null
let nextPageIndex = bookMode && mangaMode ? 0 : 1
if (count > 0) {
// Page view (single page)
firstPage = world.getItemAt(firstPageIndex)
resize(viewer) {
const { canvas } = this.props;
const firstImage = viewer.world.getItemAt(0);
if (!firstImage) {
return;
}
const imgWidth = canvas.getWidth();
const imgHeight = canvas.getHeight();
const imgAspectRatio = imgWidth / imgHeight;
const boundsRect = viewer.viewport.getBounds(true);
const viewportOrigin = new OpenSeadragon.Point(
boundsRect.x,
boundsRect.y * imgAspectRatio
);
const viewportWidth = boundsRect.width;
const viewportHeight = boundsRect.height * imgAspectRatio;
// Redraw
const viewportZoom = viewer.viewport.getZoom(true);
const zoom = firstImage.viewportToImageZoom(viewportZoom);
const imageRatio =
(firstImage._scaleSpring.current.value *
firstImage.viewport._containerInnerSize.x) /
firstImage.source.dimensions.x;
const isZoomedOut =
createRelativePoint(x: number, y: number): ?OpenSeadragon.Point {
if (!this.viewer) {
return null;
}
return this.viewer.viewport.viewerElementToImageCoordinates(
new OpenSeadragon.Point(x, y)
);
}
createViewportPoint(x: number, y: number) {
if (!this.viewer) {
return null;
}
return this.viewer.viewport.imageToViewerElementCoordinates(
new OpenSeadragon.Point(x, y)
);
}
createRelativePoint(x, y) {
return this.viewer.viewport.viewerElementToImageCoordinates(
new OpenSeadragon.Point(x, y),
);
}
panTo(x, y) {
this.viewer.viewport.panTo(new OpenSeadragon.Point(x, y));
}
createViewportPoint(x, y) {
return this.viewer.viewport.imageToViewerElementCoordinates(
new OpenSeadragon.Point(x, y),
);
}
panTo(x: number, y: number, speed: number) {
this.viewportAction('panTo', [new OpenSeadragon.Point(x, y)], speed);
}