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

170
Visualizações
lock vertical scrolling while horizontal scrolling is in progress in carousel

I'm working in a Vue.js app and in one of the pages I have 3 carousels that the user scrolls horizontally, I would like to disable the vertical scroll because right now when the user is scrolling horizontally the layout moves up and down a little bit.

I found a way to disable the vertical scroll (actually all the scrolling functionality) but in order to scroll up or down, the user need to start touching the screen outside the carousel which results in a worst user experience.

this is my current solution:

// Method for handling scroll
const touchMoveHandler = event => {
  if(event.cancelable) event.preventDefault();
}

// Get all the carousels
let carousels = document.querySelectorAll('.v-scroller');

// Handle scrolling
for (const carousel of carousels) {

  // Add event listener on touchstart to remove scrolling functionality
  carousel.addEventListener('touchstart', event => {
    window.addEventListener('touchmove', touchMoveHandler(event), {passive: false});
  });

  // Remove previous event listener on touchend
  carousel.addEventListener('touchend', event => {
    window.removeEventListener('touchmove', touchMoveHandler(event));
  });
}

In websites like twich.tv/netflix there are some carousels which once you started to scroll horizontall you can't scroll vertically. But if you touch the carousel and instead of scrolling horizontally you scroll vertically you can go up or down.

Any ideas on how they implemented this?

Any help would be appreciated, thanks in advance.

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