Capítulo 179 de 411
A responsive, ticker/slider-style helper: elements scroll along the x-axis and wrap back around seamlessly, using xPercent so it stays correct even if element widths change (e.g. on resize).
horizontalLoop(items, config) returns a Timeline with extra navigation methods attached: next(), previous(), toIndex(i) (always shortest direction), current().config options include speed (default ~100px/sec), paused, repeat, reversed, paddingRight.times: array of the timeline times where each item reaches the "starting" position; matching labels (label1, label2...) are added too.xPercent instead of x specifically so it remains correct if the elements' actual pixel widths change responsively.let loop = horizontalLoop(gsap.utils.toArray(".box"), { paused: true, repeat: -1 });
loop.next({ duration: 0.5, ease: "power1.inOut" });
loop.toIndex(3, { duration: 1 });
next()/toIndex() API this helper adds on top of a normal Timeline for slider-style navigation.