You are not logged in.

Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

nautama

Trainee

  • "nautama" started this thread

Posts: 82

Location: La Paz, Baja California Sur, México

Occupation: KRpano programmer at www.imagen360.com

  • Send private message

1

Thursday, April 30th 2015, 6:34pm

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:

Source code

1
2
3
4
5
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.

JPG_master

Beginner

Posts: 20

Location: Deutschland

Occupation: IT Manager

  • Send private message

2

Saturday, May 2nd 2015, 5:37pm

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

Source code

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


and inside XML:

Source code

1
2
3
4
5
6
<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*

3

Friday, May 8th 2015, 1:32pm

Hi,

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

Either use the onready callback and change it there:
http://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:
http://krpano.com/docu/html/#mobilescale

Best regards,
Klaus