Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a double-click handler for OSD to handle zooming instead of click-to-zoom #3987

Merged
merged 1 commit into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
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
Loading