Sync Plugin - Lag When Switching Panes

  • 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

  • Digging deeper in to it, I'm a bit confused about how the sync plugin works internally.

    I've tried debugging by printing to the console but a few things have came up, such as the kr pano ids are numerical only, when I have named them 'spherical-left-5' and 'spherical-right-4', but logging both krpano objects, both have an id of 5.

    The syncviewer property seems to be correct for each, so I am checking that and printing out the opposite side and I get both sides appearing when I assumed it'd be only the side I'm currently interacting with (screenshot attached), but I think this is meant to happen since the internal api will be making changes to the left and then subsequently the right, which makes sense, but I am just confused on how I can reliably determine which side has been interacted with most recently, or why the existing logic that's already there doesn't quite work sometimes when switching panes.

    Cheers,
    Martin

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!