jeudi 25 avril 2019

auto-increment slide handle up and down at the same rate

I have a slide handle and I want to auto-increment this up and down repeatedly at the same rate between a range of 1 and 1000 increments. I've implemented a main callback function, 2 setInterval functions, if statements, and clearInterval script but not sure whether they're actually necessary to get this function to work accurately. In the state that this function is now it is too unpredictable. Additionally, it would be helpful for someone to actually point out what the relationship between the actual numeric values in this function are.

<script>

var clickcallback = function(i) {
  setInterval(function() {
    let id1 = "button" + i;
    document.getElementById("slide_up").click();


  }, 1000); // one second
  if(i<=0 ) {
    clickcallback(i+1);
  }
  clearInterval(i);

   setInterval(function() {
    let id2 = "button" + i;
    document.getElementById("slide_down").click();


  }, 1000); // one second
  if(i >=0) {
    clickcallback(i+1);
  }

  clearInterval(i);
};
clickcallback(1);

</script>

Aucun commentaire:

Enregistrer un commentaire