Conversation
supportHi, I have used the “flat” option for my VR-Stand. Unfortunately, the image has an infinitive scroll. How can I change this so that you can move in the stand but not go over the borders of the image ? For now the image repeats all the time. Thanks in advance for any help! Kind regards, Jeremy Bosquet ECOM LUX The page I need help with: [ log in to see the link]
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
I see, I will try to add this option to the engine and UI as soon as possible
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
I see, I will try to add this option to the engine and UI as soon as possible