Hi,
I am using the sync JavaScript sync plugin/example (https://krpano.com/releases/1.20.5/examples/#js-sync-viewers), but enabling sync on the click of a button (to allow manual alignment of images before syncing).
This seems to work fine when starting on the left pane, but when switching panes, it doesn't seem to catch up immediately and can take a few seconds before it suddenly catches up. I can't seem to reproduce this with the example, so I was just wondering if anyone could see any issues with my usage?
This is the sync button handler logic:
var panoLeft = document.getElementById('left');
var panoRight = document.getElementById('right');
panoLeft.set("sync", true);
panoRight.set("sync", true);
panoLeft.set("syncviewer", "panoRight");
panoRight.set("syncviewer", "panoLeft");
In my xml I have this:
<include url="/plugins/sync.xml" />
<events
onmousedown="events.onviewchange();"
onmousewheel="events.onmousedown();"
onviewchange="update_compass();"
onloaderror="js(return false;)"
/>
and I also have a couple of other plugins included such as radar, compass and showtext but leaving them out for brevity.
Finally, the sync.xml which is really the same but with the added check for the sync being enabled
<events name="sync" keep="true"
onmousedown="sync_to_other_viewer(get(timertick));"
onmousewheel="sync_to_other_viewer(get(timertick));"
oncontextmenu="sync_to_other_viewer(get(timertick));"
onviewchange="sync_to_other_viewer();"
/>
<action name="sync_to_other_viewer" type="Javascript"><![CDATA[
var sync = krpano.get("sync");
var otherviewer = document.getElementById(krpano.get("syncviewer"));
if (otherviewer && otherviewer.get && sync) {
var lastuserinteraction = args[1] | 0;
if (lastuserinteraction) {
krpano.sync_lastuserinteraction = lastuserinteraction;
} else {
lastuserinteraction = krpano.sync_lastuserinteraction | 0;
}
var otherkrpano = otherviewer.get("global");
otherkrpano_lastuserinteraction = otherkrpano.sync_lastuserinteraction | 0;
if (lastuserinteraction > otherkrpano_lastuserinteraction) {
// An internal API call to remove the focus from the other viewer.
// That will stop any movement frictions, release pressed keyboard-keys and close an open contextmenu.
otherkrpano.control.panoControl.focusLoss();
var view1 = otherkrpano.view;
var view2 = krpano.view;
// copy view2 properties to view1