PressureJS

授权协议 MIT
开发语言 JavaScript
所属分类 Web应用开发、 常用JavaScript包
软件类型 开源软件
地区 不详
投 递 者 弘伟彦
操作系统 iOS
开源组织
适用人群 未知
 软件概览

PressureJS 是一个 JavaScript 库,封装了苹果 Force Touch 和 3D Touch 的 API

示例代码:

Pressure.set('#element', {
  start: function(event){
    // this is called on force start
  },
  end: function(){
    // this is called on force end
  },
  startDeepPress: function(event){
    // this is called on "force click" / "deep press", aka once the force is greater than 0.5
  },
  endDeepPress: function(){
    // this is called when the "force click" / "deep press" end
  },
  change: function(force, event){
    // this is called every time there is a change in pressure
    // force will always be a value from 0 to 1 on mobile and desktop
  },
  unsupported: function(){
    // this is called once there is a touch on the element and the device or browser does not support Force or 3D touch
  }
});
  • Pressure的官网 https://pressurejs.com/ 这边做个记录 由于没有支持压力感应的设备,所以在测试的时候,自己用的polyfill Pressure.set("#OfdCanvasWrapper", {//压力感应0-1之间 change: function (force) { console.log(force) }

相关阅读

相关文章

相关问答

相关文档