Sha256: e61ea7238b2a739a88c7267b0c1dc854b30b07b76631481bc6a16fec82396251

Contents?: true

Size: 1013 Bytes

Versions: 1

Compression:

Stored size: 1013 Bytes

Contents

# -----------------------------------------------------------------------------
# LIST PAGINATION
# -----------------------------------------------------------------------------

@listPagination =

  # PRIVATE ===============================================

  _bind_pagination: ->
    @lastScrollTop = 0

    @$items.scroll (e) =>
      # trigger next page loading only when scrolling to bottom
      if @lastScrollTop < e.target.scrollTop
        @lastScrollTop = e.target.scrollTop

        if ! @config.arrayStore.dataFetchLock

          if @listItemsHeight < (@listViewHeight + e.target.scrollTop + 100)
            @_show_spinner()
            @config.arrayStore.load
              onSuccess: => @_update_height_params()
              onError:   => chr.showAlert("Can't load next page, server error 500.")

    @_update_height_params()


  _update_height_params: ->
    @listViewHeight  = @$el.height()
    @listItemsHeight = 0
    @$items.children().each (i, el) => @listItemsHeight += $(el).height()




Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
chr-0.2.7 app/assets/javascripts/chr/core/list_pagination.coffee