malsup / cycle2

2nd gen cycling
899 stars 236 forks source link

Element duplicate 4 Times #741

Open mcherubin opened 8 years ago

mcherubin commented 8 years ago

I've this html:

<div class="prese" </code>
    data-cycle-fx="carousel" 
    data-cycle-timeout="0" 
    data-cycle-next="#prese-right"
    data-cycle-prev="#prese-left"
    data-cycle-slides="> div">     

</div>

I add slides programmatically in this way

$('.prese').html('');
var html='<div><img src="..." >...text....</div>';
$('.prese').append(html);

when I finish to add element i call:

$('.prese').cycle();

if I inspect html after cycle call I found my element duplicate 4 times, any ideas?

jstnthms commented 8 years ago

I noticed this too. I have a container that shows 4 items, and they are each duplicated 3 times.

Perhaps this has something to do with more efficient animation? (eg. Moving the container, rather than each element within the container.)

ryangiglio commented 8 years ago

Yeah @jstnthms that's the reason - it's duplicating so that the cycle can move left/right without having to shuffle the elements around. If you watch it as it cycles you'll notice it moves them in chunks as you go farther in one or the other direction.