- Notifications
You must be signed in to change notification settings - Fork 647
Description
I am trying to leverage this component with custom components, events, and even a multiline TextInput (custom growing component). I think moving forward what I need is to be able to fire an event to force an update. This would be recalculating scroll position based on a view or component changing it's size.
What I've tried thus far is to add an update function to the render method.
return ( <ScrollableComponent ... onScroll={this._onScroll} update={this.update} /> ) Now, some help moving forward to force this update would be much appreciated. So far I've tried the following methods with no success.
scrollIntoView(el) // Weird behavior, see below scrollToFocusedInput(el) // Weird JSON stringify errors this._resetKeyboardSpace() // this throws due to it being a Keyboard listener event. this._updateKeyboardSpace // this throws due to it being a Keyboard listener event. scrollIntoView(el) does something weird. When calling this, the screen bounces around. What I'm looking for is just to nudge the keyboard up to the bottom of this component when it's starting to scroll off screen.
Perhaps getting the coords (in conjunction with _measureElement) of the component and then firing resetScrollToCoords would work.
The code I ended up with, and similar results to scrollIntoView (with no surprise since the code was borrowed from around there).
update = async (element) => { if (!this._rnkasv_keyboardView || !element) { return } const [ parentLayout, childLayout ] = await Promise.all([ this._measureElement(this._rnkasv_keyboardView), this._measureElement(element) ]) const getScrollPosition = this._defaultGetScrollPosition const { x, y, animated } = getScrollPosition(parentLayout, childLayout, this.position) this.scrollToPosition(x, y, animated) } Any and all help is much appreciated.