知识点
相关文章
更多最近更新
更多webApp 用js 模仿微信的摇一摇功能DeviceMotionEvent
2019-03-02 00:10|来源: 网路
webApp 用js 模仿微信的摇一摇功能
<script type="text/javascript"> var color = new Array('#fff', '#ff0', '#f00', '#000', '#00f', '#0ff'); if(window.DeviceMotionEvent) { var speed = 105; var x = y = z = lastX = lastY = lastZ = 0; var ys=1; window.addEventListener('devicemotion', function(){ var acceleration =event.accelerationIncludingGravity; x = acceleration.x; y = acceleration.y; if(Math.abs(x-lastX) > speed || Math.abs(y-lastY) > speed) { ys+=1; alert("你摇一摇换了桌面哦") document.getElementById("text").innerHTML+=ys+"<br />"; document.body.style.backgroundColor = color[Math.round(Math.random()*10)%6]; } lastX = x; lastY = y; }, false); } </script>
转自:http://my.oschina.net/kacper/blog/191670
相关问答
更多-
我现在学java想到像微信这样摇一摇和听歌识曲这样的人机交互软件是怎么做到的,用代码是怎么实现的[2022-04-09]
你现在想这些太早还是从基础学起。 -
像摇一摇微信上墙这样的功能,微信公众号二次开发商找哪个做相对好点?[2024-04-01]
这些都是现成的微信营销插件,基本都不用开发,找第三方平台,直接拉过来用就行。 难的是你的公众号内容搭建和运营。 -
在webApp上使用Ajax(Using Ajax on a webApp)[2023-05-02]
解: 在评论和取消注释我的代码的不同部分之后我发现是我的objectdatasource导致问题... ObjectDataSource使用函数实例来检索业务对象但是因为我使用类属性作为我的“select”objectdatasource函数的参数我需要定义当前我的页面实例作为对象实例(1)但是当工作完成时也由objectdatasource .... :)处理我停止使用事件“ObjectDisposing”(2)处理进程... (1) protected void OdsRecordObjectCreat ... -
我面临同样的问题。 我运行下面的命令,它解决了我的问题: mkdir -p /root/.config/configstore chmod g+rwx /root /root/.config /root/.config/configstore I was facing the same issue. I ran the command below, It fixed my problem: mkdir -p /root/.config/configstore chmod g+rwx /root /ro ...
-
是的,谷歌将能够抓取您的网站。 在发送到客户端之前,把手模板将在服务器上呈现。 您可能希望在模板中设置元标记以帮助SEO。 在以下网页上,有一个名为3.2的部分。 您可能会发现有用的SEO和社交优化 : https : //nodevision.com.au/blog/post/tutorial-blogging-with-nodejs-and-keystone-cms Yes Google will be able to crawl your site. Handlebars templates will ...
-
您可以扩展图表以从x轴中删除不需要的点,如此(改编自https://stackoverflow.com/a/31606933/360067 ) Chart.types.Line.extend({ name: "LineAlt", initialize: function (data) { Chart.types.Line.prototype.initialize.apply(this, arguments); if (this.options.every) ...
-
将网站转换为webapp(convert website to webapp)[2021-09-18]
如果你想成为平台本机(android / Apple),你可以使用像native native或phonegap或Xamarin这样的工具。 这些都是前端关注的焦点。 You can use tools like react native or phonegap or Xamarin if you want to be native to the platform (android / Apple). These are all front end focussed. -
在输入文本框中添加一个id,然后使用DOM获取值。 将搜索项放在要调用的gs函数的括号中。 的index.html