Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

142
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!