vendor: 3,008 bytes, lines 1-121
1/** 2 * Animate Plugin 3 * @version 2.1.0 4 * @author Bartosz Wojciechowski 5 * @author David Deutsch 6 * @license The MIT License (MIT) 7 */ 8;(function($, window, document, undefined) { 9 10 /** 11 * Creates the animate plugin. 12 * @class The Navigation Plugin 13 * @param {Owl} scope - The Owl Carousel 14 */ 15 var Animate = function(scope) { 16 this.core = scope; 17 this.core.options = $.extend({}, Animate.Defaults, this.core.options); 18 this.swapping = true; 19 this.previous = undefined; 20 this.next = undefined; 21 22 this.handlers = { 23 'change.owl.carousel': $.proxy(function(e) { 24 if (e.namespace && e.property.name == 'position') { 25 this.previous = this.core.current(); 26 this.next = e.property.value; 27 } 28 }, this), 29 'drag.owl.carousel dragged.owl.carousel translated.owl.carousel': $.proxy(function(e) { 30 if (e.namespace) { 31 this.swapping = e.type == 'translated'; 32 } 33 }, this), 34 'translate.owl.carousel': $.proxy(function(e) { 35 if (e.namespace && this.swapping && (this.core.options.animateOut || this.core.options.animateIn)) { 36 this.swap(); 37 } 38 }, this) 39 }; 40 41 this.core.$element.on(this.handlers); 42 }; 43 44 /** 45 * Default options. 46 * @public 47 */ 48 Animate.Defaults = { 49 animateOut: false, 50 animateIn: false 51 }; 52 53 /** 54 * Toggles the animation classes whenever an translations starts. 55 * @protected 56 * @returns {Boolean|undefined} 57 */ 58 Animate.prototype.swap = function() { 59 60 if (this.core.settings.items !== 1) { 61 return; 62 } 63 64 if (!$.support.animation || !$.support.transition) { 65 return; 66 } 67 68 this.core.speed(0); 69 70 var left, 71 clear = $.proxy(this.clear, this), 72 previous = this.core.$stage.children().eq(this.previous), 73 next = this.core.$stage.children().eq(this.next), 74 incoming = this.core.settings.animateIn, 75 outgoing = this.core.settings.animateOut; 76 77 if (this.core.current() === this.previous) { 78 return; 79 } 80 81 if (outgoing) { 82 left = this.core.coordinates(this.previous) - this.core.coordinates(this.next); 83 previous.one($.support.animation.end, clear) 84 .css( { 'left': left + 'px' } ) 85 .addClass('animated owl-animated-out') 86 .addClass(outgoing); 87 } 88 89 if (incoming) { 90 next.one($.support.animation.end, clear) 91 .addClass('animated owl-animated-in') 92 .addClass(incoming); 93 } 94 }; 95 96 Animate.prototype.clear = function(e) { 97 $(e.target).css( { 'left': '' } ) 98 .removeClass('animated owl-animated-out owl-animated-in') 99 .removeClass(this.core.settings.animateIn) 100 .removeClass(this.core.settings.animateOut); 101 this.core.onTransitionEnd(); 102 }; 103 104 /** 105 * Destroys the plugin. 106 * @public 107 */ 108 Animate.prototype.destroy = function() { 109 var handler, property; 110 111 for (handler in this.handlers) { 112 this.core.$element.off(handler, this.handlers[handler]); 113 } 114 for (property in Object.getOwnPropertyNames(this)) { 115 typeof this[property] != 'function' && (this[property] = null); 116 } 117 }; 118 119 $.fn.owlCarousel.Constructor.Plugins.Animate = Animate; 120 121})(window.Zepto || window.jQuery, window, document);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.