Question: Does anyone know how to use shake feature of iPhone to start animation?


(Nick ) #1

I am looking for a way to use the shake feature of the iPhone to start a Hype animated timelineโ€ฆ
Not quite sure how to do this.

Thanks
Nick


Having an image change when shaking a device, possible?
(๐•„๐•š๐•”๐•™๐•’๐•–๐• ๐”พ๐•’๐•ฃ๐• ๐•—๐•’๐•๐• ) #2

This is just a guess, but Iโ€™m imaging the following would be chucked inside a window.ondevicemotion event.

if ( Math.abs(event.accelerationIncludingGravity.x) > 1.5) {
alert("shake");
}

#3

Hereโ€™s a plugin I found: https://github.com/alexgibson/shake.js/


(Nick ) #4

Thanks I will try this one later tonight.


(๐•„๐•š๐•”๐•™๐•’๐•–๐• ๐”พ๐•’๐•ฃ๐• ๐•—๐•’๐•๐• ) #5

The previous code didnโ€™t work for you? I tried it and at first it was triggering a lot of annoying JavaScript alert messages. So, I bumped up the number. 1.5 wasnโ€™t enough. 2.0 wasnโ€™t enough either. That was too sensitive. 10 seemed to work well.

Personally, I try to avoid libraries and just use pure JavaScript. Although, with that logic, then I probably shouldnโ€™t even be here. HA HA.


(Nick ) #6

Thanks for the tip tried it but it was not working so well.
Pure JavaScript is nice but I will always opt for libraries these days.
Much quicker less buggy.
I want to spend more time making things than debugging code๐Ÿ˜‰
Too much of a creative :blush: