2016-09-13 17:45:13 +05:30
|
|
|
(function() {
|
|
|
|
var hideEndFade;
|
|
|
|
|
|
|
|
hideEndFade = function($scrollingTabs) {
|
|
|
|
return $scrollingTabs.each(function() {
|
|
|
|
var $this;
|
|
|
|
$this = $(this);
|
|
|
|
return $this.siblings('.fade-right').toggleClass('scrolling', $this.width() < $this.prop('scrollWidth'));
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
$(function() {
|
2016-09-29 09:46:39 +05:30
|
|
|
var $scrollingTabs = $('.scrolling-tabs');
|
|
|
|
|
|
|
|
hideEndFade($scrollingTabs);
|
2016-09-13 17:45:13 +05:30
|
|
|
$(window).off('resize.nav').on('resize.nav', function() {
|
2016-09-29 09:46:39 +05:30
|
|
|
return hideEndFade($scrollingTabs);
|
2016-09-13 17:45:13 +05:30
|
|
|
});
|
2016-09-29 09:46:39 +05:30
|
|
|
$scrollingTabs.off('scroll').on('scroll', function(event) {
|
2016-09-13 17:45:13 +05:30
|
|
|
var $this, currentPosition, maxPosition;
|
|
|
|
$this = $(this);
|
|
|
|
currentPosition = $this.scrollLeft();
|
|
|
|
maxPosition = $this.prop('scrollWidth') - $this.outerWidth();
|
|
|
|
$this.siblings('.fade-left').toggleClass('scrolling', currentPosition > 0);
|
|
|
|
return $this.siblings('.fade-right').toggleClass('scrolling', currentPosition < maxPosition - 1);
|
|
|
|
});
|
2016-09-29 09:46:39 +05:30
|
|
|
|
|
|
|
$scrollingTabs.each(function () {
|
|
|
|
var $this = $(this),
|
|
|
|
scrollingTabWidth = $this.width(),
|
|
|
|
$active = $this.find('.active'),
|
|
|
|
activeWidth = $active.width();
|
|
|
|
|
|
|
|
if ($active.length) {
|
|
|
|
var offset = $active.offset().left + activeWidth;
|
|
|
|
|
|
|
|
if (offset > scrollingTabWidth - 30) {
|
|
|
|
var scrollLeft = scrollingTabWidth / 2;
|
|
|
|
scrollLeft = (offset - scrollLeft) - (activeWidth / 2);
|
|
|
|
$this.scrollLeft(scrollLeft);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2016-09-13 17:45:13 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
}).call(this);
|