Skip to content

Commit

Permalink
Hook up a double-click handler for OSD to handle zooming
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Nov 14, 2024
1 parent 27f7a08 commit 7f6d21a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/components/OpenSeadragonViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ export class OpenSeadragonViewer extends Component {

this.setState({ viewer });

viewer.addHandler('canvas-double-click', ({ position, shift }) => {
const currentZoom = viewer.viewport.getZoom();
const zoomRatio = (shift ? 1.0 / osdConfig.zoomPerDoubleClick : osdConfig.zoomPerDoubleClick);

Check failure on line 68 in src/components/OpenSeadragonViewer.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Multiple spaces found before '('

Check failure on line 68 in src/components/OpenSeadragonViewer.js

View workflow job for this annotation

GitHub Actions / build (20.x)

Multiple spaces found before '('
viewer.viewport.zoomTo(currentZoom * zoomRatio, viewer.viewport.pointFromPixel(position), false);
});

viewer.addHandler('canvas-drag', () => {
this.setState({ grabbing: true });
});
Expand Down
4 changes: 3 additions & 1 deletion src/config/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ export default {
isWorkspaceAddVisible: false, // Catalog/Workspace add window feature visible by default
exposeModeOn: false, // unused?
height: 5000, // height of the elastic mode's virtual canvas
showZoomControls: false, // Configure if zoom controls should be displayed by default
showZoomControls: true, // Configure if zoom controls should be displayed by default
type: 'mosaic', // Which workspace type to load by default. Other possible values are "elastic". If "mosaic" or "elastic" are not selected no worksapce type will be used.
viewportPosition: { // center coordinates for the elastic mode workspace
x: 0,
Expand All @@ -545,6 +545,8 @@ export default {
preserveImageSizeOnResize: true,
preserveViewport: true,
showNavigationControl: false,
zoomPerClick: 1, // disable zoom-to-click
zoomPerDoubleClick: 2.0
},
export: {
catalog: true,
Expand Down

0 comments on commit 7f6d21a

Please sign in to comment.