How to ask user to change orientation to portrait if he/she rotates phone to landscape mode

@DBear
As usual You create such elegant solutions: In a small bit of code the need for checking for mobile devices is removed; the scene notice (i.e. scene named “alert”) is far better than creating an extra layout per scene, or even (as I was going to suggest), using a persistent symbol for the warning.

There is one thing in your coding that I felt penalized viewers. If they are deep in the scene navigation and, for what ever reason, rotate their device to landscape - your code requires them to start from scratch. No matter of consequence if returning to the scene is a click away (e.g. a button~menu selection) but if it is a progressive endeavor, it might be frustrating. The attached example let’s the viewer return to the scene at which they rotated their device to landscape - otherwise everything else is your code.

orientationTest_v4.hype.zip (51.9 KB)

Note: There is no "location.reload();" as in your code - I just return to the “var bookmarkScene” - (hypeDocument.showSceneNamed(bookmarkScene) which seems to work.

var bookmarkScene = hypeDocument.currentSceneName();
	if (window.innerWidth > window.innerHeight && window.innerWidth < 1200 && V==0) {
	        hypeDocument.showSceneNamed('alert');
	        V++;
	}
	  window.addEventListener('orientationchange', function() {
	  hypeDocument.showSceneNamed(bookmarkScene);	
	});  

===========

Separately:

I am a “designer that codes” & I have read and plowed through a plethora of intricate~dense monographs over many years; but the concise, lucid way You present solutions I think is exceptional; might You possibly consider curating the knowledge You have shared on this Forum in (digital) book form?

It is not just a matter of knowing the code - it is the strategies - that take things to another level; and this is the type of insight that is so often the essence of the questions on this Forum.

Just a thought…

3 Likes