js/foundation/foundation.orbit.js in zurb-foundation-4.3.0 vs js/foundation/foundation.orbit.js in zurb-foundation-4.3.1
- old
+ new
@@ -2,10 +2,15 @@
'use strict';
var noop = function() {};
var Orbit = function(el, settings) {
+ // Don't reinitialize plugin
+ if (el.hasClass(settings.slides_container_class)) {
+ return this;
+ }
+
var self = this,
container,
slides_container = el,
number_container,
bullets_container,
@@ -193,10 +198,11 @@
animate = new FadeAnimation(slides_container);
if (settings.animation === 'slide')
animate = new SlideAnimation(slides_container);
container.on('click', '.'+settings.next_class, self.next);
container.on('click', '.'+settings.prev_class, self.prev);
+ container.on('click', '[data-orbit-slide]', self.link_bullet);
container.on('click', self.toggle_timer);
container.on('touchstart.fndtn.orbit', function(e) {
if (!e.touches) {e = e.originalEvent;}
var data = {
start_page_x: e.touches[0].pageX,
@@ -243,11 +249,10 @@
timer.start();
}
});
$(document).on('click', '[data-orbit-link]', self.link_custom);
- $(document).on('click', '[data-orbit-slide]', self.link_bullet)
$(window).on('resize', self.compute_dimensions);
$(window).on('load', self.compute_dimensions);
slides_container.trigger('orbit:ready');
};
@@ -302,22 +307,24 @@
};
};
var SlideAnimation = function(container) {
var duration = 400;
+ var is_rtl = ($('html[dir=rtl]').length === 1);
+ var margin = is_rtl ? 'marginRight' : 'marginLeft';
this.next = function(current, next, callback) {
- next.animate({'marginLeft': '0%'}, duration, 'linear', function() {
- current.css('marginLeft', '100%');
+ next.animate({margin: '0%'}, duration, 'linear', function() {
+ current.css(margin, '100%');
callback();
});
};
this.prev = function(current, prev, callback) {
- prev.css('marginLeft', '-100%');
- prev.animate({'marginLeft':'0%'}, duration, 'linear', function() {
- current.css('marginLeft', '100%');
+ prev.css(margin, '-100%');
+ prev.animate({margin:'0%'}, duration, 'linear', function() {
+ current.css(margin, '100%');
callback();
});
};
};
@@ -345,11 +352,11 @@
Foundation.libs = Foundation.libs || {};
Foundation.libs.orbit = {
name: 'orbit',
- version: '4.3.0',
+ version: '4.3.1',
settings: {
animation: 'slide',
timer_speed: 10000,
pause_on_hover: true,
@@ -400,6 +407,6 @@
});
}
};
-}(Foundation.zj, this, this.document));
\ No newline at end of file
+}(Foundation.zj, this, this.document));