js/foundation/foundation.orbit.js in zurb-foundation-4.1.6 vs js/foundation/foundation.orbit.js in zurb-foundation-4.2.0

- old
+ new

@@ -4,14 +4,16 @@ Foundation.libs = Foundation.libs || {}; Foundation.libs.orbit = { name: 'orbit', - version: '4.1.0', + version: '4.2.0', settings: { timer_speed: 10000, + pause_on_hover: true, + resume_on_mouseout: false, animation_speed: 500, bullets: true, stack_on_small: true, navigation_arrows: true, slide_number: true, @@ -37,10 +39,15 @@ if (typeof method === 'object') { $.extend(true, self.settings, method); } + if ($(scope).is('[data-orbit]')) { + var scoped_self = $.extend(true, {}, self); + scoped_self._init(idx, el); + } + $('[data-orbit]', scope).each(function(idx, el) { var scoped_self = $.extend(true, {}, self); scoped_self._init(idx, el); }); }, @@ -117,11 +124,11 @@ // To better support the "sliding" effect it's easier // if we just clone the first and last slides $slides_container.append($slides.first().clone().attr('data-orbit-slide','')); $slides_container.prepend($slides.last().clone().attr('data-orbit-slide','')); // Make the first "real" slide active - $slides_container.css('marginLeft', '-100%'); + $slides_container.css(Foundation.rtl ? 'marginRight' : 'marginLeft', '-100%'); $slides.first().addClass(self.settings.active_slide_class); self._init_events($slides_container); self._init_dimensions($slides_container); self._start_timer($slides_container); @@ -159,9 +166,19 @@ self._reset_timer($slides_container, true); self._goto($slides_container, $(e.currentTarget).data('orbit-slide-number'),function() {}); }); $container + .on('mouseenter.fndtn.orbit', function(e) { + if (self.settings.pause_on_hover) { + self._stop_timer($slides_container); + } + }) + .on('mouseleave.fndtn.orbit', function(e) { + if (self.settings.resume_on_mouseout) { + self._start_timer($slides_container); + } + }) .on('orbit:after-slide-change.fndtn.orbit', function(e, orbit) { var $slide_number = $container.find('.' + self.settings.slide_number_class); if ($slide_number.length === 1) { $slide_number.replaceWith(self._slide_number_html(orbit.slide_number, orbit.total_slides));