Problem mit Orientation-Weiche

  • Hi!

    Ich möchte je nach Bildschirmorientierung ein anderes Panorama laden.

    Dafür verwende ich den folgenden Code:

    Prinzipiell funktioniert das auch schon.

    Am Computer lädt ganz wie gewünscht das landscape Panorama.

    Auch am Handy wird das jeweils richtige Panorama geladen.

    Nur tritt bei mobilen Geräten dieses Problem auf:
    Lädt man das Panorama, wird die richtige Version geladen und sofort blinkt der Bildschirm für einen Sekundenbruchteil schwarz auf und das Panorama wird erneut geladen. Als würde das Panorama direkt hintereinander doppelt geladen werden.

    Hat jemand eine Idee

    Vielen Dank!
    Liebe Grüße
    S.

  • Code
    <krpano>
    <events name="loadpano" keep="true" onresize="onresize_loadpano();" />
    <action name="onresize_loadpano" scope="local">
    	calc(local.check, stagewidth LT stageheight); // is portrait?
    	if(global.last_check != check, // not the same as last onresize?
    		if(check, loadpano(portrait.xml), loadpano(landscape.xml));
    		copy(global.last_check, check); // update global
    	);
    </action>
    </krpano>

    maybe that works :)

    onresize can be called multiple times, specially on desktop when changing the window size
    here check is a boolean true/false for portrait/landscape

  • Hi,

    any special reason why you use loadpano and not just scenes?
    That would make things much simpler.

    Tuur *thumbsup*

  • Thanks for your replies guys!

    Code
    <krpano>
    <events name="loadpano" keep="true" onresize="onresize_loadpano();" />
    <action name="onresize_loadpano" scope="local">
    	calc(local.check, stagewidth LT stageheight); // is portrait?
    	if(global.last_check != check, // not the same as last onresize?
    		if(check, loadpano(portrait.xml), loadpano(landscape.xml));
    		copy(global.last_check, check); // update global
    	);
    </action>
    </krpano>

    maybe that works :)

    onresize can be called multiple times, specially on desktop when changing the window size
    here check is a boolean true/false for portrait/landscape

    Actually not. This ends in an endless loop of reloading the panorama *blink*


    Hi,

    any special reason why you use loadpano and not just scenes?
    That would make things much simpler.

    Tuur *thumbsup*

    Both panos have multiple actions with hundreds of lines and also are complete diffrent images - so I don't think scenes are the right thing to go here?

  • Hey there,

    got it solved by checking if the orientation has changed instead of loading the panorama whenever the screensize is changed.

    Not to tidy but working.

    Thanks for your help!

  • Quote

    Both panos have multiple actions with hundreds of lines and also are complete diffrent images - so I don't think scenes are the right thing to go here?

    that really depends of course..
    I can't remember not using scenes, besides 1-2 special cases.
    besides that..
    you could also use an xml file for every scene or chapter or whatever.

    Maybe you can share a link or your code?
    Perhaps in PM.

    Tuur *thumbsup*

Participate now!

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