首页 > 其他分享 >DeviceMotionEvent API All In One

DeviceMotionEvent API All In One

时间:2023-03-07 16:33:29浏览次数:52  
标签:Web API https DeviceMotionEvent devicemotion event

DeviceMotionEvent API All In One

设备运动事件 / 设备动作事件

https://caniuse.com/?search=DeviceMotionEvent

image

Warning: Currently, Firefox and Chrome do not handle the coordinates the same way.
Take care about this while using them.
警告:目前,Firefox 和 Chrome 处理坐标的方式不同。
使用它们时请注意这一点。

https://developer.mozilla.org/en-US/docs/Web/API/DeviceMotionEvent

new DeviceMotionEvent(type)

new DeviceMotionEvent(type, options)

https://developer.mozilla.org/en-US/docs/Web/API/DeviceMotionEvent/DeviceMotionEvent

https://developer.mozilla.org/en-US/docs/Web/API/DeviceMotionEventAcceleration

https://developer.mozilla.org/en-US/docs/Web/API/DeviceMotionEventRotationRate

devicemotion

window.addEventListener('devicemotion', (event) => {
  console.log(`event =`, event);
});

window.ondevicemotion = (event) => {
  // console.log(`event =`, event);
};


function handleMotionEvent(event) {
    // 重力加速度
    const x = event.accelerationIncludingGravity.x;
    const y = event.accelerationIncludingGravity.y;
    const z = event.accelerationIncludingGravity.z;
    // Do something awesome.
}

window.addEventListener("devicemotion", handleMotionEvent, true);

https://developer.mozilla.org/en-US/docs/Web/API/Window/devicemotion_event

DeviceOrientation Event Specification

Editor’s Draft, 30 January 2023

https://w3c.github.io/deviceorientation/#devicemotion

(

标签:Web,API,https,DeviceMotionEvent,devicemotion,event
From: https://www.cnblogs.com/xgqfrms/p/17188524.html

相关文章

  • 【APIO2015】Palembang Bridges
    容易想到先排除不用过桥的再把过桥的1加上,剩下只需要考虑河边走的距离。首先考虑k=1的情况,容易发现相当于是一个直线上2n个点选一个点到所有点距离和最小,经典的结论选在中......
  • 【APIO2015】Bali Sculptures
    发现不是很好dp,考虑从大到小枚举位转而判断能不能让这一位为0。设计dp状态:\(dp[i][j]\)表示前i个分了j组是否能满足当前条件,显然有一个\(O(n^3logA)\)的简单dp。判断是否满......
  • 【APIO2015】Jakarta Skyscrapers
    很容易的想到根号分治,我们先考虑暴力做法。用dp[i][j]表示从开始状态到第i个点有一个跳跃能力为j的doge的最少跳跃次数,暴力也是O(n^2)的。我们考虑稍微优化优化。考虑根......
  • [转]C# 获得窗体句柄并发送消息(利用windows API可在不同进程中获取)
     C#使用WindowsAPI获取窗口句柄控制其他程序窗口编写程序模拟鼠标和键盘操作可以方便的实现你需要的功能,而不需要对方程序为你开放接口。比如,操作飞信定时发送短信等......
  • 函数编程:强大的 Stream API
    函数编程:强大的StreamAPI每博一文案只要有人的地方,世界就不会是冰冷的,我们可以平凡,但绝对不可以平庸。——————《......
  • Apinto V0.12 发布:新增流量镜像与 Mock 插件,路由特性更丰富!
    Hello~各位开发者朋友们好呀,Eolink旗下开源网关Apinto本周又更新啦!这次的更新我们给大家带来了2个好用的插件,且目前已经支持静态资源路由了!希望新的功能能让大家的......
  • 【APIO2014】Beads and wires
    观察其实就是每个节点可以作为蓝线的中点一次,然后求蓝线的最大权值和。考虑如果是有根的话,可能是son[x]-x-fa[x]这种结构,也可能是son[x]-x-son[x]。应该可以用一个dp[i][0/......
  • 【APIO2014】Palindromes
    先说一下自己的SAM做法:看到回文串我们首先考虑对以下字符串建立SAM:正串+特殊字符1+特殊字符2+反串。这样也许能有一点用。晚上睡觉前我考虑的是对于正串的endpos在反串中......
  • 如何做一个完美的api接口?
    如何做一个api接口?:我们知道API其实就是应用程序编程接口,可以把它理解为是一种通道,用来和不同软件系统间进行通信,本质上它是预先定义的函数:-api,接口 1 我们......
  • 谈一谈API接口开发,怎么编写一个合理严谨的接口
    做过开发的程序猿,基本都写过接口,写接口不算难事,与接口交互的对象核对好接口的地址、请求参数和响应参数即可,我在作为面试官去面试开发人员的时候,有时候会问这个问题,但相当多......