-
Notifications
You must be signed in to change notification settings - Fork 0
/
owlDisabledArrows.js
56 lines (43 loc) · 1.32 KB
/
owlDisabledArrows.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
* owlDisabledArrows - v1.0.0
* Add a disabled class owlCarousel's non-clickable arrows
*
* owlCarousel : http://owlcarousel.owlgraphic.com/
* owlDisabledArrows : https://github.com/PierreLebedel/owlDisabledArrows
*
* Made by Pierre Lebedel
* Under MIT License
*/
;(function($){
$.fn.owlDisabledArrows = function(options){
var settings = {
disabledClass : 'owl-disabled'
};
if(options) $.extend(settings, options);
return this.each(function(){
var $carousel = $(this);
var updateArrows = function(event){
//console.log(event);
var $target = $(event.target);
var item = event.item;
var defaults = event.relatedTarget.options;
var prevArrow = $target.find('.'+defaults.navClass[0]);
var nextArrow = $target.find('.'+defaults.navClass[1]);
if(!defaults.loop){
if( item.index==0 || item.count==0 ){
prevArrow.addClass(settings.disabledClass);
}else{
prevArrow.removeClass(settings.disabledClass);
}
if( item.index==item.count-1 || item.count==0 ){
nextArrow.addClass(settings.disabledClass);
}else{
nextArrow.removeClass(settings.disabledClass);
}
}
}
$carousel.on('initialized.owl.carousel', updateArrows);
$carousel.on('changed.owl.carousel', updateArrows);
});
};
})(window.jQuery);