Skip to content

Commit 0b659b9

Browse files
authored
PR #75 from mctep/patch-74
Do not check delta when swiping in progress #74
2 parents 0d8b5af + d1911e0 commit 0b659b9

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/Swipeable.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class Swipeable extends React.Component {
117117

118118
const pos = calculatePos(e, this.swipeable);
119119

120-
if (pos.absX < delta && pos.absY < delta) return;
120+
if (pos.absX < delta && pos.absY < delta && !this.swipeable.swiping) return;
121121

122122
if (stopPropagation) e.stopPropagation();
123123

src/__tests__/Swipeable.spec.js

+20
Original file line numberDiff line numberDiff line change
@@ -202,4 +202,24 @@ describe('Swipeable', () => {
202202

203203
expect(preventDefault).not.toHaveBeenCalled();
204204
});
205+
206+
it('does not check delta when swiping in progress', () => {
207+
const onSwiping = jest.fn();
208+
const wrapper = mount((
209+
<Swipeable
210+
onSwiping={onSwiping}
211+
delta={40}
212+
>
213+
<span>Touch Here</span>
214+
</Swipeable>
215+
));
216+
217+
const touchHere = wrapper.find('span');
218+
touchHere.simulate('touchStart', createStartTouchEventObject({ x: 100, y: 100 }));
219+
touchHere.simulate('touchMove', createMoveTouchEventObject({ x: 145, y: 100 }));
220+
touchHere.simulate('touchMove', createMoveTouchEventObject({ x: 80, y: 100 }));
221+
touchHere.simulate('touchEnd', createMoveTouchEventObject({ x: 80, y: 100 }));
222+
223+
expect(onSwiping).toHaveBeenCalledTimes(2);
224+
});
205225
});

0 commit comments

Comments
 (0)