Skip to content

Commit dde309c

Browse files
Set touch option to false by default.
1 parent e9dc96f commit dde309c

File tree

10 files changed

+848
-755
lines changed

10 files changed

+848
-755
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
This project adheres to
44
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
55

6+
## 2.0.0 - 2019-04-05
7+
8+
### Breaking change
9+
10+
- Set `touch` option default to `false` because it is in most cases annoying
11+
when scrolling on a touch device.
12+
613
## 1.1.0 - 2019-03-10
714

815
- Add `timeout` option.

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ They all return an object of event listeners to add on the element.
4646

4747
```jsx
4848
import { useMouseDown } from 'use-mouse-action';
49+
4950
/** ... */
51+
5052
const props = useMouseDown(() => toggle);
5153
return (<button type="button" {...props}>Click me</button>);
5254
```
@@ -58,7 +60,7 @@ The `useMouseDown` and `useMouseUp` are both a shortcut to respectively set the
5860
- `onAction` (required): The function called on custom click triggered.
5961
- `down` (default: `false`): If the element should listen to mousedown event.
6062
- `up` (default: `false`): If the element should listen to mouseup event.
61-
- `touch` (default: `true`): If the element should listen to touch equivalent
63+
- `touch` (default: `false`): If the element should listen to touch equivalent
6264
events.
6365
- `timeout` (default: `10`): Short timeout in milliseconds to prevents multiple
6466
events.

cypress/integration/test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ context('useMouseDown', () => {
2424
it('touchstart', () => {
2525
cy.get(id)
2626
.trigger('touchstart', { button: 0 })
27-
.contains('1');
27+
.contains('0');
2828
});
2929

3030
it('mousedown wrong button', () => {
@@ -77,7 +77,7 @@ context('useMouseUp', () => {
7777
it('touchend', () => {
7878
cy.get(id)
7979
.trigger('touchend')
80-
.contains('1');
80+
.contains('0');
8181
});
8282

8383
it('mouseup wrong button', () => {
@@ -139,7 +139,7 @@ context('useMouseAction empty', () => {
139139
});
140140
});
141141

142-
context('useMouseDown and touch disabled', () => {
142+
context('useMouseDown and touch enabled', () => {
143143
const id = '#4';
144144

145145
it('mousedown', () => {
@@ -151,7 +151,7 @@ context('useMouseDown and touch disabled', () => {
151151
it('touchstart', () => {
152152
cy.get(id)
153153
.trigger('touchstart', { button: 0 })
154-
.contains('0');
154+
.contains('1');
155155
});
156156

157157
it('mousedown wrong button', () => {
@@ -180,8 +180,8 @@ context('useMouseDown and touch disabled', () => {
180180
});
181181
});
182182

183-
context('useMouseUp and touch disabled', () => {
184-
const id = '#2';
183+
context('useMouseUp and touch enabled', () => {
184+
const id = '#5';
185185

186186
it('mousedown', () => {
187187
cy.get(id)

example/dist/index.js

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/src/index.jsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,24 @@ ReactDOM.render(
7474
<main>
7575
<section>
7676
<h1>Classic drop-down</h1>
77+
7778
<ClassicDropDown />
79+
7880
<h2>Source Code</h2>
81+
7982
<SyntaxHighlighter language="jsx" style={prism}>
8083
{classicCode}
8184
</SyntaxHighlighter>
8285
</section>
8386
<section>
8487
<h1>Faster usable drop-down</h1>
88+
8589
<p>On desktop, you can simply keep mouse button down, drag down and release the button on the wanted item.</p>
90+
8691
<DropDown />
92+
8793
<h2>Source Code</h2>
94+
8895
<SyntaxHighlighter language="jsx" style={prism}>
8996
{libCode}
9097
</SyntaxHighlighter>

0 commit comments

Comments
 (0)