Hi,

I would like to trigger an event when the orientation changes in a reactive web app. Found the below reference where a method can be called whenever there is a change in device orientation.

https://success.outsystems.com/Documentation/11/Reference/OutSystems_APIs/JavaScript_API/View#registerdeviceclassgetter

But, I am not sure what the "getter" function here means and what needs to be passed to it.

Please can someone give an example code or sample .oml?

Thanks

Hi Karthik Nataraj,

You can define the below JS Script in OnInitialize event, to trigger event on every orientation change in Reactive Web application

JS Code Snippet

// Listen for orientation changes      
window.addEventListener("orientationchange", function() {
    alert('Orientation changed!');
}, false);


Hope this helps you!


Regards,

Benjith Sam

Hi Karthik Nataraj,

Adding to what I mentioned previously, if you want to add the "orientationonchange" Event Listener through out the application, you can define the JS node within the OnApplicationReady System Event action flow.

Check this - Demo Screen (Environment is under maintenance, please check the link after some time)

PFA - includes the .oml solution file


Hope this helps you.


Regards,

Benjith Sam

Benjith Sam wrote:

Hi Karthik Nataraj,

You can define the below JS Script in OnInitialize event, to trigger event on every orientation change in Reactive Web application

JS Code Snippet

// Listen for orientation changes      
window.addEventListener("orientationchange", function() {
    alert('Orientation changed!');
}, false);


Hope this helps you!


Regards,

Benjith Sam

Hi Benjith Sam,

Thanks for your suggestion, which was very helpful for my implementation.

I would like to use the built-in feature (JavaScript API/View) to achieve this so platform take care of the multi-browser compatibilities. Any idea how to use "registerdeviceclassgetter" in the above mentioned API?

Regards,

Karthik