import * as React from 'react'; import { View, Animated } from 'react-native'; import { TABVIEW_SCENE_SCROLL_TOP } from '../Const' import { SlideSceneContainerProps } from '../types' import { NativeViewGestureHandler, PanGestureHandlerStateChangeEvent } from 'react-native-gesture-handler'; const invariant = require('invariant') export default class SlideSceneContainer extends React.Component> { componentDidMount() { invariant(this.props.scrollToTop !== undefined, "scrollToTop must not be undefined"); this.addListener() } componentWillUnmount() { this.removeListener() } public render() { const { style, forwardedRef, index, childRefs, containerTrans, sceneScrollEnabled, ContainerView, ...rest } = this.props; return ( ); } addListener() { const { addListener } = this.props if (addListener !== undefined) { addListener(this, TABVIEW_SCENE_SCROLL_TOP, this._scrollToTop) } } removeListener() { const { removeListener } = this.props if (removeListener !== undefined) { removeListener(this, TABVIEW_SCENE_SCROLL_TOP, this._scrollToTop) } } getOnScroll() { const { containerTrans, isActive } = this.props if (isActive) { return Animated.event([{ nativeEvent: { contentOffset: { y: containerTrans } } }], { useNativeDriver: true, listener: this._onScroll }) } else { return this._onScroll } } _onScroll = (e: any) => { this.props.scrollYTrans.setValue(e.nativeEvent.contentOffset.y) this.props.onScroll && this.props.onScroll(e) } _scrollToTop = () => { if (this.props.isActive) return; this.props.scrollToTop && this.props.scrollToTop() } }