ilkeryilmaz / timelinejs

🎬 jQuery timeline plugin, easily creates timeline slider.
https://ilkeryilmaz.github.io/timelinejs/
882 stars 119 forks source link

Loop ? #5

Open judzk opened 6 years ago

judzk commented 6 years ago

Any way to made a loop so after the last item the timeline go to the first one?

rewrite123 commented 5 years ago

/ Just change these two functions accordingly and include loopAround: true in the options ;) /

get_next: function () { var self = this; var result = self.get_current() + 1; if(self.options.loopAround && self.get_current() >= self.get_count() -1){ result = 0; } return result; },

change_slide: function (type, itemIndex) { var self = this; if(!type) type='load'; if (type === 'click'){ self.options.startItem = itemIndex; self.autoplay_init(); }else { if (self.get_count() - 1 > self.get_current() && self.initials.direction === 0){ self.options.startItem = self.get_next(); }else if(self.get_current() > 0 && self.initials.direction === 0) { self.options.startItem = self.get_next(); self.change_timeline(); }else { self.autoplay_clear(); } } self.change_timeline(); },