well, i'm a bit loose with setInterval et clearInterval...
I need to repeat 3 time a function with a time of 200ms
I've tried this
id = setInterval( function(a,b,c) { console.log(a,b,c);} ,200, "foo", 25, id);
in the console it said
foo 25 undefined
i've tried to use the id and it "works" (it stop)
var idAnim;
var compteur = 0;
function anim(a,b,c) {
compteur++;
console.log(compteur,a,b,c);
if (compteur >= a.length){ clearInterval(c); }
}
function onInit() {
idAnim = setInterval( anim, 500, "foo", 0, idAnim);
}
and it stops after 3 time.
i've tried the same in a function in a setInterval and it stops all the setInterval
var idAnim;
var compteurAnim = 0;
var mot = "foo";
function texte(){
idAnim = setInterval(function(a,y,c){
console.log(a,y);
compteurAnim++;
if (compteurAnim >= a.length) { clearInterval(c);}
}, 100, mot, 0, idAnim);
mot+="foo";
}
function onInit() {
setInterval( texte, 4000);
}
where i'm wrong?
is there a way to pass the id to function?
or is there a simple way to repeat a definite time a function?
i want to animate text letter by letter
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Hello,
well, i'm a bit loose with setInterval et clearInterval...
I need to repeat 3 time a function with a time of 200ms
I've tried this
in the console it said
i've tried to use the id and it "works" (it stop)
and it stops after 3 time.
i've tried the same in a function in a setInterval and it stops all the setInterval
where i'm wrong?
is there a way to pass the id to function?
or is there a simple way to repeat a definite time a function?
i want to animate text letter by letter
regards
éric