I’m trying to achieve the same blind roll down looking effect google+ has for when you click to view all comments of a post. After some searching I found: http://docs.jquery.com/UI/Effects/Blind#overview but it doesn’t achieve the effect I’m after.
The code alredy present in this html isn’t the partial but the code that helps render the comments sown by default (2) when user enters the page. The partial comments are placed before this on click of a view all link and pushes them down. If more comments are typed before viewing all comments is clicked they are sliced off leaving the 2 most recent comments.
html:
<% if m.comments.any? %>
<div class="allCommentsWrapper">
<% comments(m.id).each do |comment| %>
<div class="comment_container">
<%= link_to image_tag(default_photo_for_commenter(comment), :class => "commenter_photo"), commenter(comment.user_id).username %>
<div class="commenter_content"> <div class="userNameFontStyle"><%= link_to commenter(comment.user_id).username.capitalize, commenter(comment.user_id).username %> - <%= simple_format h(comment.content) %> </div>
</div><div class="comment_post_time"> <%= time_ago_in_words(comment.created_at) %> ago. </div>
</div>
<% end %>
</div>
<% end %>
JQuery:
$('.view_all_comments').off().on('ajax:success', function(e){
e.preventDefault();
$(this).parents('.post_content').find('.comment_container').slice(0, -2).remove();
$(this).parents('.post_content').find('.comment_container:first').before("<%= j render 'users/partials/show_all_comments', :comments => @comments %>");
$(this).parents('.post_content').find('.allCommentsWrapper').hide().show("blind", { direction: "vertical" }, 6000);
});
Anyway this doesn’t achieve the effect I’m after. It’s like the contents are stuck to another background and as the allCommentsWrapper div is sliding down it’s revealing each comment. I want it to seem as if the comments are stuck to the div so as it’s sliding down it’s like the div is being pulled from the bottom but the top part of it is hidden but seems like it’s just behind the divs above it.
The best way to see what I mean is visit google+ and click on e.g. “23 comments” and watch them slide down.
Would appreciate a solution and some tips if possible.
Kind regards
Edit: added code comments
http://jsfiddle.net/MZzUr/51/
How’s this?
Here is an example of how this would be accomplished. Let me know if you need help translating that to your specific example. It’s different as I don’t have your ajax functions, so I mocked the adding of comments.