We have been adding WeChat Shake for a long time, and many friends are playing. So how to implement the WeChat Shake function based on html5 DeviceOrientation? Below, the editor of Wulin.com will share the detailed content with you for your reference.
In HTML5, the DeviceMotion event provided by the DeviceOrientation feature encapsulates the device's motion sensor time. By changing the time, data such as the device's motion state, acceleration, etc. can be obtained (the deviceOrientation event also provides device angle, orientation and other information).
Through DeviceMotion's judgment of the device's motion state, we can help us achieve the interactive effect of shaking on the web page.
Motion event monitoring
Copy the code