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

131
Visualizações
div follow mouse when scroll in javascript

I build a website with some sliders (Wordpress - Divi). I added some javascript to let the slider description follow the mousepointer when the mouse hovers over the slider. Works perfectly, BUT: when I scroll the mouse the pointer shifts downwards as expected, but the slider description does not shift accordingly; it remains where it was. So from that point on the link between the mouse and the description is gone.

Question: how can I enforce the description to follow the mouse when scrolling...... If you want to see the result until now, please check https://roel.famnabuurs.nl

Any help appreciated

The code as requested:

    const sliderzelf = document.getElementById(slidernaam);  
    const titleblockslist = document.getElementById(slidernaam).getElementsByClassName('et_pb_slide_description');  
    for (let indslide of titleblockslist) {
        indslide.style.setProperty('opacity',1, 'important');
        var sliderOffset = sliderzelf.getBoundingClientRect();        
        let xpos = e.clientX - sliderOffset.left ;
        // do not shift too far to the right  
        if (xpos > sliderzelf.clientWidth - indslide.clientWidth) {
          xpos = sliderzelf.clientWidth - indslide.clientWidth;
        } 
        if (xpos < 15) {
          // do not shift too far to the left
          xpos = 15;
    }
    indslide.style.left = (xpos) + 'px';
    indslide.style.top = e.clientY + 'px';
  }
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