In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces how to use gravity induction to realize shaking and changing color in html5. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.
Found a case from the Internet, which is used to shake and change color, which is very easy to use, but after the test, you need to pay attention to:
1. Ios or Android 4.0 or above is required to achieve functional applications.
2. If the judgment of z coordinate is added, the screen will change color indiscriminately, which is probably too sensitive. Or I can't find the right usage. I hope you can correct it.
3. With a slight change in this function, it can become a lottery method, which is more fashionable than turntable and scratch cards. Haha.
The code is as follows:
Var color = new Array ('red',' blue', 'yellow',' green','# 00fags,'# 0ff'); if (window.DeviceMotionEvent) {var speed = 25; var x = z = lastX = lastY = lastZ = 0; window.addEventListener ('devicemotion', function () {var acceleration = event.accelerationIncludingGravity; x = acceleration.x; y = acceleration.y; / / z = acceleration.z If (Math.abs (x-lastX) > speed | | Math.abs (y-lastY) > speed) {document.body.style.backgroundColor = color [Math.round (Math.random () * 10)% 6];} lastX = x; lastY = y; / / lastZ = z;}, false) } about how to use gravity induction to realize shake and change color in html5 can be used as a lucky draw to share here. I hope the above content can be helpful to everyone and learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.