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.

1

Wednesday, November 27th 2019, 3:28pm

Problem mit Orientation-Weiche

Hi!

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

Dafür verwende ich den folgenden Code:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<krpano>

<events name="onresize_changes_only" keep="true"
        onresize="
            if(last_stagewidth != stagewidth OR last_stageheight != stageheight,
               events.dispatch('onresizeonly');
            );
            copy(last_stagewidth, stagewidth);
            copy(last_stageheight, stageheight);
            "
        />

<events onresizeonly="loadit();" />

<action name="loadit">
if(stagewidth GT stageheight, loadpano(landscape.xml), loadpano(portrait.xml));
</action>

</krpano>


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.

2

Wednesday, November 27th 2019, 4:28pm

Source code

1
2
3
4
5
6
7
8
9
10
<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

Tuur

Sage

Posts: 3,205

Location: Netherlands

Occupation: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer

  • Send private message

3

Wednesday, November 27th 2019, 4:40pm

Hi,

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

Source code

1
2
3
4
5
6
7
8
9
10
    <events name="orient" keep="true" devices="mobile" onresize="Orientation();" />    
    <action name="Orientation" > 
        if(stagewidth LT stageheight,
<!-- portrait -->
               set(layer[pic].y, 30);
        ,
               set(layer[pic].y, 10);
        );

    </action>


Tuur *thumbsup*
http://www.virtualtuur.com
Skype:studiotuur

4

Wednesday, November 27th 2019, 4:46pm

Thanks for your replies guys!

Source code

1
2
3
4
5
6
7
8
9
10
<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.

Source code

1
2
3
4
5
6
7
8
9
10
    <events name="orient" keep="true" devices="mobile" onresize="Orientation();" />    
    <action name="Orientation" > 
        if(stagewidth LT stageheight,
<!-- portrait -->
               set(layer[pic].y, 30);
        ,
               set(layer[pic].y, 10);
        );

    </action>


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?

5

Wednesday, November 27th 2019, 5:20pm

delete

This post has been edited 1 times, last edit by "s-maier" (Nov 27th 2019, 5:58pm)


6

Wednesday, November 27th 2019, 5:55pm

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!

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<krpano>

<events name="onresize_changes_only" keep="true"
        onresize="
			if(stagewidth/stageheight GT 1, set(ratio, 'landscape'), set(ratio, 'portrait'));
			
            if(last_ratio != ratio,
               events.dispatch('onresizeonly');
            );
            copy(last_stagewidth, stagewidth);
            copy(last_stageheight, stageheight);
			copy(last_ratio, ratio);
            "
        />

<events onresizeonly="loadit();" />

<action name="loadit">
if(stagewidth GT stageheight, loadpano(landscape.xml), loadpano(portrait.xml));
</action>

</krpano>

Tuur

Sage

Posts: 3,205

Location: Netherlands

Occupation: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer

  • Send private message

7

Wednesday, November 27th 2019, 6:29pm

Quoted

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*
http://www.virtualtuur.com
Skype:studiotuur