Ciao a tutti,
con js ho impostato che il valore top di un immagine varia nel tempo

codice:
var img = document.getElementById("imgEs");				 
      var counter = 0;
    myVar = setInterval(function(){
        counter += -0.07;
        img.style.top = img.innerHTML += counter.toString() + '%';
      }, 1);
ora vorrei fermare tale funzione quanto top raggiunge il valore -200% ma così non funziona
codice:
setInterval(function(){
					 if (img.style.top < -50 + '%') {
   clearInterval(myVar);
  } 
      }, 1);
Come potrei risolvere?
Grazie