Goje87
Goje87

Reputation: 2869

iOS Safari's iframe doesn't get device orientation and motion events

I was trying to learn about HTML5 device orientation API. I found few demos that worked great on Android and iOS when I opened them on browser.

Demo: https://www.audero.it/demo/device-orientation-api-demo.html

Now, when I included those pages in an iframe and opened in Android (chrome), it worked as expected. But, in iOS safari, the page just didn't do anything. Looks like the window.DeviceOrientationEvent is true, but no deviceorientation event is triggered inside the iframe.

Demo: http://output.jsbin.com/sumevugiga/1

Is this expected or am I doing something wrong here?

Upvotes: 1

Views: 787

Answers (1)

axrami
axrami

Reputation: 177

Add an event listener on orientationchange

document.addEventListener('orientationchange', function () {
  isLandScape = Math.abs(window.orientation) == 90;
  // handle_orientation_change
});

Upvotes: -1

Related Questions