summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/layout_nav.js
blob: ce472f3bcd0aac3d6e411a4e637295610dc2a1a2 (plain)
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
(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() {
    hideEndFade($('.scrolling-tabs'));
    $(window).off('resize.nav').on('resize.nav', function() {
      return hideEndFade($('.scrolling-tabs'));
    });
    return $('.scrolling-tabs').on('scroll', function(event) {
      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);
    });
  });

}).call(this);