Use the DeviceOrientation feature of Html5 to implement the shake function. New html5 features

Source: Internet
Author: User

Use the DeviceOrientation feature of Html5 to implement the shake function. New html5 features

Many mobile websites now have the same shake function, such as what to shake to receive a red envelope, receive a gift, etc.

1. deviceOrientation: encapsulates the event of the direction sensor data to obtain the direction data of the mobile phone in the static state, such as the angle, orientation, and orientation of the mobile phone.

2. deviceMotion: encapsulates motion sensor data events to obtain motion acceleration data during mobile phone motion.

It is useless to say more, and the code is healthy:

<! DOCTYPE html> 

You can directly paste it, but you must prepare the music link yourself.



I can shake it with html5, but it can be opened with UC browser, but it cannot be used if it is encapsulated into webview. How can this problem be solved?

Is Gravity sensing not called after being encapsulated into webview, or it is completely ineffective... I don't know. I can see that I can call sensors like gravity sensing with phonegap on the internet ..


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.