I am looking to create a helper object with a function that will trigger on each "orientationchange" event of the window.
Below is my code, but it is not working correctly. Can you help me define the onRotate function properly so that I can use it globally?
<script type="text/javascript">
'use strict';
var GlobalHelper = (function () {
var me = {
onRotate: onRotate // struggling with this part
}
function onRotate() {
window.addEventListener("orientationchange", function (event) {
console.log(event.target.screen.orientation.angle);
});
}
return me;
})();
GlobalHelper.onRotate = function (e) {
console.log(e);
}
</script>