Skip to content

Commit a98affe

Browse files
author
Marek Rozmus
committed
Fix one directional swipe items animation
1 parent 3a28164 commit a98affe

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/SwipeableListItem.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,13 +282,31 @@ class SwipeableListItem extends PureComponent {
282282
});
283283
};
284284

285+
get onlyLeftContent() {
286+
return this.contentLeft !== null && this.contentRight === null;
287+
}
288+
289+
get onlyRightContent() {
290+
return this.contentLeft === null && this.contentRight !== null;
291+
}
292+
285293
updatePosition = () => {
286294
const now = Date.now();
287295
const elapsed = now - this.startTime;
288296

289297
if (elapsed > FPS_INTERVAL && this.isSwiping()) {
290298
let contentToShow = this.left < 0 ? this.contentLeft : this.contentRight;
291299

300+
if (this.onlyLeftContent && this.left > 0) {
301+
this.left = 0;
302+
contentToShow = this.contentLeft;
303+
}
304+
305+
if (this.onlyRightContent && this.left < 0) {
306+
this.left = 0;
307+
contentToShow = this.contentRight;
308+
}
309+
292310
if (!contentToShow) {
293311
return;
294312
}

0 commit comments

Comments
 (0)