Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

81
Vistas
JS parallax effect / only usable for Images/Elements that are not positioned at the top

I'm currently trying to create a lightweight parallax effect in JS. The only problem that i'm running into is, when i try to assign the effect to elements mid-document. Here's the current code:

[].forEach.call(document.getElementsByClassName('parallax'), function (v) {
    window.addEventListener('scroll', function () {
        let eTop = $('parallax').offset();
        let value = window.scrollY;
        v.style.top = value * .5 + 'px';
    });
});

If i now assign the 'parallax' class to objects below the top position they get weirdly transformed because their respective position is calculated using window.scollY resulting in heavily transformed positions. I guess the best way to deal with it is to subtract the elements actual position on the document, right? And if so how to do it? (newbie here)

Thamks in advance!

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda