PageSourceSearch

https://www.mariinsky.ru/scripts_lib/OwlCarousel2-2.3.4/js/owl.carousel.js

js mariinsky.ru collected 2026-09-24 07:59:42 UTC 46,481 bytes, 1,750 lines download raw bytes

vendor: 46,481 bytes, lines 1-1750
1/**
2 * Owl carousel
3 * @version 2.3.4
4 * @author Bartosz Wojciechowski
5 * @author David Deutsch
6 * @license The MIT License (MIT)
7 * @todo Lazy Load Icon
8 * @todo prevent animationend bubling
9 * @todo itemsScaleUp
10 * @todo Test Zepto
11 * @todo stagePadding calculate wrong active classes
12 */
13;(function($, window, document, undefined) {
14
15	/**
16	 * Creates a carousel.
17	 * @class The Owl Carousel.
18	 * @public
19	 * @param {HTMLElement|jQuery} element - The element to create the carousel for.
20	 * @param {Object} [options] - The options
21	 */
22	function Owl(element, options) {
23
24		/**
25		 * Current settings for the carousel.
26		 * @public
27		 */
28		this.settings = null;
29
30		/**
31		 * Current options set by the caller including defaults.
32		 * @public
33		 */
34		this.options = $.extend({}, Owl.Defaults, options);
35
36		/**
37		 * Plugin element.
38		 * @public
39		 */
40		this.$element = $(element);
41
42		/**
43		 * Proxied event handlers.
44		 * @protected
45		 */
46		this._handlers = {};
47
48		/**
49		 * References to the running plugins of this carousel.
50		 * @protected
51		 */
52		this._plugins = {};
53
54		/**
55		 * Currently suppressed events to prevent them from being retriggered.
56		 * @protected
57		 */
58		this._supress = {};
59
60		/**
61		 * Absolute current position.
62		 * @protected
63		 */
64		this._current = null;
65
66		/**
67		 * Animation speed in milliseconds.
68		 * @protected
69		 */
70		this._speed = null;
71
72		/**
73		 * Coordinates of all items in pixel.
74		 * @todo The name of this member is missleading.
75		 * @protected
76		 */
77		this._coordinates = [];
78
79		/**
80		 * Current breakpoint.
81		 * @todo Real media queries would be nice.
82		 * @protected
83		 */
84		this._breakpoint = null;
85
86		/**
87		 * Current width of the plugin element.
88		 */
89		this._width = null;
90
91		/**
92		 * All real items.
93		 * @protected
94		 */
95		this._items = [];
96
97		/**
98		 * All cloned items.
99		 * @protected
100		 */
101		this._clones = [];
102
103		/**
104		 * Merge values of all items.
105		 * @todo Maybe this could be part of a plugin.
106		 * @protected
107		 */
108		this._mergers = [];
109
110		/**
111		 * Widths of all items.
112		 */
113		this._widths = [];
114
115		/**
116		 * Invalidated parts within the update process.
117		 * @protected
118		 */
119		this._invalidated = {};
120
121		/**
122		 * Ordered list of workers for the update process.
123		 * @protected
124		 */
125		this._pipe = [];
126
127		/**
128		 * Current state information for the drag operation.
129		 * @todo #261
130		 * @protected
131		 */
132		this._drag = {
133			time: null,
134			target: null,
135			pointer: null,
136			stage: {
137				start: null,
138				current: null
139			},
140			direction: null
141		};
142
143		/**
144		 * Current state information and their tags.
145		 * @type {Object}
146		 * @protected
147		 */
148		this._states = {
149			current: {},
150			tags: {
151				'initializing': [ 'busy' ],
152				'animating': [ 'busy' ],
153				'dragging': [ 'interacting' ]
154			}
155		};
156
157		$.each([ 'onResize', 'onThrottledResize' ], $.proxy(function(i, handler) {
158			this._handlers[handler] = $.proxy(this[handler], this);
159		}, this));
160
161		$.each(Owl.Plugins, $.proxy(function(key, plugin) {
162			this._plugins[key.charAt(0).toLowerCase() + key.slice(1)]
163				= new plugin(this);
164		}, this));
165
166		$.each(Owl.Workers, $.proxy(function(priority, worker) {
167			this._pipe.push({
168				'filter': worker.filter,
169				'run': $.proxy(worker.run, this)
170			});
171		}, this));
172
173		this.setup();
174		this.initialize();
175	}
176
177	/**
178	 * Default options for the carousel.
179	 * @public
180	 */
181	Owl.Defaults = {
182		items: 3,
183		loop: false,
184		center: false,
185		rewind: false,
186		checkVisibility: true,
187
188		mouseDrag: true,
189		touchDrag: true,
190		pullDrag: true,
191		freeDrag: false,
192
193		margin: 0,
194		stagePadding: 0,
195
196		merge: false,
197		mergeFit: true,
198		autoWidth: false,
199
200		startPosition: 0,
201		rtl: false,
202
203		smartSpeed: 250,
204		fluidSpeed: false,
205		dragEndSpeed: false,
206
207		responsive: {},
208		responsiveRefreshRate: 200,
209		responsiveBaseElement: window,
210
211		fallbackEasing: 'swing',
212		slideTransition: '',
213
214		info: false,
215
216		nestedItemSelector: false,
217		itemElement: 'div',
218		stageElement: 'div',
219
220		refreshClass: 'owl-refresh',
221		loadedClass: 'owl-loaded',
222		loadingClass: 'owl-loading',
223		rtlClass: 'owl-rtl',
224		responsiveClass: 'owl-responsive',
225		dragClass: 'owl-drag',
226		itemClass: 'owl-item',
227		stageClass: 'owl-stage',
228		stageOuterClass: 'owl-stage-outer',
229		grabClass: 'owl-grab'
230	};
231
232	/**
233	 * Enumeration for width.
234	 * @public
235	 * @readonly
236	 * @enum {String}
237	 */
238	Owl.Width = {
239		Default: 'default',
240		Inner: 'inner',
241		Outer: 'outer'
242	};
243
244	/**
245	 * Enumeration for types.
246	 * @public
247	 * @readonly
248	 * @enum {String}
249	 */
250	Owl.Type = {
251		Event: 'event',
252		State: 'state'
253	};
254
255	/**
256	 * Contains all registered plugins.
257	 * @public
258	 */
259	Owl.Plugins = {};
260
261	/**
262	 * List of workers involved in the update process.
263	 */
264	Owl.Workers = [ {
265		filter: [ 'width', 'settings' ],
266		run: function() {
267			this._width = this.$element.width();
268		}
269	}, {
270		filter: [ 'width', 'items', 'settings' ],
271		run: function(cache) {
272			cache.current = this._items && this._items[this.relative(this._current)];
273		}
274	}, {
275		filter: [ 'items', 'settings' ],
276		run: function() {
277			this.$stage.children('.cloned').remove();
278		}
279	}, {
280		filter: [ 'width', 'items', 'settings' ],
281		run: function(cache) {
282			var margin = this.settings.margin || '',
283				grid = !this.settings.autoWidth,
284				rtl = this.settings.rtl,
285				css = {
286					'width': 'auto',
287					'margin-left': rtl ? margin : '',
288					'margin-right': rtl ? '' : margin
289				};
290
291			!grid && this.$stage.children().css(css);
292
293			cache.css = css;
294		}
295	}, {
296		filter: [ 'width', 'items', 'settings' ],
297		run: function(cache) {
298			var width = (this.width() / this.settings.items).toFixed(3) - this.settings.margin,
299				merge = null,
300				iterator = this._items.length,
301				grid = !this.settings.autoWidth,
302				widths = [];
303
304			cache.items = {
305				merge: false,
306				width: width
307			};
308
309			while (iterator--) {
310				merge = this._mergers[iterator];
311				merge = this.settings.mergeFit && Math.min(merge, this.settings.items) || merge;
312
313				cache.items.merge = merge > 1 || cache.items.merge;
314
315				widths[iterator] = !grid ? this._items[iterator].width() : width * merge;
316			}
317
318			this._widths = widths;
319		}
320	}, {
321		filter: [ 'items', 'settings' ],
322		run: function() {
323			var clones = [],
324				items = this._items,
325				settings = this.settings,
326				// TODO: Should be computed from number of min width items in stage
327				view = Math.max(settings.items * 2, 4),
328				size = Math.ceil(items.length / 2) * 2,
329				repeat = settings.loop && items.length ? settings.rewind ? view : Math.max(view, size) : 0,
330				append = '',
331				prepend = '';
332
333			repeat /= 2;
334
335			while (repeat > 0) {
336				// Switch to only using appended clones
337				clones.push(this.normalize(clones.length / 2, true));
338				append = append + items[clones[clones.length - 1]][0].outerHTML;
339				clones.push(this.normalize(items.length - 1 - (clones.length - 1) / 2, true));
340				prepend = items[clones[clones.length - 1]][0].outerHTML + prepend;
341				repeat -= 1;
342			}
343
344			this._clones = clones;
345
346			$(append).addClass('cloned').appendTo(this.$stage);
347			$(prepend).addClass('cloned').prependTo(this.$stage);
348		}
349	}, {
350		filter: [ 'width', 'items', 'settings' ],
351		run: function() {
352			var rtl = this.settings.rtl ? 1 : -1,
353				size = this._clones.length + this._items.length,
354				iterator = -1,
355				previous = 0,
356				current = 0,
357				coordinates = [];
358
359			while (++iterator < size) {
360				previous = coordinates[iterator - 1] || 0;
361				current = this._widths[this.relative(iterator)] + this.settings.margin;
362				coordinates.push(previous + current * rtl);
363			}
364
365			this._coordinates = coordinates;
366		}
367	}, {
368		filter: [ 'width', 'items', 'settings' ],
369		run: function() {
370			var padding = this.settings.stagePadding,
371				coordinates = this._coordinates,
372				css = {
373					'width': Math.ceil(Math.abs(coordinates[coordinates.length - 1])) + padding * 2,
374					'padding-left': padding || '',
375					'padding-right': padding || ''
376				};
377
378			this.$stage.css(css);
379		}
380	}, {
381		filter: [ 'width', 'items', 'settings' ],
382		run: function(cache) {
383			var iterator = this._coordinates.length,
384				grid = !this.settings.autoWidth,
385				items = this.$stage.children();
386
387			if (grid && cache.items.merge) {
388				while (iterator--) {
389					cache.css.width = this._widths[this.relative(iterator)];
390					items.eq(iterator).css(cache.css);
391				}
392			} else if (grid) {
393				cache.css.width = cache.items.width;
394				items.css(cache.css);
395			}
396		}
397	}, {
398		filter: [ 'items' ],
399		run: function() {
400			this._coordinates.length < 1 && this.$stage.removeAttr('style');
401		}
402	}, {
403		filter: [ 'width', 'items', 'settings' ],
404		run: function(cache) {
405			cache.current = cache.current ? this.$stage.children().index(cache.current) : 0;
406			cache.current = Math.max(this.minimum(), Math.min(this.maximum(), cache.current));
407			this.reset(cache.current);
408		}
409	}, {
410		filter: [ 'position' ],
411		run: function() {
412			this.animate(this.coordinates(this._current));
413		}
414	}, {
415		filter: [ 'width', 'position', 'items', 'settings' ],
416		run: function() {
417			var rtl = this.settings.rtl ? 1 : -1,
418				padding = this.settings.stagePadding * 2,
419				begin = this.coordinates(this.current()) + padding,
420				end = begin + this.width() * rtl,
421				inner, outer, matches = [], i, n;
422
423			for (i = 0, n = this._coordinates.length; i < n; i++) {
424				inner = this._coordinates[i - 1] || 0;
425				outer = Math.abs(this._coordinates[i]) + padding * rtl;
426
427				if ((this.op(inner, '<=', begin) && (this.op(inner, '>', end)))
428					|| (this.op(outer, '<', begin) && this.op(outer, '>', end))) {
429					matches.push(i);
430				}
431			}
432
433			this.$stage.children('.active').removeClass('active');
434			this.$stage.children(':eq(' + matches.join('), :eq(') + ')').addClass('active');
435
436			this.$stage.children('.center').removeClass('center');
437			if (this.settings.center) {
438				this.$stage.children().eq(this.current()).addClass('center');
439			}
440		}
441	} ];
442
443	/**
444	 * Create the stage DOM element
445	 */
446	Owl.prototype.initializeStage = function() {
447		this.$stage = this.$element.find('.' + this.settings.stageClass);
448
449		// if the stage is already in the DOM, grab it and skip stage initialization
450		if (this.$stage.length) {
451			return;
452		}
453
454		this.$element.addClass(this.options.loadingClass);
455
456		// create stage
457		this.$stage = $('<' + this.settings.stageElement + '>', {
458			"class": this.settings.stageClass
459		}).wrap( $( '<div/>', {
460			"class": this.settings.stageOuterClass
461		}));
462
463		// append stage
464		this.$element.append(this.$stage.parent());
465	};
466
467	/**
468	 * Create item DOM elements
469	 */
470	Owl.prototype.initializeItems = function() {
471		var $items = this.$element.find('.owl-item');
472
473		// if the items are already in the DOM, grab them and skip item initialization
474		if ($items.length) {
475			this._items = $items.get().map(function(item) {
476				return $(item);
477			});
478
479			this._mergers = this._items.map(function() {
480				return 1;
481			});
482
483			this.refresh();
484
485			return;
486		}
487
488		// append content
489		this.replace(this.$element.children().not(this.$stage.parent()));
490
491		// check visibility
492		if (this.isVisible()) {
493			// update view
494			this.refresh();
495		} else {
496			// invalidate width
497			this.invalidate('width');
498		}
499
500		this.$element
501			.removeClass(this.options.loadingClass)
502			.addClass(this.options.loadedClass);
503	};
504
505	/**
506	 * Initializes the carousel.
507	 * @protected
508	 */
509	Owl.prototype.initialize = function() {
510		this.enter('initializing');
511		this.trigger('initialize');
512
513		this.$element.toggleClass(this.settings.rtlClass, this.settings.rtl);
514
515		if (this.settings.autoWidth && !this.is('pre-loading')) {
516			var imgs, nestedSelector, width;
517			imgs = this.$element.find('img');
518			nestedSelector = this.settings.nestedItemSelector ? '.' + this.settings.nestedItemSelector : undefined;
519			width = this.$element.children(nestedSelector).width();
520
521			if (imgs.length && width <= 0) {
522				this.preloadAutoWidthImages(imgs);
523			}
524		}
525
526		this.initializeStage();
527		this.initializeItems();
528
529		// register event handlers
530		this.registerEventHandlers();
531
532		this.leave('initializing');
533		this.trigger('initialized');
534	};
535
536	/**
537	 * @returns {Boolean} visibility of $element
538	 *                    if you know the carousel will always be visible you can set `checkVisibility` to `false` to
539	 *                    prevent the expensive browser layout forced reflow the $element.is(':visible') does
540	 */
541	Owl.prototype.isVisible = function() {
542		return this.settings.checkVisibility
543			? this.$element.is(':visible')
544			: true;
545	};
546
547	/**
548	 * Setups the current settings.
549	 * @todo Remove responsive classes. Why should adaptive designs be brought into IE8?
550	 * @todo Support for media queries by using `matchMedia` would be nice.
551	 * @public
552	 */
553	Owl.prototype.setup = function() {
554		var viewport = this.viewport(),
555			overwrites = this.options.responsive,
556			match = -1,
557			settings = null;
558
559		if (!overwrites) {
560			settings = $.extend({}, this.options);
561		} else {
562			$.each(overwrites, function(breakpoint) {
563				if (breakpoint <= viewport && breakpoint > match) {
564					match = Number(breakpoint);
565				}
566			});
567
568			settings = $.extend({}, this.options, overwrites[match]);
569			if (typeof settings.stagePadding === 'function') {
570				settings.stagePadding = settings.stagePadding();
571			}
572			delete settings.responsive;
573
574			// responsive class
575			if (settings.responsiveClass) {
576				this.$element.attr('class',
577					this.$element.attr('class').replace(new RegExp('(' + this.options.responsiveClass + '-)\\S+\\s', 'g'), '$1' + match)
578				);
579			}
580		}
581
582		this.trigger('change', { property: { name: 'settings', value: settings } });
583		this._breakpoint = match;
584		this.settings = settings;
585		this.invalidate('settings');
586		this.trigger('changed', { property: { name: 'settings', value: this.settings } });
587	};
588
589	/**
590	 * Updates option logic if necessery.
591	 * @protected
592	 */
593	Owl.prototype.optionsLogic = function() {
594		if (this.settings.autoWidth) {
595			this.settings.stagePadding = false;
596			this.settings.merge = false;
597		}
598	};
599
600	/**
601	 * Prepares an item before add.
602	 * @todo Rename event parameter `content` to `item`.
603	 * @protected
604	 * @returns {jQuery|HTMLElement} - The item container.
605	 */
606	Owl.prototype.prepare = function(item) {
607		var event = this.trigger('prepare', { content: item });
608
609		if (!event.data) {
610			event.data = $('<' + this.settings.itemElement + '/>')
611				.addClass(this.options.itemClass).append(item)
612		}
613
614		this.trigger('prepared', { content: event.data });
615
616		return event.data;
617	};
618
619	/**
620	 * Updates the view.
621	 * @public
622	 */
623	Owl.prototype.update = function() {
624		var i = 0,
625			n = this._pipe.length,
626			filter = $.proxy(function(p) { return this[p] }, this._invalidated),
627			cache = {};
628
629		while (i < n) {
630			if (this._invalidated.all || $.grep(this._pipe[i].filter, filter).length > 0) {
631				this._pipe[i].run(cache);
632			}
633			i++;
634		}
635
636		this._invalidated = {};
637
638		!this.is('valid') && this.enter('valid');
639	};
640
641	/**
642	 * Gets the width of the view.
643	 * @public
644	 * @param {Owl.Width} [dimension=Owl.Width.Default] - The dimension to return.
645	 * @returns {Number} - The width of the view in pixel.
646	 */
647	Owl.prototype.width = function(dimension) {
648		dimension = dimension || Owl.Width.Default;
649		switch (dimension) {
650			case Owl.Width.Inner:
651			case Owl.Width.Outer:
652				return this._width;
653			default:
654				return this._width - this.settings.stagePadding * 2 + this.settings.margin;
655		}
656	};
657
658	/**
659	 * Refreshes the carousel primarily for adaptive purposes.
660	 * @public
661	 */
662	Owl.prototype.refresh = function() {
663		this.enter('refreshing');
664		this.trigger('refresh');
665
666		this.setup();
667
668		this.optionsLogic();
669
670		this.$element.addClass(this.options.refreshClass);
671
672		this.update();
673
674		this.$element.removeClass(this.options.refreshClass);
675
676		this.leave('refreshing');
677		this.trigger('refreshed');
678	};
679
680	/**
681	 * Checks window `resize` event.
682	 * @protected
683	 */
684	Owl.prototype.onThrottledResize = function() {
685		window.clearTimeout(this.resizeTimer);
686		this.resizeTimer = window.setTimeout(this._handlers.onResize, this.settings.responsiveRefreshRate);
687	};
688
689	/**
690	 * Checks window `resize` event.
691	 * @protected
692	 */
693	Owl.prototype.onResize = function() {
694		if (!this._items.length) {
695			return false;
696		}
697
698		if (this._width === this.$element.width()) {
699			return false;
700		}
701
702		if (!this.isVisible()) {
703			return false;
704		}
705
706		this.enter('resizing');
707
708		if (this.trigger('resize').isDefaultPrevented()) {
709			this.leave('resizing');
710			return false;
711		}
712
713		this.invalidate('width');
714
715		this.refresh();
716
717		this.leave('resizing');
718		this.trigger('resized');
719	};
720
721	/**
722	 * Registers event handlers.
723	 * @todo Check `msPointerEnabled`
724	 * @todo #261
725	 * @protected
726	 */
727	Owl.prototype.registerEventHandlers = function() {
728		if ($.support.transition) {
729			this.$stage.on($.support.transition.end + '.owl.core', $.proxy(this.onTransitionEnd, this));
730		}
731
732		if (this.settings.responsive !== false) {
733			this.on(window, 'resize', this._handlers.onThrottledResize);
734		}
735
736		if (this.settings.mouseDrag) {
737			this.$element.addClass(this.options.dragClass);
738			this.$stage.on('mousedown.owl.core', $.proxy(this.onDragStart, this));
739			this.$stage.on('dragstart.owl.core selectstart.owl.core', function() { return false });
740		}
741
742		if (this.settings.touchDrag){
743			this.$stage.on('touchstart.owl.core', $.proxy(this.onDragStart, this));
744			this.$stage.on('touchcancel.owl.core', $.proxy(this.onDragEnd, this));
745		}
746	};
747
748	/**
749	 * Handles `touchstart` and `mousedown` events.
750	 * @todo Horizontal swipe threshold as option
751	 * @todo #261
752	 * @protected
753	 * @param {Event} event - The event arguments.
754	 */
755	Owl.prototype.onDragStart = function(event) {
756		var stage = null;
757
758		if (event.which === 3) {
759			return;
760		}
761
762		if ($.support.transform) {
763			stage = this.$stage.css('transform').replace(/.*\(|\)| /g, '').split(',');
764			stage = {
765				x: stage[stage.length === 16 ? 12 : 4],
766				y: stage[stage.length === 16 ? 13 : 5]
767			};
768		} else {
769			stage = this.$stage.position();
770			stage = {
771				x: this.settings.rtl ?
772					stage.left + this.$stage.width() - this.width() + this.settings.margin :
773					stage.left,
774				y: stage.top
775			};
776		}
777
778		if (this.is('animating')) {
779			$.support.transform ? this.animate(stage.x) : this.$stage.stop()
780			this.invalidate('position');
781		}
782
783		this.$element.toggleClass(this.options.grabClass, event.type === 'mousedown');
784
785		this.speed(0);
786
787		this._drag.time = new Date().getTime();
788		this._drag.target = $(event.target);
789		this._drag.stage.start = stage;
790		this._drag.stage.current = stage;
791		this._drag.pointer = this.pointer(event);
792
793		$(document).on('mouseup.owl.core touchend.owl.core', $.proxy(this.onDragEnd, this));
794
795		$(document).one('mousemove.owl.core touchmove.owl.core', $.proxy(function(event) {
796			var delta = this.difference(this._drag.pointer, this.pointer(event));
797
798			$(document).on('mousemove.owl.core touchmove.owl.core', $.proxy(this.onDragMove, this));
799
800			if (Math.abs(delta.x) < Math.abs(delta.y) && this.is('valid')) {
801				return;
802			}
803
804			event.preventDefault();
805
806			this.enter('dragging');
807			this.trigger('drag');
808		}, this));
809	};
810
811	/**
812	 * Handles the `touchmove` and `mousemove` events.
813	 * @todo #261
814	 * @protected
815	 * @param {Event} event - The event arguments.
816	 */
817	Owl.prototype.onDragMove = function(event) {
818		var minimum = null,
819			maximum = null,
820			pull = null,
821			delta = this.difference(this._drag.pointer, this.pointer(event)),
822			stage = this.difference(this._drag.stage.start, delta);
823
824		if (!this.is('dragging')) {
825			return;
826		}
827
828		event.preventDefault();
829
830		if (this.settings.loop) {
831			minimum = this.coordinates(this.minimum());
832			maximum = this.coordinates(this.maximum() + 1) - minimum;
833			stage.x = (((stage.x - minimum) % maximum + maximum) % maximum) + minimum;
834		} else {
835			minimum = this.settings.rtl ? this.coordinates(this.maximum()) : this.coordinates(this.minimum());
836			maximum = this.settings.rtl ? this.coordinates(this.minimum()) : this.coordinates(this.maximum());
837			pull = this.settings.pullDrag ? -1 * delta.x / 5 : 0;
838			stage.x = Math.max(Math.min(stage.x, minimum + pull), maximum + pull);
839		}
840
841		this._drag.stage.current = stage;
842
843		this.animate(stage.x);
844	};
845
846	/**
847	 * Handles the `touchend` and `mouseup` events.
848	 * @todo #261
849	 * @todo Threshold for click event
850	 * @protected
851	 * @param {Event} event - The event arguments.
852	 */
853	Owl.prototype.onDragEnd = function(event) {
854		var delta = this.difference(this._drag.pointer, this.pointer(event)),
855			stage = this._drag.stage.current,
856			direction = delta.x > 0 ^ this.settings.rtl ? 'left' : 'right';
857
858		$(document).off('.owl.core');
859
860		this.$element.removeClass(this.options.grabClass);
861
862		if (delta.x !== 0 && this.is('dragging') || !this.is('valid')) {
863			this.speed(this.settings.dragEndSpeed || this.settings.smartSpeed);
864			this.current(this.closest(stage.x, delta.x !== 0 ? direction : this._drag.direction));
865			this.invalidate('position');
866			this.update();
867
868			this._drag.direction = direction;
869
870			if (Math.abs(delta.x) > 3 || new Date().getTime() - this._drag.time > 300) {
871				this._drag.target.one('click.owl.core', function() { return false; });
872			}
873		}
874
875		if (!this.is('dragging')) {
876			return;
877		}
878
879		this.leave('dragging');
880		this.trigger('dragged');
881	};
882
883	/**
884	 * Gets absolute position of the closest item for a coordinate.
885	 * @todo Setting `freeDrag` makes `closest` not reusable. See #165.
886	 * @protected
887	 * @param {Number} coordinate - The coordinate in pixel.
888	 * @param {String} direction - The direction to check for the closest item. Ether `left` or `right`.
889	 * @return {Number} - The absolute position of the closest item.
890	 */
891	Owl.prototype.closest = function(coordinate, direction) {
892		var position = -1,
893			pull = 30,
894			width = this.width(),
895			coordinates = this.coordinates();
896
897		if (!this.settings.freeDrag) {
898			// check closest item
899			$.each(coordinates, $.proxy(function(index, value) {
900				// on a left pull, check on current index
901				if (direction === 'left' && coordinate > value - pull && coordinate < value + pull) {
902					position = index;
903				// on a right pull, check on previous index
904				// to do so, subtract width from value and set position = index + 1
905				} else if (direction === 'right' && coordinate > value - width - pull && coordinate < value - width + pull) {
906					position = index + 1;
907				} else if (this.op(coordinate, '<', value)
908					&& this.op(coordinate, '>', coordinates[index + 1] !== undefined ? coordinates[index + 1] : value - width)) {
909					position = direction === 'left' ? index + 1 : index;
910				}
911				return position === -1;
912			}, this));
913		}
914
915		if (!this.settings.loop) {
916			// non loop boundries
917			if (this.op(coordinate, '>', coordinates[this.minimum()])) {
918				position = coordinate = this.minimum();
919			} else if (this.op(coordinate, '<', coordinates[this.maximum()])) {
920				position = coordinate = this.maximum();
921			}
922		}
923
924		return position;
925	};
926
927	/**
928	 * Animates the stage.
929	 * @todo #270
930	 * @public
931	 * @param {Number} coordinate - The coordinate in pixels.
932	 */
933	Owl.prototype.animate = function(coordinate) {
934		var animate = this.speed() > 0;
935
936		this.is('animating') && this.onTransitionEnd();
937
938		if (animate) {
939			this.enter('animating');
940			this.trigger('translate');
941		}
942
943		if ($.support.transform3d && $.support.transition) {
944			this.$stage.css({
945				transform: 'translate3d(' + coordinate + 'px,0px,0px)',
946				transition: (this.speed() / 1000) + 's' + (
947					this.settings.slideTransition ? ' ' + this.settings.slideTransition : ''
948				)
949			});
950		} else if (animate) {
951			this.$stage.animate({
952				left: coordinate + 'px'
953			}, this.speed(), this.settings.fallbackEasing, $.proxy(this.onTransitionEnd, this));
954		} else {
955			this.$stage.css({
956				left: coordinate + 'px'
957			});
958		}
959	};
960
961	/**
962	 * Checks whether the carousel is in a specific state or not.
963	 * @param {String} state - The state to check.
964	 * @returns {Boolean} - The flag which indicates if the carousel is busy.
965	 */
966	Owl.prototype.is = function(state) {
967		return this._states.current[state] && this._states.current[state] > 0;
968	};
969
970	/**
971	 * Sets the absolute position of the current item.
972	 * @public
973	 * @param {Number} [position] - The new absolute position or nothing to leave it unchanged.
974	 * @returns {Number} - The absolute position of the current item.
975	 */
976	Owl.prototype.current = function(position) {
977		if (position === undefined) {
978			return this._current;
979		}
980
981		if (this._items.length === 0) {
982			return undefined;
983		}
984
985		position = this.normalize(position);
986
987		if (this._current !== position) {
988			var event = this.trigger('change', { property: { name: 'position', value: position } });
989
990			if (event.data !== undefined) {
991				position = this.normalize(event.data);
992			}
993
994			this._current = position;
995
996			this.invalidate('position');
997
998			this.trigger('changed', { property: { name: 'position', value: this._current } });
999		}
1000
1001		return this._current;
1002	};
1003
1004	/**
1005	 * Invalidates the given part of the update routine.
1006	 * @param {String} [part] - The part to invalidate.
1007	 * @returns {Array.<String>} - The invalidated parts.
1008	 */
1009	Owl.prototype.invalidate = function(part) {
1010		if ($.type(part) === 'string') {
1011			this._invalidated[part] = true;
1012			this.is('valid') && this.leave('valid');
1013		}
1014		return $.map(this._invalidated, function(v, i) { return i });
1015	};
1016
1017	/**
1018	 * Resets the absolute position of the current item.
1019	 * @public
1020	 * @param {Number} position - The absolute position of the new item.
1021	 */
1022	Owl.prototype.reset = function(position) {
1023		position = this.normalize(position);
1024
1025		if (position === undefined) {
1026			return;
1027		}
1028
1029		this._speed = 0;
1030		this._current = position;
1031
1032		this.suppress([ 'translate', 'translated' ]);
1033
1034		this.animate(this.coordinates(position));
1035
1036		this.release([ 'translate', 'translated' ]);
1037	};
1038
1039	/**
1040	 * Normalizes an absolute or a relative position of an item.
1041	 * @public
1042	 * @param {Number} position - The absolute or relative position to normalize.
1043	 * @param {Boolean} [relative=false] - Whether the given position is relative or not.
1044	 * @returns {Number} - The normalized position.
1045	 */
1046	Owl.prototype.normalize = function(position, relative) {
1047		var n = this._items.length,
1048			m = relative ? 0 : this._clones.length;
1049
1050		if (!this.isNumeric(position) || n < 1) {
1051			position = undefined;
1052		} else if (position < 0 || position >= n + m) {
1053			position = ((position - m / 2) % n + n) % n + m / 2;
1054		}
1055
1056		return position;
1057	};
1058
1059	/**
1060	 * Converts an absolute position of an item into a relative one.
1061	 * @public
1062	 * @param {Number} position - The absolute position to convert.
1063	 * @returns {Number} - The converted position.
1064	 */
1065	Owl.prototype.relative = function(position) {
1066		position -= this._clones.length / 2;
1067		return this.normalize(position, true);
1068	};
1069
1070	/**
1071	 * Gets the maximum position for the current item.
1072	 * @public
1073	 * @param {Boolean} [relative=false] - Whether to return an absolute position or a relative position.
1074	 * @returns {Number}
1075	 */
1076	Owl.prototype.maximum = function(relative) {
1077		var settings = this.settings,
1078			maximum = this._coordinates.length,
1079			iterator,
1080			reciprocalItemsWidth,
1081			elementWidth;
1082
1083		if (settings.loop) {
1084			maximum = this._clones.length / 2 + this._items.length - 1;
1085		} else if (settings.autoWidth || settings.merge) {
1086			iterator = this._items.length;
1087			if (iterator) {
1088				reciprocalItemsWidth = this._items[--iterator].width();
1089				elementWidth = this.$element.width();
1090				while (iterator--) {
1091					reciprocalItemsWidth += this._items[iterator].width() + this.settings.margin;
1092					if (reciprocalItemsWidth > elementWidth) {
1093						break;
1094					}
1095				}
1096			}
1097			maximum = iterator + 1;
1098		} else if (settings.center) {
1099			maximum = this._items.length - 1;
1100		} else {
1101			maximum = this._items.length - settings.items;
1102		}
1103
1104		if (relative) {
1105			maximum -= this._clones.length / 2;
1106		}
1107
1108		return Math.max(maximum, 0);
1109	};
1110
1111	/**
1112	 * Gets the minimum position for the current item.
1113	 * @public
1114	 * @param {Boolean} [relative=false] - Whether to return an absolute position or a relative position.
1115	 * @returns {Number}
1116	 */
1117	Owl.prototype.minimum = function(relative) {
1118		return relative ? 0 : this._clones.length / 2;
1119	};
1120
1121	/**
1122	 * Gets an item at the specified relative position.
1123	 * @public
1124	 * @param {Number} [position] - The relative position of the item.
1125	 * @return {jQuery|Array.<jQuery>} - The item at the given position or all items if no position was given.
1126	 */
1127	Owl.prototype.items = function(position) {
1128		if (position === undefined) {
1129			return this._items.slice();
1130		}
1131
1132		position = this.normalize(position, true);
1133		return this._items[position];
1134	};
1135
1136	/**
1137	 * Gets an item at the specified relative position.
1138	 * @public
1139	 * @param {Number} [position] - The relative position of the item.
1140	 * @return {jQuery|Array.<jQuery>} - The item at the given position or all items if no position was given.
1141	 */
1142	Owl.prototype.mergers = function(position) {
1143		if (position === undefined) {
1144			return this._mergers.slice();
1145		}
1146
1147		position = this.normalize(position, true);
1148		return this._mergers[position];
1149	};
1150
1151	/**
1152	 * Gets the absolute positions of clones for an item.
1153	 * @public
1154	 * @param {Number} [position] - The relative position of the item.
1155	 * @returns {Array.<Number>} - The absolute positions of clones for the item or all if no position was given.
1156	 */
1157	Owl.prototype.clones = function(position) {
1158		var odd = this._clones.length / 2,
1159			even = odd + this._items.length,
1160			map = function(index) { return index % 2 === 0 ? even + index / 2 : odd - (index + 1) / 2 };
1161
1162		if (position === undefined) {
1163			return $.map(this._clones, function(v, i) { return map(i) });
1164		}
1165
1166		return $.map(this._clones, function(v, i) { return v === position ? map(i) : null });
1167	};
1168
1169	/**
1170	 * Sets the current animation speed.
1171	 * @public
1172	 * @param {Number} [speed] - The animation speed in milliseconds or nothing to leave it unchanged.
1173	 * @returns {Number} - The current animation speed in milliseconds.
1174	 */
1175	Owl.prototype.speed = function(speed) {
1176		if (speed !== undefined) {
1177			this._speed = speed;
1178		}
1179
1180		return this._speed;
1181	};
1182
1183	/**
1184	 * Gets the coordinate of an item.
1185	 * @todo The name of this method is missleanding.
1186	 * @public
1187	 * @param {Number} position - The absolute position of the item within `minimum()` and `maximum()`.
1188	 * @returns {Number|Array.<Number>} - The coordinate of the item in pixel or all coordinates.
1189	 */
1190	Owl.prototype.coordinates = function(position) {
1191		var multiplier = 1,
1192			newPosition = position - 1,
1193			coordinate;
1194
1195		if (position === undefined) {
1196			return $.map(this._coordinates, $.proxy(function(coordinate, index) {
1197				return this.coordinates(index);
1198			}, this));
1199		}
1200
1201		if (this.settings.center) {
1202			if (this.settings.rtl) {
1203				multiplier = -1;
1204				newPosition = position + 1;
1205			}
1206
1207			coordinate = this._coordinates[position];
1208			coordinate += (this.width() - coordinate + (this._coordinates[newPosition] || 0)) / 2 * multiplier;
1209		} else {
1210			coordinate = this._coordinates[newPosition] || 0;
1211		}
1212
1213		coordinate = Math.ceil(coordinate);
1214
1215		return coordinate;
1216	};
1217
1218	/**
1219	 * Calculates the speed for a translation.
1220	 * @protected
1221	 * @param {Number} from - The absolute position of the start item.
1222	 * @param {Number} to - The absolute position of the target item.
1223	 * @param {Number} [factor=undefined] - The time factor in milliseconds.
1224	 * @returns {Number} - The time in milliseconds for the translation.
1225	 */
1226	Owl.prototype.duration = function(from, to, factor) {
1227		if (factor === 0) {
1228			return 0;
1229		}
1230
1231		return Math.min(Math.max(Math.abs(to - from), 1), 6) * Math.abs((factor || this.settings.smartSpeed));
1232	};
1233
1234	/**
1235	 * Slides to the specified item.
1236	 * @public
1237	 * @param {Number} position - The position of the item.
1238	 * @param {Number} [speed] - The time in milliseconds for the transition.
1239	 */
1240	Owl.prototype.to = function(position, speed) {
1241		var current = this.current(),
1242			revert = null,
1243			distance = position - this.relative(current),
1244			direction = (distance > 0) - (distance < 0),
1245			items = this._items.length,
1246			minimum = this.minimum(),
1247			maximum = this.maximum();
1248
1249		if (this.settings.loop) {
1250			if (!this.settings.rewind && Math.abs(distance) > items / 2) {
1251				distance += direction * -1 * items;
1252			}
1253
1254			position = current + distance;
1255			revert = ((position - minimum) % items + items) % items + minimum;
1256
1257			if (revert !== position && revert - distance <= maximum && revert - distance > 0) {
1258				current = revert - distance;
1259				position = revert;
1260				this.reset(current);
1261			}
1262		} else if (this.settings.rewind) {
1263			maximum += 1;
1264			position = (position % maximum + maximum) % maximum;
1265		} else {
1266			position = Math.max(minimum, Math.min(maximum, position));
1267		}
1268
1269		this.speed(this.duration(current, position, speed));
1270		this.current(position);
1271
1272		if (this.isVisible()) {
1273			this.update();
1274		}
1275	};
1276
1277	/**
1278	 * Slides to the next item.
1279	 * @public
1280	 * @param {Number} [speed] - The time in milliseconds for the transition.
1281	 */
1282	Owl.prototype.next = function(speed) {
1283		speed = speed || false;
1284		this.to(this.relative(this.current()) + 1, speed);
1285	};
1286
1287	/**
1288	 * Slides to the previous item.
1289	 * @public
1290	 * @param {Number} [speed] - The time in milliseconds for the transition.
1291	 */
1292	Owl.prototype.prev = function(speed) {
1293		speed = speed || false;
1294		this.to(this.relative(this.current()) - 1, speed);
1295	};
1296
1297	/**
1298	 * Handles the end of an animation.
1299	 * @protected
1300	 * @param {Event} event - The event arguments.
1301	 */
1302	Owl.prototype.onTransitionEnd = function(event) {
1303
1304		// if css2 animation then event object is undefined
1305		if (event !== undefined) {
1306			event.stopPropagation();
1307
1308			// Catch only owl-stage transitionEnd event
1309			if ((event.target || event.srcElement || event.originalTarget) !== this.$stage.get(0)) {
1310				return false;
1311			}
1312		}
1313
1314		this.leave('animating');
1315		this.trigger('translated');
1316	};
1317
1318	/**
1319	 * Gets viewport width.
1320	 * @protected
1321	 * @return {Number} - The width in pixel.
1322	 */
1323	Owl.prototype.viewport = function() {
1324		var width;
1325		if (this.options.responsiveBaseElement !== window) {
1326			width = $(this.options.responsiveBaseElement).width();
1327		} else if (window.innerWidth) {
1328			width = window.innerWidth;
1329		} else if (document.documentElement && document.documentElement.clientWidth) {
1330			width = document.documentElement.clientWidth;
1331		} else {
1332			console.warn('Can not detect viewport width.');
1333		}
1334		return width;
1335	};
1336
1337	/**
1338	 * Replaces the current content.
1339	 * @public
1340	 * @param {HTMLElement|jQuery|String} content - The new content.
1341	 */
1342	Owl.prototype.replace = function(content) {
1343		this.$stage.empty();
1344		this._items = [];
1345
1346		if (content) {
1347			content = (content instanceof jQuery) ? content : $(content);
1348		}
1349
1350		if (this.settings.nestedItemSelector) {
1351			content = content.find('.' + this.settings.nestedItemSelector);
1352		}
1353
1354		content.filter(function() {
1355			return this.nodeType === 1;
1356		}).each($.proxy(function(index, item) {
1357			item = this.prepare(item);
1358			this.$stage.append(item);
1359			this._items.push(item);
1360			this._mergers.push(item.find('[data-merge]').addBack('[data-merge]').attr('data-merge') * 1 || 1);
1361		}, this));
1362
1363		this.reset(this.isNumeric(this.settings.startPosition) ? this.settings.startPosition : 0);
1364
1365		this.invalidate('items');
1366	};
1367
1368	/**
1369	 * Adds an item.
1370	 * @todo Use `item` instead of `content` for the event arguments.
1371	 * @public
1372	 * @param {HTMLElement|jQuery|String} content - The item content to add.
1373	 * @param {Number} [position] - The relative position at which to insert the item otherwise the item will be added to the end.
1374	 */
1375	Owl.prototype.add = function(content, position) {
1376		var current = this.relative(this._current);
1377
1378		position = position === undefined ? this._items.length : this.normalize(position, true);
1379		content = content instanceof jQuery ? content : $(content);
1380
1381		this.trigger('add', { content: content, position: position });
1382
1383		content = this.prepare(content);
1384
1385		if (this._items.length === 0 || position === this._items.length) {
1386			this._items.length === 0 && this.$stage.append(content);
1387			this._items.length !== 0 && this._items[position - 1].after(content);
1388			this._items.push(content);
1389			this._mergers.push(content.find('[data-merge]').addBack('[data-merge]').attr('data-merge') * 1 || 1);
1390		} else {
1391			this._items[position].before(content);
1392			this._items.splice(position, 0, content);
1393			this._mergers.splice(position, 0, content.find('[data-merge]').addBack('[data-merge]').attr('data-merge') * 1 || 1);
1394		}
1395
1396		this._items[current] && this.reset(this._items[current].index());
1397
1398		this.invalidate('items');
1399
1400		this.trigger('added', { content: content, position: position });
1401	};
1402
1403	/**
1404	 * Removes an item by its position.
1405	 * @todo Use `item` instead of `content` for the event arguments.
1406	 * @public
1407	 * @param {Number} position - The relative position of the item to remove.
1408	 */
1409	Owl.prototype.remove = function(position) {
1410		position = this.normalize(position, true);
1411
1412		if (position === undefined) {
1413			return;
1414		}
1415
1416		this.trigger('remove', { content: this._items[position], position: position });
1417
1418		this._items[position].remove();
1419		this._items.splice(position, 1);
1420		this._mergers.splice(position, 1);
1421
1422		this.invalidate('items');
1423
1424		this.trigger('removed', { content: null, position: position });
1425	};
1426
1427	/**
1428	 * Preloads images with auto width.
1429	 * @todo Replace by a more generic approach
1430	 * @protected
1431	 */
1432	Owl.prototype.preloadAutoWidthImages = function(images) {
1433		images.each($.proxy(function(i, element) {
1434			this.enter('pre-loading');
1435			element = $(element);
1436			$(new Image()).one('load', $.proxy(function(e) {
1437				element.attr('src', e.target.src);
1438				element.css('opacity', 1);
1439				this.leave('pre-loading');
1440				!this.is('pre-loading') && !this.is('initializing') && this.refresh();
1441			}, this)).attr('src', element.attr('src') || element.attr('data-src') || element.attr('data-src-retina'));
1442		}, this));
1443	};
1444
1445	/**
1446	 * Destroys the carousel.
1447	 * @public
1448	 */
1449	Owl.prototype.destroy = function() {
1450
1451		this.$element.off('.owl.core');
1452		this.$stage.off('.owl.core');
1453		$(document).off('.owl.core');
1454
1455		if (this.settings.responsive !== false) {
1456			window.clearTimeout(this.resizeTimer);
1457			this.off(window, 'resize', this._handlers.onThrottledResize);
1458		}
1459
1460		for (var i in this._plugins) {
1461			this._plugins[i].destroy();
1462		}
1463
1464		this.$stage.children('.cloned').remove();
1465
1466		this.$stage.unwrap();
1467		this.$stage.children().contents().unwrap();
1468		this.$stage.children().unwrap();
1469		this.$stage.remove();
1470		this.$element
1471			.removeClass(this.options.refreshClass)
1472			.removeClass(this.options.loadingClass)
1473			.removeClass(this.options.loadedClass)
1474			.removeClass(this.options.rtlClass)
1475			.removeClass(this.options.dragClass)
1476			.removeClass(this.options.grabClass)
1477			.attr('class', this.$element.attr('class').replace(new RegExp(this.options.responsiveClass + '-\\S+\\s', 'g'), ''))
1478			.removeData('owl.carousel');
1479	};
1480
1481	/**
1482	 * Operators to calculate right-to-left and left-to-right.
1483	 * @protected
1484	 * @param {Number} [a] - The left side operand.
1485	 * @param {String} [o] - The operator.
1486	 * @param {Number} [b] - The right side operand.
1487	 */
1488	Owl.prototype.op = function(a, o, b) {
1489		var rtl = this.settings.rtl;
1490		switch (o) {
1491			case '<':
1492				return rtl ? a > b : a < b;
1493			case '>':
1494				return rtl ? a < b : a > b;
1495			case '>=':
1496				return rtl ? a <= b : a >= b;
1497			case '<=':
1498				return rtl ? a >= b : a <= b;
1499			default:
1500				break;
1501		}
1502	};
1503
1504	/**
1505	 * Attaches to an internal event.
1506	 * @protected
1507	 * @param {HTMLElement} element - The event source.
1508	 * @param {String} event - The event name.
1509	 * @param {Function} listener - The event handler to attach.
1510	 * @param {Boolean} capture - Wether the event should be handled at the capturing phase or not.
1511	 */
1512	Owl.prototype.on = function(element, event, listener, capture) {
1513		if (element.addEventListener) {
1514			element.addEventListener(event, listener, capture);
1515		} else if (element.attachEvent) {
1516			element.attachEvent('on' + event, listener);
1517		}
1518	};
1519
1520	/**
1521	 * Detaches from an internal event.
1522	 * @protected
1523	 * @param {HTMLElement} element - The event source.
1524	 * @param {String} event - The event name.
1525	 * @param {Function} listener - The attached event handler to detach.
1526	 * @param {Boolean} capture - Wether the attached event handler was registered as a capturing listener or not.
1527	 */
1528	Owl.prototype.off = function(element, event, listener, capture) {
1529		if (element.removeEventListener) {
1530			element.removeEventListener(event, listener, capture);
1531		} else if (element.detachEvent) {
1532			element.detachEvent('on' + event, listener);
1533		}
1534	};
1535
1536	/**
1537	 * Triggers a public event.
1538	 * @todo Remove `status`, `relatedTarget` should be used instead.
1539	 * @protected
1540	 * @param {String} name - The event name.
1541	 * @param {*} [data=null] - The event data.
1542	 * @param {String} [namespace=carousel] - The event namespace.
1543	 * @param {String} [state] - The state which is associated with the event.
1544	 * @param {Boolean} [enter=false] - Indicates if the call enters the specified state or not.
1545	 * @returns {Event} - The event arguments.
1546	 */
1547	Owl.prototype.trigger = function(name, data, namespace, state, enter) {
1548		var status = {
1549			item: { count: this._items.length, index: this.current() }
1550		}, handler = $.camelCase(
1551			$.grep([ 'on', name, namespace ], function(v) { return v })
1552				.join('-').toLowerCase()
1553		), event = $.Event(
1554			[ name, 'owl', namespace || 'carousel' ].join('.').toLowerCase(),
1555			$.extend({ relatedTarget: this }, status, data)
1556		);
1557
1558		if (!this._supress[name]) {
1559			$.each(this._plugins, function(name, plugin) {
1560				if (plugin.onTrigger) {
1561					plugin.onTrigger(event);
1562				}
1563			});
1564
1565			this.register({ type: Owl.Type.Event, name: name });
1566			this.$element.trigger(event);
1567
1568			if (this.settings && typeof this.settings[handler] === 'function') {
1569				this.settings[handler].call(this, event);
1570			}
1571		}
1572
1573		return event;
1574	};
1575
1576	/**
1577	 * Enters a state.
1578	 * @param name - The state name.
1579	 */
1580	Owl.prototype.enter = function(name) {
1581		$.each([ name ].concat(this._states.tags[name] || []), $.proxy(function(i, name) {
1582			if (this._states.current[name] === undefined) {
1583				this._states.current[name] = 0;
1584			}
1585
1586			this._states.current[name]++;
1587		}, this));
1588	};
1589
1590	/**
1591	 * Leaves a state.
1592	 * @param name - The state name.
1593	 */
1594	Owl.prototype.leave = function(name) {
1595		$.each([ name ].concat(this._states.tags[name] || []), $.proxy(function(i, name) {
1596			this._states.current[name]--;
1597		}, this));
1598	};
1599
1600	/**
1601	 * Registers an event or state.
1602	 * @public
1603	 * @param {Object} object - The event or state to register.
1604	 */
1605	Owl.prototype.register = function(object) {
1606		if (object.type === Owl.Type.Event) {
1607			if (!$.event.special[object.name]) {
1608				$.event.special[object.name] = {};
1609			}
1610
1611			if (!$.event.special[object.name].owl) {
1612				var _default = $.event.special[object.name]._default;
1613				$.event.special[object.name]._default = function(e) {
1614					if (_default && _default.apply && (!e.namespace || e.namespace.indexOf('owl') === -1)) {
1615						return _default.apply(this, arguments);
1616					}
1617					return e.namespace && e.namespace.indexOf('owl') > -1;
1618				};
1619				$.event.special[object.name].owl = true;
1620			}
1621		} else if (object.type === Owl.Type.State) {
1622			if (!this._states.tags[object.name]) {
1623				this._states.tags[object.name] = object.tags;
1624			} else {
1625				this._states.tags[object.name] = this._states.tags[object.name].concat(object.tags);
1626			}
1627
1628			this._states.tags[object.name] = $.grep(this._states.tags[object.name], $.proxy(function(tag, i) {
1629				return $.inArray(tag, this._states.tags[object.name]) === i;
1630			}, this));
1631		}
1632	};
1633
1634	/**
1635	 * Suppresses events.
1636	 * @protected
1637	 * @param {Array.<String>} events - The events to suppress.
1638	 */
1639	Owl.prototype.suppress = function(events) {
1640		$.each(events, $.proxy(function(index, event) {
1641			this._supress[event] = true;
1642		}, this));
1643	};
1644
1645	/**
1646	 * Releases suppressed events.
1647	 * @protected
1648	 * @param {Array.<String>} events - The events to release.
1649	 */
1650	Owl.prototype.release = function(events) {
1651		$.each(events, $.proxy(function(index, event) {
1652			delete this._supress[event];
1653		}, this));
1654	};
1655
1656	/**
1657	 * Gets unified pointer coordinates from event.
1658	 * @todo #261
1659	 * @protected
1660	 * @param {Event} - The `mousedown` or `touchstart` event.
1661	 * @returns {Object} - Contains `x` and `y` coordinates of current pointer position.
1662	 */
1663	Owl.prototype.pointer = function(event) {
1664		var result = { x: null, y: null };
1665
1666		event = event.originalEvent || event || window.event;
1667
1668		event = event.touches && event.touches.length ?
1669			event.touches[0] : event.changedTouches && event.changedTouches.length ?
1670				event.changedTouches[0] : event;
1671
1672		if (event.pageX) {
1673			result.x = event.pageX;
1674			result.y = event.pageY;
1675		} else {
1676			result.x = event.clientX;
1677			result.y = event.clientY;
1678		}
1679
1680		return result;
1681	};
1682
1683	/**
1684	 * Determines if the input is a Number or something that can be coerced to a Number
1685	 * @protected
1686	 * @param {Number|String|Object|Array|Boolean|RegExp|Function|Symbol} - The input to be tested
1687	 * @returns {Boolean} - An indication if the input is a Number or can be coerced to a Number
1688	 */
1689	Owl.prototype.isNumeric = function(number) {
1690		return !isNaN(parseFloat(number));
1691	};
1692
1693	/**
1694	 * Gets the difference of two vectors.
1695	 * @todo #261
1696	 * @protected
1697	 * @param {Object} - The first vector.
1698	 * @param {Object} - The second vector.
1699	 * @returns {Object} - The difference.
1700	 */
1701	Owl.prototype.difference = function(first, second) {
1702		return {
1703			x: first.x - second.x,
1704			y: first.y - second.y
1705		};
1706	};
1707
1708	/**
1709	 * The jQuery Plugin for the Owl Carousel
1710	 * @todo Navigation plugin `next` and `prev`
1711	 * @public
1712	 */
1713	$.fn.owlCarousel = function(option) {
1714		var args = Array.prototype.slice.call(arguments, 1);
1715
1716		return this.each(function() {
1717			var $this = $(this),
1718				data = $this.data('owl.carousel');
1719
1720			if (!data) {
1721				data = new Owl(this, typeof option == 'object' && option);
1722				$this.data('owl.carousel', data);
1723
1724				$.each([
1725					'next', 'prev', 'to', 'destroy', 'refresh', 'replace', 'add', 'remove'
1726				], function(i, event) {
1727					data.register({ type: Owl.Type.Event, name: event });
1728					data.$element.on(event + '.owl.carousel.core', $.proxy(function(e) {
1729						if (e.namespace && e.relatedTarget !== this) {
1730							this.suppress([ event ]);
1731							data[event].apply(this, [].slice.call(arguments, 1));
1732							this.release([ event ]);
1733						}
1734					}, data));
1735				});
1736			}
1737
1738			if (typeof option == 'string' && option.charAt(0) !== '_') {
1739				data[option].apply(data, args);
1740			}
1741		});
1742	};
1743
1744	/**
1745	 * The constructor for the jQuery Plugin
1746	 * @public
1747	 */
1748	$.fn.owlCarousel.Constructor = Owl;
1749
1750})(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.