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

287
Visualizações
addEventListener touchstart and touchend not working

Script is functioning as expected on a PC, but nothing happens in the mobile version.

How do I get it working so that a swipe left or right moves the div accordinly?

More stuff here so I can actually submit all the code.

document.addEventListener("touchstart", touchStart, false);
document.addEventListener("touchend", touchEnd, false);
document.addEventListener("mousedown", touchStart, false);
document.addEventListener("mouseup", touchEnd, false);
var xDown = null;
var yDown = null;
function touchStart(event)
{
    xDown = event.clientX;
    yDown = event.clientY;
} 
function touchEnd(event)
{
    var currentPlayerPosition = parseInt(window.getComputedStyle(playerModel, null).getPropertyValue('left'));
    if ( ! xDown || ! yDown ) {
        return;
    }
    var xUp = event.clientX;                                    
    var yUp = event.clientY;
    var xDiff = xDown - xUp;
    var yDiff = yDown - yUp;                                                                     
    if ( Math.abs( xDiff ) > Math.abs( yDiff ) ) {
        if ( xDiff > 0 ) {
            if(currentPlayerPosition <= "25")
            {
                return;
            }                document.getElementById("playerModel").style.left = currentPlayerPosition - 25 + "px";
        } else {
            if(currentPlayerPosition >= "230")
            {
                return;
            }               document.getElementById("playerModel").style.left = currentPlayerPosition + 25 + "px";
        }                       
    } else {
        if ( yDiff > 0 ) {
        } else { 
        }                                                                 
    }
    xDown = null;
    yDown = null;       
}
about 4 years ago · Santiago Trujillo
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