summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/layout_nav.js.coffee
blob: cad095daae1ddda05550ba0c2b9bd540470ae479 (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
hideEndFade = ($scrollingTabs) ->
  $scrollingTabs.each ->
    $this = $(@)

    $this
      .find('.fade-right')
      .toggleClass('scrolling', $this.width() < $this.prop('scrollWidth'))

$ ->

  hideEndFade($('.scrolling-tabs'))

  $(window)
    .off 'resize.nav'
    .on 'resize.nav', ->
      hideEndFade($('.scrolling-tabs'))

  $('.scrolling-tabs').on 'scroll', (event) ->
    $this = $(this)
    currentPosition = $this.scrollLeft()
    maxPosition = $this.prop('scrollWidth') - $this.outerWidth()

    $this.find('.fade-left').toggleClass('scrolling', currentPosition > 0)
    $this.find('.fade-right').toggleClass('scrolling', currentPosition < maxPosition - 1)