Arrow to move to the right of the page does not stop at the end

Asked

Viewed 51 times

1

Good afternoon,

I’m in need of a help because I built a horizontal page that besides the scroll of the mouse it also uses the arrows on the side for the drive, but the more you press the arrows, the more it advances regardless of whether it has reached the end of the page or not, I send the code I used, I wonder if you could give me a hand:

var projObj = null;

function init(){
   projObj = document.getElementById('PagProjetos');
   projObj.style.position= 'relative'; 
   projObj.style.right = '0px';
}

function moveRight(){
   projObj.style.right = parseInt(projObj.style.right) + 600 + 'px';

}
function stop(){
   projObj.style.right = '0px'; 
}

window.onload =init;

Thank you very much

1 answer

0

I did some research and managed to get to the code below, but it still didn’t work, I wonder if someone could give a help?

<script>

function init(){
   projObj = document.getElementById('PagProjetos');
   projObj.style.position= 'relative'; 
   projObj.style.right = '0px';

  totalDeImagens = document.getElementeByName('nomeDasImagens');
}

function moveRight(){

  if(contadorDeImages< totalDeImagens){
    projObj.style.right = parseInt(projObj.style.right) + 600 + 'px';
    contadorDeImages++;
  }else{
    projObj.style.right = '0px';
    contadorDeImages = 0;
  }
}
function stop(){
   projObj.style.right = '0px'; 
}

window.onload =init;

//-->

Browser other questions tagged

You are not signed in. Login or sign up in order to post.