Skip to content

Commit

Permalink
Prevent flickering with adjustToContentHeight
Browse files Browse the repository at this point in the history
  • Loading branch information
charpeni committed Oct 11, 2019
1 parent 88d7a11 commit a2585c6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Modalize.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,17 @@ export default class Modalize<FlatListItem = any, SectionListItem = any>
}

public open = (): void => {
const { onOpen } = this.props;
const { adjustToContentHeight, onOpen } = this.props;

if (onOpen) {
onOpen();
}

this.onAnimateOpen();
if (!adjustToContentHeight || this.contentAlreadyCalculated) {
this.onAnimateOpen();
} else {
this.setState({ isVisible: true });
}
}

public close = (): void => {
Expand Down Expand Up @@ -297,6 +301,7 @@ export default class Modalize<FlatListItem = any, SectionListItem = any>
modalHeight: contentHeight - this.handleHeight,
}, () => {
this.contentAlreadyCalculated = true;
this.onAnimateOpen();
});
}

Expand Down

0 comments on commit a2585c6

Please sign in to comment.