Try this code inside the custom js section. If it will be ok for your case I can add this as a new scene option in next release
const plugin = this;
const $ = jQuery;
let activeScene = null;
let containerWidth = plugin.$container.width();
const lockMoving = (event) => {
let pos = activeScene.control.getPosition();
let zoom = activeScene.control.getZoom();
const zoomThreshhold = 2;
let fix = false;
if(zoom > zoomThreshhold) { zoom = zoomThreshhold; fix = true; }
if(fix) {
activeScene.control.removeEventListener('change', lockMoving);
activeScene.control.setZoom(zoom);
activeScene.control.addEventListener('change', lockMoving);
}
const posThreshhold = (activeScene.control.imageSize.width * zoom)/2 - containerWidth/2;
fix = false;
if(pos.x < -posThreshhold) { pos.x = -posThreshhold; fix = true; }
else if(pos.x > posThreshhold) { pos.x = posThreshhold; fix = true; }
if(fix) {
activeScene.control.removeEventListener('change', lockMoving);
activeScene.control.setPosition(pos.x, pos.y);
activeScene.control.addEventListener('change', lockMoving);
}
}
plugin.$container.on('ipanorama:scene-before-load', (e, data) => {
if(activeScene && activeScene.cfg.type == 'flat') {
activeScene.control.removeEventListener('change', lockMoving);
}
activeScene = data.scene;
if(activeScene.cfg.type == 'flat') {
activeScene.control.addEventListener('change', lockMoving);
}
});
$(window).on('resize', () => {
containerWidth = plugin.$container.width();
});