Comcast / Xooie

Important note: this project is no longer actively maintained. Xfinity Xooie - Modular, Modifiable, Responsive, Accessible
Apache License 2.0
14 stars 20 forks source link

Carousel: Create autorotate addon #5

Open andrewlarkin opened 11 years ago

andrewlarkin commented 11 years ago

The carousel needs an addon to rotate by item or page automatically. This should work like the tab automation module

andrewlarkin commented 10 years ago

From Helene's code: var args = self.root().attr('data-x-role').split(':'); if (args[0] === 'auto') { self._timers.auto = setInterval(function() { if (self.isRight()) { self._positioners.item.apply(self, ['goto', '1', 'item']); } else { self._positioners.item.apply(self, ['right', '1', 'item']); } }, parseInt(args[1])*1000); }

This is a good start, we should use this to create an addon

helenezspeer commented 10 years ago

My team isn't entirely happy with the way the carousel "rewinds" back to the first position when it comes to the last item. They expect it to loop back to the first position in the same direction that it's been going. They also want the arrow buttons to work the same way. For instance, in a left-to-right carousel with four items, clicking the right arrow from item 4 should scroll "forward" to item 1.

javallone commented 10 years ago

We've done that with carousels in the past. The easiest way to do it was the duplicate the first n items (where n is enough items to fill a "page" of the carousel) after the last item in the carousel. Then, allow the user to scroll past the last item.

Once the carousel is displaying only the duplicated page of items, reset its position to show the originals (a little math is needed to make sure everything lines up when you do this).

When scrolling to the left, you start by repositioning to the duplicated items and allow scrolling to the left as usual.

This should probably be another addon for the carousel, but I defer to Andrew for that.