Skip to content

Commit

Permalink
Merge pull request #16 from yamartino/dev-v0.0.4
Browse files Browse the repository at this point in the history
v0.0.4
  • Loading branch information
stuyam committed Feb 7, 2016
2 parents 4b25d95 + 38e10d4 commit f918fcd
Show file tree
Hide file tree
Showing 28 changed files with 1,561 additions and 1,042 deletions.
2 changes: 1 addition & 1 deletion License
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License

Copyright (c) 2015-Present Stuart Yamartino.
Copyright (c) 2015 - Present Stuart Yamartino.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
60 changes: 58 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ Pressure.set('#id-name', {
NOTE: the "this" keyword in each of the callback methods will be the element itself that has force applied to it
```javascript
Pressure.set('#element', {
start: function(){
start: function(event){
// this is called on force start
},
end: function(){
// this is called on force end
},
startDeepPress: function(){
startDeepPress: function(event){
// this is called on "force click" / "deep press", aka once the force is greater than 0.5
},
endDeepPress: function(){
Expand All @@ -66,3 +66,59 @@ Pressure.set('#element', {
}
});
```


## jQuery Usage
NOTE: the "this" keyword in each of the callback methods will be the element itself that has force applied to it
```javascript
$('#element').pressure({
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
}
});
```

## Options
### Only run on Force Touch trackpads (Mac)
Set the option only to the type you want it to run on 'force' or '3d'
```javascript
$('#element').pressure({
change: function(force, event){
console.log(force);
},
}, {only: 'force'});
```
### Only run on 3D Touch (iPhone 6s)
```javascript
$('#element').pressure({
change: function(force, event){
console.log(force);
},
}, {only: '3d'});
```

### Change the preventDefault option
The preventDefault option in "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"
```javascript
$('#element').pressure({
change: function(force, event){
console.log(force);
},
}, {preventDefault: false});
```
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "pressure",
"description": "Pressure is a JavaScript library for handling both Force Touch and 3D Touch through a single API",
"main": "pressure.js",
"main": "dist/pressure.min.js",
"authors": [
"Stuart Yamartino"
],
Expand All @@ -25,5 +25,5 @@
"test",
"tests"
],
"version": "0.0.3"
"version": "0.0.4"
}
Loading

0 comments on commit f918fcd

Please sign in to comment.