Skip to content

Commit 8e2b5ab

Browse files
committed
add comment for delta update, add swiped callbacks to delta test
1 parent 0b659b9 commit 8e2b5ab

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/Swipeable.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ class Swipeable extends React.Component {
117117

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

120+
// if swipe is under delta and we have not already started to track a swipe: return
120121
if (pos.absX < delta && pos.absY < delta && !this.swipeable.swiping) return;
121122

122123
if (stopPropagation) e.stopPropagation();

src/__tests__/Swipeable.spec.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,13 @@ describe('Swipeable', () => {
205205

206206
it('does not check delta when swiping in progress', () => {
207207
const onSwiping = jest.fn();
208+
const onSwipedRight = jest.fn();
209+
const onSwipedLeft = jest.fn();
208210
const wrapper = mount((
209211
<Swipeable
210212
onSwiping={onSwiping}
213+
onSwipedRight={onSwipedRight}
214+
onSwipedLeft={onSwipedLeft}
211215
delta={40}
212216
>
213217
<span>Touch Here</span>
@@ -221,5 +225,7 @@ describe('Swipeable', () => {
221225
touchHere.simulate('touchEnd', createMoveTouchEventObject({ x: 80, y: 100 }));
222226

223227
expect(onSwiping).toHaveBeenCalledTimes(2);
228+
expect(onSwipedLeft).toHaveBeenCalledTimes(1);
229+
expect(onSwipedRight).not.toHaveBeenCalled();
224230
});
225231
});

0 commit comments

Comments
 (0)