Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed container so that it would load extra messages if it detected that... #361

Merged
merged 1 commit into from
May 15, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/assets/javascripts/backbone/views/channel_pane.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's check if the $container object has a scroll bar. if it does not, load more messages until it does.

@loading_new_messages = true;
@loadMoreActivities($container)

$container.bind 'scroll', =>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we bind to the "scroll" event, we have to make sure a scroll bar is actually present or it will never trigger. In the case of #358, the user had a vertical monitor which didn't allow for a scroll bar to appear. Thus, they couldn't scroll to trigger new messages.

if $container.scrollTop() <= 100 && !@loading_new_messages
@loading_new_messages = true
Expand Down
3 changes: 3 additions & 0 deletions app/assets/javascripts/layout.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ $(document).ready ->
$(this).closest('.nav').addClass('search-focus')
.on 'blur', ->
$(this).closest('.nav').removeClass('search-focus')

$.fn.hasScrollBar = ->
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A method that builds on a jQuery selector for ease of use. Not...really sure where to put this, so I put it in layout, but perhaps it should go somewhere different?

(if @get(0) then @get(0).scrollHeight > @innerHeight() else false)