From b227c8a398edccd44a4e2dea7796f78f8f4d0c6f Mon Sep 17 00:00:00 2001 From: Scott Goci Date: Wed, 14 May 2014 14:34:11 -0400 Subject: [PATCH] Fixed container so that it would load extra messages if it detected that a scroll bar was not present on the container --- app/assets/javascripts/backbone/views/channel_pane.js.coffee | 4 ++++ app/assets/javascripts/layout.js.coffee | 3 +++ 2 files changed, 7 insertions(+) diff --git a/app/assets/javascripts/backbone/views/channel_pane.js.coffee b/app/assets/javascripts/backbone/views/channel_pane.js.coffee index a0add6f4..11e127e5 100644 --- a/app/assets/javascripts/backbone/views/channel_pane.js.coffee +++ b/app/assets/javascripts/backbone/views/channel_pane.js.coffee @@ -8,6 +8,10 @@ class Kandan.Views.ChannelPane extends Backbone.View # Flag to avoid pulling new messages when we already requested new messages from the server @loading_new_messages = false + if !$container.hasScrollBar() + @loading_new_messages = true; + @loadMoreActivities($container) + $container.bind 'scroll', => if $container.scrollTop() <= 100 && !@loading_new_messages @loading_new_messages = true diff --git a/app/assets/javascripts/layout.js.coffee b/app/assets/javascripts/layout.js.coffee index 4f8066a0..c4109e65 100644 --- a/app/assets/javascripts/layout.js.coffee +++ b/app/assets/javascripts/layout.js.coffee @@ -21,3 +21,6 @@ $(document).ready -> $(this).closest('.nav').addClass('search-focus') .on 'blur', -> $(this).closest('.nav').removeClass('search-focus') + + $.fn.hasScrollBar = -> + (if @get(0) then @get(0).scrollHeight > @innerHeight() else false)