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

147
Visualizações
Animation delayed because of scroll bounce when scroll reaches end

I am hiding a navbar-like header on scroll. Which is working okay except for one detail. The animation get's delayed when scroll reaches to the top (which is when the header should be animated into vision again), because when it reaches the top it does that "bounce"-animation. THEN my animation triggers, which is something like 500ms to late.

The problem is that I can't figure out how to trigger it instantly when the scroll reaches the top.

I have been trying all different kind of props to ScrollView, I have tried using states to detect when the position is right for a trigger. I have tried all different conditionals I could imagine.

All my solutions has ended up with the animation being triggered when the scroll reaches the top AND the bounce animation has ended, I want it to trigger the same moment the scrollposition has reached 0.

This is how the code looks right now:

        let viewPosition = 0;
        const scrollToHide = (event) => {
        const currentPosition = event.nativeEvent.contentOffset.y;
        const direction =
            currentPosition > 0 && currentPosition > viewPosition
                ? "down"
                : "up";
        const isDescending = direction === "down";
        if (isDescending !== isHidden) {
            LayoutAnimation.configureNext("my animation here");
            setIsHidden(!isHidden);
        }
        // To not trigger animation when scroll goes beyond top end. (the bouncing I'm talking about)
        if (currentPosition < 0) {
            setIsHidden(false);
        }
        // To not trigger animation if the scroll position is not near the top
        if (currentPosition > 10) {
            setIsHidden(true);
        }
        viewPosition = currentPosition;
    };



<ScrollView onScroll={scrollToHide} />
about 4 years ago · Juan Pablo Isaza
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