12
Views
3
Comments
How to use "registerDeviceClassGetter" method in Javascript API?
Question

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

mvp_badge
MVP
Rank: #91

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

mvp_badge
MVP
Rank: #91

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

DetectScreenOrientationChange.oml