Test motion events with new polyfill

Developer Remy Sharp has unveiled Remote-Tilt, a polyfill that enables you to send motion events to a web page. The script works in Chrome, Safari and Opera, and can be added through a single line of JavaScript.

Sharp told us that he built Remote-Tilt for the usual reasons he builds anything: "I was stuck trying to do something, and so I created a tool to do that thing. I was planning on adding motion events to a website I had worked on, and although I know how they work, the values in the events don't really mean much to me."

The usual process for working on such functionality, explained Sharp, is a "horrible loop" of writing code, pointing a mobile device at it, and testing; furthermore, debugging on mobile devices is fiddly. "But I figured these are just events and I could simulate the values using a simple JavaScript polyfill," he told us. "Once I had the initial pop-up working, I quickly realised I could open my simulator on a mobile device that had a gyroscope or accelerometer and just pipe those events from my phone to my development project."

Development itself was, according to Sharp, a challenge, in the sense of making the whole thing a single script include – "That's a single script to create the pop-up. A single script that actually is the pop-up. A single script with the images, events, everything." – And he ran into problems in Chrome, but considers his script an edge case. "But piping events from the mobile phone to the desktop is pretty straightforward and very similar to the technique I use to create a remote control for mobiles. And, all the code was written in a matter of a couple of days – it's still just a single script with a simple server after all!"

Thank you for reading 5 articles this month* Join now for unlimited access

Enjoy your first month for just £1 / $1 / €1

*Read 5 free articles per month without a subscription

Join now for unlimited access

Try first month for just £1 / $1 / €1

The Creative Bloq team is made up of a group of design fans, and has changed and evolved since Creative Bloq began back in 2012. The current website team consists of six full-time members of staff: Editor Kerrie Hughes, Deputy Editor Rosie Hilder, Deals Editor Beren Neale, Senior News Editor Daniel Piper, Digital Arts and Design Editor Ian Dean, and Staff Writer Amelia Bamsey, as well as a roster of freelancers from around the world. The 3D World and ImagineFX magazine teams also pitch in, ensuring that content from 3D World and ImagineFX is represented on Creative Bloq.