Skip to content

Commit

Permalink
Merge pull request #425 from hellbinder/fix_bug_with_scroll_squashed
Browse files Browse the repository at this point in the history
fix bug with scroll
  • Loading branch information
scouttyg committed Jan 21, 2015
2 parents 75ca9d8 + e6761ac commit 547764f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
6 changes: 2 additions & 4 deletions app/assets/javascripts/backbone/helpers/channels.js.coffee
Expand Up @@ -128,17 +128,15 @@ class Kandan.Helpers.Channels

@setPaginationState: (channelId, moreActivities, oldest) ->
console.log "pagination element", moreActivities, @channelPaginationEl(channelId)
# Only set pagination data if there are more activities. Otherwise is useless
@channelPaginationEl(channelId).data("oldest", oldest.get("id"))
if moreActivities == true
# Only set pagination data if there are more activities. Otherwise is useless
@channelPaginationEl(channelId).data("oldest", oldest.get("id"))

@channelPaginationEl(channelId).show()
else
@channelPaginationEl(channelId).hide()

# If there are no more messages we will unbind the scroll event
@channelPane(channelId).unbind("scroll")

@setPaginationData: (channelId) ->
$oldestActivity = @channelActivitiesEl(channelId).find(".activity").first()
if $oldestActivity.length != 0
Expand Down
31 changes: 16 additions & 15 deletions app/assets/javascripts/backbone/views/channel_pane.js.coffee
Expand Up @@ -61,18 +61,19 @@ class Kandan.Views.ChannelPane extends Backbone.View
activities.fetch
data: { oldest: oldest },
success: (collection) =>
for activity in collection.models.reverse()
activityView = new Kandan.Views.ShowActivity(activity: activity, silence_mentions: true, silence_music: true)
$container.find(".channel-activities").prepend(activityView.render().el)

if $current_top_element.length != 0
$container.scrollTop($current_top_element.offset().top)

Kandan.Helpers.Channels.setPaginationState(
collection.channelId,
collection.moreActivities,
_.last(collection.models),
$container
)

@loading_new_messages = false
if collection.length > 0
for activity in collection.models.reverse()
activityView = new Kandan.Views.ShowActivity(activity: activity, silence_mentions: true, silence_music: true)
$container.find(".channel-activities").prepend(activityView.render().el)

if $current_top_element.length != 0
$container.scrollTop($current_top_element.offset().top)

Kandan.Helpers.Channels.setPaginationState(
collection.channelId,
collection.moreActivities,
_.last(collection.models),
$container
)

@loading_new_messages = false

0 comments on commit 547764f

Please sign in to comment.