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

295
Vistas
After preventing the default scroll event, scrollIntoView(); doesn't work Properly on Firefox desktop?

In my scenario the code should prevent the the default scroll event and use scrollIntoView() to move the user to a specific section according to the scroll direction.

https://stackoverflow.com/a/4770179/9164633 I used this method to prevent the scroll default event.
And I detect the direction like so,

preventDefault(e) {
  e.preventDefault(); 
  if(this.waiting == false && this.forceInitialScroll != true) {
    if(e.deltaY && e.deltaY > 7) {
      this.scrollDirection = 'down';
        this.checkScroll()
    }else if(e.deltaY && e.deltaY < -7) {
      this.scrollDirection = 'up';
        this.checkScroll()
    }else {
      
    }
  }
},

and Im pretty sure that both are working fine.

After preventing the scroll and detecting the scroll direction I try to scroll the user to the section like so,

checkScroll() {
     let element;
     if(this.scrollDirection == 'down' && this.scrollIndex != 4 ) {
       element = document.getElementById(`section-${this.scrollIndex+1}`);
     }else if(this.scrollDirection == 'up' && this.scrollIndex != 0) {
       element = document.getElementById(`section-${this.scrollIndex-1}`);
     } 
     this.waiting = true;
     if(element) {
       console.log(element)
       element.scrollIntoView({
         behavior: 'smooth',
         block: 'center',
       })
     }
     setTimeout(() => {
       if(this.waiting == true) {
         this.waiting = false;
         this.scrollDirection = null;
       }
     }, 450)
   },

this.waiting is used to prevent the user form scrolling more than one section at a time.
On firefox the browser doesnt scroll the user properly though its working fine on chrome.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Apparently Firefox's behavior with event.preventDefault() was that it blocked any kind of user scrolling and even the js manual scrolling.

The problem in my case was solved by hiding the scroll in css instead of js by using overflow: hidden; and then controlling the scroll manually instead of preventing the default behavior.

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