Reputation: 228
I'm building a responsive image viewer, incorporating OpenSeaDragon, that requires different panning behaviour at different screen widths. At narrow widths panning should not be allowed, but when the window's wider, panning should be activated.
A simplified example follows:
Let's assume the window is fairly wide, then the panning options during initialisation will be:
OpenSeaDragon({ panHorizontal: true, panVertical: true, ... });
(I understand these are the defaults, but including them here for clarity.)
I can then detect whether panning should be activated/deactivated using matchMedia
inside a window resize event handler, something like:
// (Crude example, resize would need debouncing etc)
window.addEventListener('resize', function () {
if (window.matchMedia('(min-width:800px)').matches) {
// allow panning
} else {
// prevent panning
}
});
My question is, can the panning constraint options provided when OpenSeaDragin is initialised be changed later, without having to reinitialise the viewer? Failing that, is there a different way of getting the same effect? I've had a dig into the OpenSeaDragon docs and code but I can't see a way of doing it.
Upvotes: 0
Views: 414
Reputation: 2174
Yes, you can change those properties directly without having to reinitialize, like so:
var viewer = OpenSeaDragon({ panHorizontal: true, panVertical: true, ... });
viewer.panHorizontal = false;
Upvotes: 1