Sha256: 7f27ad4586d136d4e62102aae1630827f80d7805c3c94417354416902b0e3eb1

Contents?: true

Size: 632 Bytes

Versions: 7

Compression:

Stored size: 632 Bytes

Contents

class Spina.InfiniteScroll
  @init: (link) ->
    $(window).off('scroll.infiniteScroll')

    $link = $(link)
    if (url = $link.find('a').attr('href'))
      $(window).on 'scroll.infiniteScroll', => @loadNextPage($link)
      $(window).scroll()

  @loadNextPage: ($link) ->
    if ($(window).scrollTop() > $link.offset().top - $(window).height() - 500)
      $(window).off('scroll.infiniteScroll')
      $.rails.disableElement($link.find('a'))
      $.getScript($link.find('a').attr('href'))

$.fn.infiniteScroll = () ->
  Spina.InfiniteScroll.init(this)

$(document).on 'page:change', ->
  $(window).off('scroll.infiniteScroll')

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
spina-0.9.0 app/assets/javascripts/spina/admin/spina.infinite_scroll.coffee
spina-0.8.3 app/assets/javascripts/spina/admin/spina.infinite_scroll.coffee
spina-0.8.2 app/assets/javascripts/spina/admin/spina.infinite_scroll.coffee
spina-0.8.1 app/assets/javascripts/spina/admin/spina.infinite_scroll.coffee
spina-0.8.0 app/assets/javascripts/spina/admin/spina.infinite_scroll.coffee
spina-0.7.3 app/assets/javascripts/spina/admin/spina.infinite_scroll.coffee
spina-0.7.2 app/assets/javascripts/spina/admin/spina.infinite_scroll.coffee