Modifying KRPANO variables from the HTML through JS

  • Hello, I'm trying to dynamically modify krpano variables from a HTML embed window through JS but don't know how should I do this. The variables I'd like to modify (rewrite) are the "stagescale", which is an attribute of the <krpano> element, and the "mousetype" variable, which lives inside the <control> element. ¿Any ideas on how to achieve this?

    When I create de viewer is where I'd like to modify the "mousetype" variable, but since it doesn't live inside the krpano element I have my doubts:

    Code
    var viewer = createPanoViewer({swf:"tour.swf", id:"krpanoSWFObject", html5:"always", html5licenseload:false});
    	viewer.addVariable("xml", "tour.xml");
    	viewer.addVariable("stagescale", ".45");
    	viewer.addVariable("simulatedevice", "iphone");
    	viewer.embed("krpanoDIV");

    Once generated I'd like to modify the stagescale without reloading the viewer.

    Thank yo guys, very much guys.

  • Nautama,

    whe I understand this correct:

    When I create de viewer is where I'd like to modify the "mousetype" variable, but since it doesn't live inside the krpano element I have my doubts:

    you would like to dynamically - means from HTML - want to modify more values than given in your "embed" example.

    I only see a chance with the <krpano onstart= ...> action.

    I use the following

    Code
    if( GetStartParam('teasermode')) viewer.addVariable("_br360.teasermode", GetStartParam('teasermode'));
    viewer.addVariable("_br360.teaser_alt-pano", "file:///......./MASTER.html");

    and inside XML:

    Code
    <action name="XYZ"> 
    if ( _br360.teasermode == ON, 
    ...
    
    
    txtadd(onclickstring, 'openurl(', get( _br360.teaser_alt-pano ) ,', _blank); ');
    set( layer[ clickpane ].onclick, get( onclickstring ) );

    This PUSHES the values to the viewer.
    So you can pass values, but - so my thoughts - but not anymore AFTER the embed statment.

    You would have to embed a JS function, that "PULLS" Values called from krpano actions while viewer executes - compare Klaus examples under "javascript-interface" and "js-sync xxx".
    Did that help?

    cheers

    Honi soit qui mal y pense ! *thumbup*

  • Hi,

    the stagescale setting is special one that can't be set on embedding.

    Either use the onready callback and change it there:
    https://krpano.com/docu/html/#onready
    but note - in older Webkit-based Android browsers the stagescale can have different values than just 0.5 and 1.0!

    An new possibility with version 1.19 is the 'mobilescale' embedding setting to adjust the scaling on mobiles devices directly:
    https://krpano.com/docu/html/#mobilescale

    Best regards,
    Klaus

Participate now!

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