You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: CHANGELOG.md
+11
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,14 @@
1
+
# 5.1.0
2
+
* Fix for `preventDefaultTouchmoveEvent` in safari [issue #127](https://github.com/dogfessional/react-swipeable/issues/127) and [PR #131](https://github.com/dogfessional/react-swipeable/pull/131)
3
+
* Thank you [@JiiB](https://github.com/JiiB) and [@bhj](https://github.com/bhj)!
4
+
* use `ref` callback for both `<Swipeable>` and `useSwipeable` to attach all touch event handlers
5
+
*`useSwipeable`'s returned `handlers` now contains a ref callback
6
+
* Please see disscusion and comments in both [#127](https://github.com/dogfessional/react-swipeable/issues/127) and [#131](https://github.com/dogfessional/react-swipeable/issues/127) for more details and info.
7
+
* fix avoids the `passive: true` issue from chrome document event listeners
8
+
* fix avoids bug on safari where the `touchmove` event listener needs to be attached before a `touchstart` in order to be able to call `e.preventDefault`
9
+
* removed `touchHandlerOption` prop
10
+
* fix above deprecates this prop
11
+
1
12
# 5.0.0
2
13
* Introduce react hook, `useSwipeable`
3
14
* Core rewrite to simplify api and trim down bundled size
passive: true|false // defaults opposite of preventDefaultTouchmoveEvent *See Details*
87
-
},
88
84
}
89
85
```
90
86
91
87
### Component Specific Props
92
88
93
89
```
94
90
{
95
-
nodeName: 'div', // internal component dom node
96
-
innerRef // access internal component dom node
91
+
nodeName: 'div', // internally rendered component dom node
92
+
innerRef // callback ref for internal component dom node
97
93
}
98
94
```
99
95
100
96
**None of the props/config options are required.**
101
97
98
+
### Hook details
99
+
- Hook use requires **react >= 16.8.0**
100
+
- The props contained in `handlers` are currently `ref` and `onMouseDown`
101
+
- Please spread `handlers` as the props contained in it could change as react improves event listening capabilities
102
+
- See [#127](https://github.com/dogfessional/react-swipeable/issues/127) for some more context
103
+
102
104
### preventDefaultTouchmoveEvent Details
103
105
104
106
**`preventDefaultTouchmoveEvent`** prevents the browser's [touchmove](https://developer.mozilla.org/en-US/docs/Web/Events/touchmove) event. Use this to stop the browser from scrolling while a user swipes.
105
107
*`e.preventDefault()` is only called when:
106
108
*`preventDefaultTouchmoveEvent: true`
107
109
*`trackTouch: true`
108
110
* the users current swipe has an associated `onSwiping` or `onSwiped` handler/prop
109
-
* if `preventDefaultTouchmoveEvent: true` then `touchHandlerOption` defaults to `{ passive: false }`
110
-
* if `preventDefaultTouchmoveEvent: false` then `touchHandlerOption` defaults to `{ passive: true }`
111
111
112
112
Example:
113
113
* If a user is swiping right with `<Swipable onSwipedRight={this.userSwipedRight} preventDefaultTouchmoveEvent={true} >` then `e.preventDefault()` will be called, but if the user was swiping left then `e.preventDefault()` would **not** be called.
114
114
115
115
Please experiment with the [example](http://dogfessional.github.io/react-swipeable/) to test `preventDefaultTouchmoveEvent`.
116
116
117
-
#### Older browser support
118
-
If you need to support older browsers that do not have support for `{passive: false}``addEventListener` 3rd argument, we recommend using [detect-passive-events](https://www.npmjs.com/package/detect-passive-events) package to determine the `touchHandlerOption` prop value.
0 commit comments