Good morning people!
I have a difficult question to solve.
Actually, I do not even want a solution, but I teach:
So imagine an ul with, say, 5 li's. These li's are inline-block.
I'll apply a slideShow effect on them so they run from right to left. So far without mysteries: It works well.
My question is this: For each li that runs, a smooth running effect is applied from -0% to -100% in its (normal) position. This, of course, added 100 to 100 to each passing li. No surprise.
The doubt:
When the li's come to the end, when the first li replays again, it does not appear at the same time, but it seems that before starting the second sequence, the slider gives a little time, which here in the case seems to be of some 4 seconds, and then the first li appears as a simple display: none for the last and display: block on the first.
What I would like is that when the first sequence is finished, the second one starts together, that is, then, as if they were more in line.
The way it looks at the end of the question.
Here is the code I am using:
- $(document).ready(function(e) {
- var tempoTransicao = 20;
- var quantasImagens = $("div.slider ul.slide li img").size();
- var tamanhoIntervalos = 100/quantasImagens;
- var tempoImagens = 0;
- var tMax = 0;
- var obj = new Array();
- for (i = 0; i < quantasImagens; i++) {
- tMin = tMax;
- tMax += tamanhoIntervalos;
- obj[tMin + '%'] = { 'margin-left': '-' + tempoImagens + '%'};
- obj[tMax + '%'] = { 'margin-left': '-' + tempoImagens + '%'};
- tempoImagens += 100;
- }
- console.log(obj);
- $.keyframe.define(
- [
- $.extend(
- { name: 'tocaSlide' },
- obj
- )
- ]
- );
- $("div.slider ul.slide").css({
- 'animation-duration' : tempoTransicao + 's',
- 'width' : (100.1 * quantasImagens) + '%',
- });
- });
If I put inside the for:
- if (i == how many Images - 1) obj ['100%'] = {'margin-left': '0%'};
- So when you get to the last li, the slider comes back li li li to the first and resumes.
But that's not what I want.
What I want is the sequence to continue:
If i do as below after the loop, it only occurs from the first image appears after the last one. But this does not solve the problem of the first read abruptly.
- $ ("div.slider ul.slide li: first"). insertAfter ($ ("div.slider ul.slide li: last"));
- $ ("div.slider ul.slide"). css ('margin-left', '-' + 100 + '%');
How to proceed to do this?
I made an image to exemplify what I want.