{"id":13432105,"url":"https://github.com/stuyam/pressure","last_synced_at":"2026-04-09T03:32:54.920Z","repository":{"id":37285293,"uuid":"44794996","full_name":"stuyam/pressure","owner":"stuyam","description":":point_down::boom:  JavaScript library for handling Force Touch, 3D Touch, and Pointer Pressure.","archived":false,"fork":false,"pushed_at":"2022-12-06T23:57:34.000Z","size":5161,"stargazers_count":2944,"open_issues_count":23,"forks_count":98,"subscribers_count":40,"default_branch":"master","last_synced_at":"2026-03-18T12:59:44.604Z","etag":null,"topics":["3d-touch","force-touch","javascript","pointer-events","polyfill"],"latest_commit_sha":null,"homepage":"https://pressurejs.com","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stuyam.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"License","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-23T06:30:29.000Z","updated_at":"2026-03-15T17:21:23.000Z","dependencies_parsed_at":"2022-07-12T10:02:47.656Z","dependency_job_id":null,"html_url":"https://github.com/stuyam/pressure","commit_stats":null,"previous_names":["yamartino/pressure"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/stuyam/pressure","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stuyam%2Fpressure","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stuyam%2Fpressure/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stuyam%2Fpressure/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stuyam%2Fpressure/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stuyam","download_url":"https://codeload.github.com/stuyam/pressure/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stuyam%2Fpressure/sbom","scorecard":{"id":856403,"data":{"date":"2025-08-11","repo":{"name":"github.com/stuyam/pressure","commit":"f0a35fb1f3dc5605fda9547af525954c539a18c8"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 2/24 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: License:0","Info: FSF or OSI recognized license: MIT License: License:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 10 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"21 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-w8qv-6jwh-64r5","Warn: Project is vulnerable to: GHSA-897m-rjf5-jp39","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq","Warn: Project is vulnerable to: GHSA-4gmj-3p3h-gm8h","Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj","Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh","Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-23T23:59:02.486Z","repository_id":37285293,"created_at":"2025-08-23T23:59:02.486Z","updated_at":"2025-08-23T23:59:02.486Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31584575,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T14:31:17.711Z","status":"online","status_checked_at":"2026-04-09T02:00:06.848Z","response_time":112,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["3d-touch","force-touch","javascript","pointer-events","polyfill"],"created_at":"2024-07-31T02:01:08.620Z","updated_at":"2026-04-09T03:32:54.890Z","avatar_url":"https://github.com/stuyam.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","目录","前端常用"],"sub_categories":[],"readme":"# Pressure.js\n\n[![Join the chat at https://gitter.im/yamartino/pressure](https://badges.gitter.im/yamartino/pressure.svg)](https://gitter.im/stuyam/pressure?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n[![npm https://www.npmjs.com/package/pressure](https://img.shields.io/npm/v/pressure.svg)](https://www.npmjs.com/package/pressure)\n[![npm https://www.npmjs.com/package/pressure](https://img.shields.io/npm/dt/pressure.svg)](https://www.npmjs.com/package/pressure)\n\n![Pressure Example](http://pressurejs.com/img/pressure.gif)\n\nPressure is a JavaScript library for handling both Force Touch and 3D Touch on the web, bundled under one library with a simple API that makes working with them painless.\n\nHead over to the [documentation](http://pressurejs.com/documentation.html) for installation instructions, supported devices, and more details on pressure.js.\n\n## Install\nDownload pressure.min.js or pressure.js files from GitHub or install with npm or bower\n#### npm\n```\nnpm install pressure --save\n```\n#### bower\n```\nbower install pressure --save\n```\n\n\n## Setup\nUse pressure in the global space:\n```javascript\nPressure.set('#id-name', {\n  change: function(force){\n    this.innerHTML = force;\n  }\n});\n```\nOR use it with browserify or CommonJS like setups:\n```javascript\nvar Pressure = require('pressure');\n\nPressure.set('#id-name', {\n  change: function(force){\n    this.innerHTML = force;\n  }\n});\n```\n\n\n## Usage\nNOTE: the \"this\" keyword in each of the callback methods will be the element itself that has force applied to it\n```javascript\nPressure.set('#element', {\n  start: function(event){\n    // this is called on force start\n  },\n  end: function(){\n    // this is called on force end\n  },\n  startDeepPress: function(event){\n    // this is called on \"force click\" / \"deep press\", aka once the force is greater than 0.5\n  },\n  endDeepPress: function(){\n    // this is called when the \"force click\" / \"deep press\" end\n  },\n  change: function(force, event){\n    // this is called every time there is a change in pressure\n    // force will always be a value from 0 to 1 on mobile and desktop\n  },\n  unsupported: function(){\n    // NOTE: this is only called if the polyfill option is disabled!\n    // this is called once there is a touch on the element and the device or browser does not support Force or 3D touch\n  }\n});\n```\n\n\n## jQuery Usage\nNOTE: the \"this\" keyword in each of the callback methods will be the element itself that has force applied to it\n```javascript\n$('#element').pressure({\n  start: function(event){\n    // this is called on force start\n  },\n  end: function(){\n    // this is called on force end\n  },\n  startDeepPress: function(event){\n    // this is called on \"force click\" / \"deep press\", aka once the force is greater than 0.5\n  },\n  endDeepPress: function(){\n    // this is called when the \"force click\" / \"deep press\" end\n  },\n  change: function(force, event){\n    // this is called every time there is a change in pressure\n    // force will always be a value from 0 to 1 on mobile and desktop\n  },\n  unsupported: function(){\n    // NOTE: this is only called if the polyfill option is disabled!\n    // this is called once there is a touch on the element and the device or browser does not support Force or 3D touch\n  }\n});\n```\n\n## Options\nWith Pressure, the third parameter is an optional object of options that can be passed in.\n\n### Polyfill Support\nUsing the \"polyfill\" keyword, you can disable polyfill support for the element. The polyfill is enabled by default and is useful if the device or browser does not support pressure, it will fall back to using time. For example instead of force from 0 to 1, it counts up from 0 to 1 over the course of one second, as long as you are holding the element. Try some of the examples on the main page on a device that does not support pressure and see for yourself how it works.\n```javascript\nPressure.set('#example', {\n  change: function(force, event){\n    this.innerHTML = force;\n  },\n  unsupported: function(){\n    alert(\"Oh no, this device does not support pressure.\");\n  }\n}, {polyfill: false});\n```\n\n### Polyfill Speed Up\nIf you are using the polyfill (on by default), you can see the \"polyfillSpeedUp\" speed to determine how fast the polyfill takes to go from 0 to 1. The value is an integer in milliseconds and the default is 1000 (1 second).\n```javascript\nPressure.set('#example', {\n  change: function(force, event){\n    this.innerHTML = force;\n  }\n}, {polyfillSpeedUp: 5000});\n// takes 5 seconds to go from a force value of 0 to 1\n// only on devices that do not support pressure\n```\n\n### Polyfill Speed Down\nIf you are using the polyfill (on by default), you can see the \"polyfillSpeedDown\" speed to determine how fast the polyfill takes to go from 1 to 0 when you let go. The value is an integer in milliseconds and the default is 0 (aka off).\n```javascript\nPressure.set('#example', {\n  change: function(force, event){\n    this.innerHTML = force;\n  }\n}, {polyfillSpeedDown: 2000});\n// takes 2 seconds to go from a force value of 1 to 0\n// only on devices that do not support pressure\n```\n\n### Only run on Force Touch trackpads (mouse)\nSet the option only to the type you want it to run on 'mouse', 'touch', or 'pointer'. The names are the types of events that pressure will respond to.\n```javascript\nPressure.set('#example',{\n  change: function(force, event){\n    console.log(force);\n  },\n}, {only: 'mouse'});\n```\n### Only run on 3D Touch (touch)\n```javascript\nPressure.set('#example',{\n  change: function(force, event){\n    console.log(force);\n  },\n}, {only: 'touch'});\n```\n### Only run on Pointer Supported Devices (pointer)\n```javascript\nPressure.set('#example',{\n  change: function(force, event){\n    console.log(force);\n  },\n}, {only: 'pointer'});\n```\n\n### Change the preventSelect option\nThe preventDefault option is \"true\" by default and it prevents the default actions that happen on 3D \"peel and pop\" actions and the Force \"define word\" actions as well as other defaults. To allow the defaults to run set preventDefault to \"false\"\n```javascript\nPressure.set('#example',{\n  change: function(force, event){\n    console.log(force);\n  },\n}, {preventSelect: false});\n```\n\n## Helpers\n\n### Config\nYou can use ```Pressure.config()``` to set default configurations for site wide setup. All of the configurations are the same as the options listed above.\n\n*Heads Up: If you have a config set, you can always override the config on individual Pressure elements by passing in any of the options listed above to a specific Pressure block.*\n\n**When using the jQuery Pressure library, use ```$.pressureConfig()``` rather than ```Pressure.map()```**\n```javascript\n// These are the default configs set by Pressure\nPressure.config({\n  polyfill: true,\n  polyfillSpeedUp: 1000,\n  polyfillSpeedDown: 0,\n  preventDefault: true,\n  only: null\n});\n```\n\n### Map\nYou can use ```Pressure.map()``` to map a value from one range of values to another. It takes 5 params: ```Pressure.map(inputValue, inputValueMin, inputValueMax, mapToMin, mapToMax);``` Here is a good write up on how this works in the Processing framework: [Map Function](https://processing.org/reference/map_.html).\n\n**When using the jQuery Pressure library, use ```$.pressureMap()``` rather than ```Pressure.map()```**\n```javascript\nPressure.set('#element', {\n  change: function(force, event){\n    // this takes the force, given that the force can range from 0 to 1, and maps that force value on a 100 to 200 range\n    this.style.width = Pressure.map(force, 0, 1, 100, 200);\n  }\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstuyam%2Fpressure","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstuyam%2Fpressure","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstuyam%2Fpressure/lists"}