# Interactive mobile device tilt as trigger

**URL:** <https://forum.readymag.com/t/interactive-mobile-device-tilt-as-trigger/2721>\
**Category:** Custom code\
**Created:** [April 3, 2024, 7:31pm UTC](https://forum.readymag.com/t/interactive-mobile-device-tilt-as-trigger/2721 "2024-04-03T19:31:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Emir\_Kreidie](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.readymag.com/emir_kreidie/32/1280_2.png) [@Emir\_Kreidie](https://forum.readymag.com/u/Emir_Kreidie)\
**Post date:** [April 3, 2024, 7:31pm UTC](https://forum.readymag.com/t/interactive-mobile-device-tilt-as-trigger/2721/1 "2024-04-03T19:31:12Z")

</div>

hello trying to make a video play on tilting the mobile device. the video is linked from video via a code widget using iframe, attached the code i tried that did not work, anyone know if that is possible to run on readymag? or any issues with the code? tx

 ![Screenshot 2024-04-03 at 10.21.55 PM](https://us1.discourse-cdn.com/flex015/uploads/readymag/original/2X/4/47a0a3e16bbcddbac380e5431e209a1d4ab5d76a.jpeg)

---

<div class="post-metadata">

**Author:** ![Samus](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.readymag.com/samus/32/1146_2.png) [@Samus](https://forum.readymag.com/u/Samus)\
**Post date:** [April 10, 2024, 11:57pm UTC](https://forum.readymag.com/t/interactive-mobile-device-tilt-as-trigger/2721/2 "2024-04-10T23:57:22Z")

</div>

Tricky! Project layouts automatically swap upon changing from portrait—\>landscape. I doubt this mechanic can be overwritten easily (if even) via code.

---

<div class="post-metadata">

**Author:** ![neueMeta](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.readymag.com/neuemeta/32/92_2.png) [@neueMeta](https://forum.readymag.com/u/neueMeta)\
**Post date:** [April 11, 2024, 7:52am UTC](https://forum.readymag.com/t/interactive-mobile-device-tilt-as-trigger/2721/3 "2024-04-11T07:52:02Z")

</div>

Thats right, your main problem is the automated switch to the desktop version if you tilt your phone.  
I´m not sure if this is done that easy.at least requires some digging into it without knowing that there is a solution…

And in general, if this problem wouldn´t be there:

your code should work regarding the logic behind it…  
But I think your selector is wrong! The data-id of RM is not the same as the knwon css #ID.  
it should be:

```auto
const videoIframe = document.querySelectorAll("[data-id=6604f29e84b6080035c470e9]").querySeceltor("iframe");

```

Also I wrap your code inside a timeout to make sure that all elements are already loaded before adressing them with JS…

```auto
  setTimeout(function() {

//yourcode

  }, 2000);  

```

---

<div class="post-metadata">

**Author:** ![Emir\_Kreidie](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.readymag.com/emir_kreidie/32/1280_2.png) [@Emir\_Kreidie](https://forum.readymag.com/u/Emir_Kreidie)\
**Post date:** [April 11, 2024, 2:07pm UTC](https://forum.readymag.com/t/interactive-mobile-device-tilt-as-trigger/2721/4 "2024-04-11T14:07:53Z")

</div>

thank you. much appreciated.
