PedroBern / react-native-collapsible-tab-view

A cross-platform Collapsible Tab View component for React Native
MIT License
868 stars 171 forks source link

when first Render scroll on top forced #277

Open giraaaaaa opened 2 years ago

giraaaaaa commented 2 years ago

I am using dynamic tabs and also each tab's scroll length is diffrent when first tab render (when i change tab) scroll on top forced how can i fix it? 'swip', 'onpress', 'setindex' same have problem i try to using lazy or not its not solved i usuing a week i want to sleep plz help me

giraaaaaa commented 2 years ago
<Tabs.Container
                    // onMoveStart={onMoveStart}
                    headerContainerStyle={style5}
                    // lazy={true}
                    ref={tabRef}
                    minHeaderHeight={52 + inset.top}
                    // revealHeaderOnScroll={true}
                    // onScroll={(event) => {
                    //     Animated.event([{nativeEvent: {contentOffset: {y: yOffset}}}], {useNativeDriver: false})(event);
                    // }}
                    onTabChange={({prevIndex, index, prevTabName, tabName}) => {
                        if (tabName === gallery.replace(/^\s+|\s+$/gm, '')) {
                            console.log('gallery')
                            getPortfolioKeyword();
                        } else {
                            return;
                        }
                        // tabRef.current?.setIndex(index);
                    }}
                    renderTabBar={(props) => (
                        <MaterialTabBar
                            {...props}
                            scrollEnabled
                            style={{paddingHorizontal: 20, borderBottomColor: '#EEEEEE', borderBottomWidth: 1}}
                            labelStyle={Object.assign(
                                {
                                    fontSize: 15,
                                },
                                Fonts.NOTOSANS.BOLD,
                            )}
                            indicatorStyle={{backgroundColor: '#FF8864', width: 50}}
                            activeColor={'#FF8864'}
                            inactiveColor={'#999999'}
                        />
                    )}
                    renderHeader={() =>
                        <RenderListHeader2
                            isLoading={isLoading}
                            detail={detail}
                            // renderOpenTime={renderOpenTime()}
                            renderService={() => renderService()}
                            StoreInPuppy={(item) => {
                                StoreInPuppy(item);
                            }}
                            moveToTop={() => {
                                // console.log('value', tabRef.current);
                                setTimeout(() => {
                                    tabRef.current?.setIndex(4);
                                }, 500);
                            }}
                            offsetCheck={offsetCheck}
                            openRBSheet={() => {
                                rbSheetRef?.open();
                            }}
                            openCouponSheetRef={() => {
                                couponSheetRef?.open();
                            }}
                            onUpdateScrap={() => {
                                onUpdateScrap(detail?.shopDetailInfo);
                            }}
                            storeVisit={() => {
                                setIsClickVisit(true);
                                _storeVisitRef?.show();
                                _storeVisitRef?.visitCertification(true);
                            }}
                        />
                    }>
                    {isLoading === false &&
                        detail?.categoryList?.map((item2, index) => {
                            return renderCategoryList(item2, index);
                        })}
                </Tabs.Container>