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

fix bug with scroll #425

Merged
merged 1 commit into from
Jan 21, 2015
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
6 changes: 2 additions & 4 deletions app/assets/javascripts/backbone/helpers/channels.js.coffee
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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