Skip to content

Commit 87a09dd

Browse files
authored
fix(ios): prevent onScroll method to divide by 0 (#208)
1 parent a5e04e1 commit 87a09dd

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

ios/ReactNativePageView.m

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,9 +325,13 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
325325
CGPoint point = scrollView.contentOffset;
326326
float offset = 0;
327327
if (self.orientation == UIPageViewControllerNavigationOrientationHorizontal) {
328-
offset = (point.x - self.frame.size.width)/self.frame.size.width;
328+
if (self.frame.size.width != 0) {
329+
offset = (point.x - self.frame.size.width)/self.frame.size.width;
330+
}
329331
} else {
330-
offset = (point.y - self.frame.size.height)/self.frame.size.height;
332+
if (self.frame.size.height != 0) {
333+
offset = (point.y - self.frame.size.height)/self.frame.size.height;
334+
}
331335
}
332336
if(fabs(offset) > 1) {
333337
offset = offset > 0 ? 1.0 : -1.0;

0 commit comments

Comments
 (0)