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

228
Visualizações
Opacity reduction script does not working

I have a problem with a script that until recently worked, but now seems not to want to work. I want to reduce the opacity of the green spheres when scrolling down, it seems to be working until recently, but now I can't figure out what the problem is.

The website is this: https://attiliosantomo.com/PROVA/

The script is this:

        $(document).ready(function() {
            $(window).scroll(function(event) {
                let scroll = $(this).scrollTop();
                let opacity = 1 - (scroll / 1300);
                if (opacity > 0.2) {
                    $('.bg-bubble').css('opacity', opacity);
                }
            });
        });
        </script>

Thank you so much for you help

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The issue is that it's not the window that is scrolling. It's the .main-desktop element that is being scrolled. Targeting the scroll event of the .main-desktop as per below should solve the issue.

$(document).ready(function() {
    // \/ Changed \/ selector from window to '.main-desktop'
    $('.main-desktop').scroll(function(event) {
        let scroll = $(this).scrollTop();
        let opacity = 1 - (scroll / 1300);
        if (opacity > 0.2) {
            $('.bg-bubble').css('opacity', opacity);
        }
    });
});
html,
body {
 height: 100%;
 margin: 0;
}
.main-desktop {
 overflow: scroll;
 height: 100%;
}
.inner {
 height: 3000px;
}
.bg-bubble {
 height: 100px;
 width: 100px;
 background-color: blue;
 position: absolute;
 top: 0;
 left: 0;
 border-radius: 50%;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="bg-bubble"></div>
<div class="main-desktop">
  <div class="inner"></div>
</div>

about 4 years ago · Juan Pablo Isaza Relatório
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