I am working on mobile site that donate if you are not using your phone.

I was searching on the internet and I found similar project.

http://tap.unicefusa.org/mobile

you need to open it by mobile device.

I am worried how can I detect if the user hold his mobile or he put it down on table or something by jQuery mobile or javascript ?

any Idea how they did that?

有帮助吗?

解决方案

In a webpage you can access the Gyroscope using DeviceMotionEvent.

simply check if that even exists prior to use it as plenty of mobiles do not allow or do not have such feature.

a good idea on how to start might be an old post from Peter's blog.

There's also some javascript libraries such as gyro.js that you might try.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top