Skip to content

Commit cdd4614

Browse files
author
Marek Rozmus
committed
Merge branch 'fix_null_exceptions'
2 parents 1b50ae4 + 63a3925 commit cdd4614

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/SwipeableListItem.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,12 @@ class SwipeableListItem extends PureComponent {
170170
if (this.isSwiping()) {
171171
const threshold = this.props.threshold || 0.5;
172172

173-
if (this.left < this.listElement.offsetWidth * threshold * -1) {
174-
this.handleSwipedLeft();
175-
} else if (this.left > this.listElement.offsetWidth * threshold) {
176-
this.handleSwipedRight();
173+
if (this.listElement) {
174+
if (this.left < this.listElement.offsetWidth * threshold * -1) {
175+
this.handleSwipedLeft();
176+
} else if (this.left > this.listElement.offsetWidth * threshold) {
177+
this.handleSwipedRight();
178+
}
177179
}
178180

179181
if (this.props.onSwipeEnd) {
@@ -311,11 +313,13 @@ class SwipeableListItem extends PureComponent {
311313
return;
312314
}
313315

314-
this.listElement.style.transform = `translateX(${this.left}px)`;
316+
if (this.listElement) {
317+
this.listElement.style.transform = `translateX(${this.left}px)`;
318+
}
315319

316320
const opacity = (Math.abs(this.left) / 100).toFixed(2);
317321

318-
if (this.props.onSwipeProgress && this.listElement !== null) {
322+
if (this.props.onSwipeProgress && this.listElement) {
319323
const listElementWidth = this.listElement.offsetWidth;
320324
let swipeDistancePercent = this.previousSwipeDistancePercent;
321325

0 commit comments

Comments
 (0)