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

281
Visualizações
How to stop SwipeJS event propagate to child component (VideoJS)

I have a React Swiper component with a collection of Video.JS children component to play videos on mobile devices, and a touchend event attached to the VideoJS children to play and pause the video. But when on swipe end event it will also play the video while the touchend is triggered. How do I stop event propagate down, I tried this doesn't work.

       <Swiper
          direction='vertical'
          spaceBetween={50}
          slidesPerView={1}
          onTouchMove={(s, e) => {
            e.preventDefault;
            e.stopPropagation;
          }}
        >
          {
            shorts.map((short: {id: number, display_image: String, file: string}) => {
              return (
                <SwiperSlide key={short.id}>
                  <Short short={short} />
                </SwiperSlide>
              )
            })
          }
        </Swiper>

And my VideoJS componenet

const Short = ({ short }) => {
  const playerRef = React.useRef(null);

  const videoJsOptions = {
    controls: true,
    bigPlayButton: false,
    responsive: true,
    sources: [{
      src: short.file,
      type: 'video/mp4'
    }],
    inactivityTimeout: 0,
  };

  const handlePlayerReady = (player) => {
    playerRef.current = player;

    // You can handle player events here, for example:
    player.on('ready', () => {
      player.playsinline(true);

      player.on('touchend', function(e) {
          if (window.isSwiping) {
            if (player.paused()) {
              player.play();
            } else {
              player.pause();
            }
          }
      });
    });
  };

  return (
    <>
      <VideoJS options={videoJsOptions} onReady={handlePlayerReady} />
    </>
  );
};

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