Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

209
Visualizações
Hide and show on scroll right and left React-Native
  1. In React Native, I am trying to create a Flatlist horizontal with right and left arrows, and I hope to make arrows to be visible and invisible on press on condition that it stays invisible if it is already on the side of right or left until condition changes
  2. I want left arrow be invisible in default
  3. when pressed right arrow, right arrow should be invisible while left arrow becomes visible and vice-versa
  4. however it should not be visible if you press two or three times the same arrow

  const leftScrollHandler = () => {
    listViewRef.scrollToOffset({ offset: 0.5, animated: true });
  };

  const rightScrollHandler = () => {
    //OnCLick of right button we scrolled the list to bottom
    listViewRef.scrollToEnd({ animated: true });
  };
  // this below is for scroller to apear and disapear funtionality

  const [backgroundColor, setBackgroundColor] = useState("transparent");
  const [backgroundColor2, setBackgroundColor2] = useState(colors.secondary);
  const [pressed, setPressed] = useState(false);
  function changeColor() {
    if (!pressed) {
      setPressed(true);
      setBackgroundColor(colors.secondary);
      setBackgroundColor2("transparent");
    } else {
      setPressed(false);
      setBackgroundColor2(colors.secondary);
      setBackgroundColor("transparent");
    }
  }

 <FlatList
        horizontal={true}
        showsHorizontalScrollIndicator={false}
        data={Data}
        keyExtractor={(item, index) => [item.id, index.toString()]}
        renderItem={renderItem}
        ref={(ref) => {
          listViewRef = ref;
        }}
      />
      <TouchableOpacity
        activeOpacity={0.5}
        onPress={() => {
          changeColor();
          leftScrollHandler();
        }}
        style={
          (web && isTablet) || isDesktop
            ? styles.leftScrollDesktop
            : styles.leftScroll
        } >
        <AntDesign
          style={styles.leftArrow}
          name="arrowleft"
          size={(web && isTablet) || isDesktop ? 50 : 35}
          color={backgroundColor}
        />
      </TouchableOpacity>
      <TouchableOpacity
        activeOpacity={0.5}
        onPress={() => {
          changeColor();
          rightScrollHandler();
        }}
        style={
          (web && isTablet) || isDesktop
            ? styles.rightScrollDesktop
            : styles.rightScroll
        }
      >
        <AntDesign
          style={styles.rightArrow}
          name="arrowright"
          size={(web && isTablet) || isDesktop ? 50 : 35}
          color={backgroundColor2}
        />
      </TouchableOpacity>
about 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda