0
I am doing a work with images and I have the code below:
var tempoTransicao = 5;
var quantasImagens = $("ul.slider li img").size();
var tamanhoIntervalos = Math.round(100/quantasImagens);
var t = 0;
for (i = 1; i <= quantasImagens; i++) {
tMin = t + tempoTransicao;
tMax = t + tamanhoIntervalos;
t+=tamanhoIntervalos;
//if(t=~100) i=quantasImagens;
alert("tMin: "+tMin);
alert("tMax: "+tMax);
alert("t: "+t);
}
The idea is a bond for
that passes in run from 0 to 100%, filling tables of tamanhoIntervalos %
. Everything works fine, but I need to figure out a way when I get to the last loop, do i=quantasImagens
.
That is my difficulty, because in the last iteration almost never the variable tMax
will receive value 100%
.
I also tried with the variable i
iterating from 0 to 100%:
for (i = 0; i <= 100; i++) {
tMin = i + tempoTransicao;
tMax = i + tamanhoIntervalos;
if (i == 0 ) {
tMin = 0;
} else if (i == 100) {
//tMax = 100;
}
//alert("tempoTransicao: "+tempoTransicao);
//alert("tMin: "+tMin);
//alert("tMax: "+tMax);
i = tMax==100 ? 100 : tMax-1;
}
HTML
<ul class="slider">
<li>
<img src="_imgs/_slideShow/1.png" />
<img src="_imgs/_slideShow/2.png" />
<img src="_imgs/_slideShow/3.png" />
</li>
</ul>
Someone help me find that logic?
In the first
for
, to identify the last iteration you can doif (i == quantasImagens) { ... }
– Woss
Can you help me with that question by doing me a favor? https://answall.com/questions/249014/crea-uma-anima%C3%A7%C3%A3o-com-jquery
– Carlos Rocha