debian-mirror-gitlab/app/assets/javascripts/layout_nav.js.coffee

25 lines
684 B
CoffeeScript
Raw Normal View History

hideEndFade = ($scrollingTabs) ->
$scrollingTabs.each ->
$this = $(@)
$this
2016-08-24 12:49:21 +05:30
.siblings('.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()
2016-08-24 12:49:21 +05:30
$this.siblings('.fade-left').toggleClass('scrolling', currentPosition > 0)
$this.siblings('.fade-right').toggleClass('scrolling', currentPosition < maxPosition - 1)