DraxScrollView scrollTo function is undefined.
See original GitHub issueI am trying to make the card center of the DraxScrollView which will have the dynamic width based upon the number of the cards DraxScrollView is acquiring.
I have used <DraxScrollView contentContainerStyle={[styles.receivedZone,]} alwaysBounceVertical={true} maximumZoomScale={10} minimumZoomScale={-2} directionalLockEnabled={false} horizontal={true} ref={(ref) => this.draxScrollViewRef = ref.getNodes()} > <View onLayout={event => this.layout = event.nativeEvent.layout} style={{ position: 'relative', width: 105, height: 105, overflow: 'visible' }} > <Text>Cards content</Text> </View> </DraxScrollView>
The reference is then used on ` componentDidMount = async () => {
setTimeout(() => {
this.draxScrollViewRef.getNodes().scrollTo({
y: this.layout.y,
x: this.layout.x - GlobalItem.deviceWidth / 2 + 55,
animated: false
})
}, 100);
}`
But the end result is TypeError: _this.draxScrollViewRef.getNodes is not a function. (In '_this.draxScrollViewRef.getNodes()', '_this.draxScrollViewRef.getNodes' is undefined)
What can be done?
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
I have found the solution to access ScrollView ref by exporting onScrollRefNew on line number 30.
Previous Code // Set the ScrollView and node handle refs.
New Code // Set the ScrollView and node handle refs.
I believe the current implementation of
DraxScrollView
does not provide a way to access the internalScrollView
ref. I think it needs to be enhanced to support the functionality you’re requesting.