js panorama's on the fly

  • I need to create js panorama's via mouse events but it doesn't work.

    I do:

    Code
    var viewer = createPanoViewer({
    	 // bunch of variables
    });
    viewer.useHTML5('always');
    viewer.embed();

    This works fine when initialising the page but not when fired at a later point. I suspected a load event and on further inspection there's 'window.addEventListener("load",.....' on ln30 col325 of krpano.js (1.0.8.12).

    Is there any reason why the js pano's have to be initialised on load?
    The Flash version works without onload so it would be nice to have this working similarly.

    I've succesfully tested it by adding a boolean and a load function switching that boolean:

    Code
    var bLoadEventHasFired = false;
    window.addEventListener("load", function(e){bLoadEventHasFired=true;}, false);


    then, where the function was added to the load event I first put the function in a var then executed or added to event listener depending on previously created boolean:

    Code
    var fnLoad = function () {(...)}; // the function that was added to the load event
    if (bLoadEventHasFired) fnLoad();
    else window.addEventListener("load", fnLoad, false)

    gr

    Ron

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!