Image has infinitive scroll | WordPress.org

[ad_1]

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();
});

Hi @avirtum,

Thank you so much for this fast support.

It indeed resolved my issue! And yes I think this would be great.

Kind regards,

Jeremy Bosquet

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer