Sha256: 0a84ad047126aa771da6625b317d6357a33234e0e33ffb07d2c38ba5d01e235d

Contents?: true

Size: 905 Bytes

Versions: 1

Compression:

Stored size: 905 Bytes

Contents

angular.module('EssayApp.directives').directive "nanoScroller", ['$timeout', ($timeout) ->
  restrict: 'A'
  scope: true
  link: (scope, element, attrs) ->
    defaults = {
      alwaysVisible: true
    }
    options = scope.$eval(attrs.nanoScroller) || {}
    options = $.extend defaults, options

    initNanoScroller = (update = false)->
      element.nanoScroller(options)
      if update and attrs.scrollOnUpdate?
        switch attrs.scrollOnUpdate
          when 'top'
            element.nanoScroller({ scroll: 'top' })
          when 'bottom'
            element.nanoScroller({ scroll: 'bottom' })
          else
            element.nanoScroller({ scrollTo: $(attrs.scrollOnUpdate) })

    element.on 'reinit.nanoScroller', ->
      initNanoScroller(true)

    if attrs.trackBy?
      scope.$watch attrs.trackBy, (data)->
        initNanoScroller(true)

    $timeout initNanoScroller, 1, false
]

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
translation_cms-0.1.5 app/assets/javascripts/app/directives/nano_scroller.js.coffee