How to autoscroll a horizontal scrollview in react native just like marquee tag in html

86 views Asked by At

I have a horizontal scrollview and I want continuously scrolling from left to right just like marquee tag in html.

Here is the code.

<ScrollView  ref={scrollRef} horizontal={true} showsHorizontalScrollIndicator={false} contentContainerStyle={{ flexDirection:"row",alignItems:"center",height:responsiveHeight(12),paddingLeft:responsiveWidth(3.2)}}>
        {homeCompanies.length > 0 && <>
          {homeCompanies.reverse().map((company, index) => {
            return (
              <TouchableOpacity key={index} onPress={() => goToEmployerDetails(company)}>
                <View style={styles.homeSingleEmployer}>
                  <Image style={styles.homeSingleEmployerImage} source={{uri: company.images[0].regular}}/>
                </View>
              </TouchableOpacity>
            );
          })}
        </>
        }
</ScrollView>

and I have a function to scroll it

 const scroll = () => {

  scrollRef.current?.scrollTo({
    x: 400,
    animated: true,
  });

};

But it's only scrolling one time. I want it continuously from left to right and repeat it.

Any type of help or guidance will be highly appreciated. Here is the image for reference.

this is the image

0

There are 0 answers