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

143
Visualizações
Flickering on scroll when section is visible

I have a problem with my code when the section is visible, there's a flickering happening on the frontend. The elements inside that section are flickering when on viewpoint. Here's my Jquery Code:

jQuery( document ).ready(function($) {


$(window).scroll(function() {
    var windowBottom = $(this).scrollTop() + $(this).innerHeight();
        var window_height = $(window).height(); 
            var scrollMiddle = $(window).scrollTop() + (window_height/2);
  
$(window).scroll(function() {
    
    $(".fading-section").each(function() {
        var classes = $(this).attr("class").split(/\s+/);
        var objectBottom = $(this).offset().top + $(this).outerHeight();
        var objectTop = $(this).position().top;
        var section_bg = $(this).find(".uagb-section__overlay").css("background-color");
        
        
        if (scrollMiddle >= objectTop && scrollMiddle <= objectBottom) { //object comes into view (scrolling down)
            
            
                $("body.page-id-2899").stop(false,false).animate({ backgroundColor: section_bg}, 750);
                $(this).addClass('visible-section');
                $(this).removeClass('notvisible-section');
                
            
        } else {
                $(this).removeClass('visible-section');
                $(this).addClass('notvisible-section');
                
            
        }
        
        
        //console.log(classes);
        //console.log(section_bg);
        //console.log("Object Top:" + objectTop);
        //console.log("Object Bottom:" + objectBottom);
        //console.log("The Middle:" + scrollMiddle);
        //console.log("Height of the screen:" + window_height);
    });
});  

 }); //invoke scroll-handler on page-load
});

This code will just set the opacity to 1 when I add the class on that section.

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