Skip to content

Commit 813feb6

Browse files
committed
Allow scroll to bottom without animation, also, if we still don't know the contentSize when scrollToBottom is requested - wait for it.
1 parent 9ce9b2c commit 813feb6

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/KeyboardAwareBase.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,16 @@ export default class KeyboardAwareBase extends React.Component {
9393
this.state.scrollBottomOnNextSizeChange = true;
9494
}
9595

96-
scrollToBottom() {
96+
scrollToBottom(scrollAnimated = true) {
9797
if (this._keyboardAwareView) {
98+
99+
if(!this._keyboardAwareView.contentSize) {
100+
setTimeout(() => this.scrollToBottom(scrollAnimated), 50);
101+
return;
102+
}
103+
98104
const bottomYOffset = this._keyboardAwareView.contentSize.height - this._keyboardAwareView.layout.height + this._keyboardAwareView.props.contentInset.bottom;
99-
this._keyboardAwareView.scrollTo({x: 0, y: bottomYOffset, animated: true});
105+
this._keyboardAwareView.scrollTo({x: 0, y: bottomYOffset, animated: scrollAnimated});
100106
}
101107
}
102108
}

0 commit comments

Comments
 (0)