HTML5 Device Access (设备访问)
camera api (含图片预览)
- 主要为利用input type=file, accept="image/*" 进行处理
- 图片预览方式(两种)
const file = e.target.files[0]
// 方式1
const url1 = window.URL.createObjectURL(file);
let url2
// 方式2
const reader = new FileReader();
reader.onload = (e) => {
url2 = e.target.result;
};
reader.readAsDataURL(file);
touch events (触屏事件)
- touchstart
- touchend
- touchcancel 电话的接入或者弹出信息等比较高级的事件触发,一般做保存操作
- touchmove
geolocation
- 注意谷歌浏览器要https才能提供定位服务
if (navigator.geolocation){
navigator.geolocation.getCurrentPosition((position) => {
this.geolocation = `latitude:${position.coords.latitude},longitude:${position.coords.longitude}`
}, (err) => {
console.log(err);
}, {
enableHighAccuracy: true,
maximumAge : 30000, // buffer memory timre
timeout : 27000 // waiting time
})
} else {
alert('geolocation not supported!')
}
device orientation and motion
window.addEventListener('deviceorientation',(doe) => {
this.absolute = doe.absolute //false 表示方向数据由设备本身坐标系提供
this.alpha = doe.alpha // 绕Z轴0-360 进入时手机水平正对的方向为0或360
this.beta = doe.beta // 绕X轴-180~180 描述由前向后旋转
this.gamma = doe.gamma // 绕Y轴-90~90 描述由左向右旋转
}, true)
// chrome v65 只支持accelerationIncludingGravity和interval(应该因为一些限制没有找到),其它浏览器最新版基本都支持
window.addEventListener('devicemotion', (dme) => {
this.acceleration = dme.acceleration
this.accelerationIncludingGravity = dme.accelerationIncludingGravity
this.rotationRate = dme.rotationRate
this.interval = dme.interval
}, false)
Pointer Lock(鼠标锁定)
<button onclick="lockPointer();">锁住它!</button>
<div id="pointer-lock-element" style="width:500px;height:500px;background-color: red"></div>
// 简单示例,将鼠标锁定在 pointer-lock-element 元素内
let = document.getElementById("pointer-lock-element");
document.addEventListener("mousemove", function(e) {
var movementX = e.movementX
movementY = e.movementY
// 打印鼠标移动的增量值。
console.log("X=" + movementX, "Y=" + movementY);
}, false);
function lockPointer() {
elem = document.getElementById("pointer-lock-element");
elem.requestPointerLock = elem.requestPointerLock ||
elem.mozRequestPointerLock ||
elem.webkitRequestPointerLock;
elem.requestPointerLock();
}
HTML5 Device Access (设备访问)的更多相关文章
- [转] HTML5+规范:device(管理设备信息)
http://blog.csdn.net/qq_27626333/article/details/51815310 Device模块管理设备信息,用于获取手机设备的相关信息,如IMEI.IMSI.型号 ...
- 与众不同 windows phone (18) - Device(设备)之加速度传感器, 数字罗盘传感器
原文:与众不同 windows phone (18) - Device(设备)之加速度传感器, 数字罗盘传感器 [索引页][源码下载] 与众不同 windows phone (18) - Device ...
- 与众不同 windows phone (20) - Device(设备)之位置服务(GPS 定位), FM 收音机, 麦克风, 震动器
原文:与众不同 windows phone (20) - Device(设备)之位置服务(GPS 定位), FM 收音机, 麦克风, 震动器 [索引页][源码下载] 与众不同 windows phon ...
- 与众不同 windows phone (19) - Device(设备)之陀螺仪传感器, Motion API
原文:与众不同 windows phone (19) - Device(设备)之陀螺仪传感器, Motion API [索引页][源码下载] 与众不同 windows phone (19) - Dev ...
- Blazor组件自做十一 : File System Access 文件系统访问 组件
Blazor File System Access 文件系统访问 组件 Web 应用程序与用户本地设备上的文件进行交互 File System Access API(以前称为 Native File ...
- 用DBMS_ADVISOR.SQLACCESS_ADVISOR创建SQL Access Advisor访问优化建议
使用OEM方式来创建SQL Access Advisor访问优化建议,已经是四五年的事了,下面就来写写怎样使用DBMS_ADVISOR.SQLACCESS_ADVISOR来创建SQL Access A ...
- 与众不同 windows phone (23) - Device(设备)之硬件状态, 系统状态, 网络状态
原文:与众不同 windows phone (23) - Device(设备)之硬件状态, 系统状态, 网络状态 [索引页][源码下载] 与众不同 windows phone (23) - Devic ...
- 与众不同 windows phone (22) - Device(设备)之摄像头(硬件快门, 自动对焦, 实时修改捕获视频)
原文:与众不同 windows phone (22) - Device(设备)之摄像头(硬件快门, 自动对焦, 实时修改捕获视频) [索引页][源码下载] 与众不同 windows phone (22 ...
- 与众不同 windows phone (21) - Device(设备)之摄像头(拍摄照片, 录制视频)
原文:与众不同 windows phone (21) - Device(设备)之摄像头(拍摄照片, 录制视频) [索引页][源码下载] 与众不同 windows phone (21) - Device ...
随机推荐
- Tell Don’t Ask
The Tell, Don’t Ask (TDA) principle suggests that it is better to issue an object a command do perfo ...
- C语言学习书籍推荐《C语言入门经典(第5版)》下载
霍尔顿 (Ivor Horton) (作者), 杨浩 (译者) 下载地址:点我 C语言是每一位程序员都应该掌握的基础语言.C语言是微软.NET编程中使用的C#语言的基础:C语言是iPhone.iPad ...
- Object.toString()打印“地址”的原理
Object.toString()打印"地址"的原理 @(java) 首先,打印的绝不是地址 public native int hashCode(); public boolea ...
- 异常——cmd下javac错误:编码GBK不可映射字符
在看菜鸟教程时候用记事本创建文件,之后用notepad++编辑后,运行出现错误. 首先从信息上知道这是编码的问题了.开始试了下再notepad++上打开文件选择标签栏的“Encoding”中的“enc ...
- WinForm控件之【MaskedTextBox】
基本介绍 掩码文本控件,使用掩码来区分用户输入文本是否正确. 常设置属性 BeepOnError:指示键入无效字符是控件是否发出系统提示音: CutCopyMaskFormat:设置控件文本值复制到剪 ...
- 关于css样式加载的问题
今天我在学习jQuery的addClass操作时遇到了一个小问题,想来跟大家分享一下,避免初学者踩坑. 我的需求是制作一个表格,并让它隔行换色,在此基础上再加上鼠标悬浮变色的效果.(主要训练jQuer ...
- Excel催化剂开源第41波-网抓网络采集类库及工具分享
在VBA开发网抓程序中,会用到xmlhttp/winHttp.winHttprequest.5.1等组件,当时笔者也是这样进入了网抓领域的,这些都是非常过时的东西,在.Net的开发中,有大量的更好用的 ...
- c语言进阶3-有参函数
一. 有参函数的定义 有参函数的定义格式如下: 类型标识符 函数名(形式参数表列) { 语句: } 如 void fun(int a,int b) { printf(“a+b=%d”,a ...
- 六、SQL 多张表数据叠加到一个视图里面
1 create view vABC as select * from a,b,c where a.id = b.aid and b.id = c.bid ---------------------- ...
- Spring Boot2(十五):Shiro记住我rememberMe、验证码Kaptcha
接着上次学习的<Spring Boot2(十二):手摸手教你搭建Shiro安全框架>,实现了Shiro的认证和授权.今天继续在这个基础上学习Shiro实现功能记住我rememberMe,以 ...