Skip to content

Instantly share code, notes, and snippets.

@abackstrom
Created January 12, 2012 15:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abackstrom/1601019 to your computer and use it in GitHub Desktop.
Save abackstrom/1601019 to your computer and use it in GitHub Desktop.
P2 jQuery.animate() fixes: transparency and callback
Index: js/p2.js
===================================================================
--- js/p2.js (revision 8687)
+++ js/p2.js (working copy)
@@ -141,9 +141,10 @@
var cnt = newComment.contents();
newComment.children('li.newcomment').each(function() {
if (isElementVisible(this) && !showNotification) {
- $(this).animate({backgroundColor:'transparent'}, {duration: 1000}, function(){
- $(this).removeClass('newcomment');
- });
+ $(this).animate({backgroundColor:'transparent'}, {duration: 1000, complete: function(){
+ // jquery-color fades to white, not transparent
+ $(this).removeClass('newcomment').css({backgroundColor:''});
+ }});
}
bindActions(this, 'comment');
});
@@ -821,16 +822,17 @@
function removeYellow() {
$('li.newcomment, tr.newcomment').each(function() {
if (isElementVisible(this)) {
- $(this).animate({backgroundColor:'transparent'}, {duration: 2500}, function(){
- $(this).removeClass('newcomment');
- });
+ $(this).animate({backgroundColor:'transparent'}, {duration: 2500, complete: function(){
+ $(this).removeClass('newcomment').css({backgroundColor:''});
+ }});
}
});
if (isFirstFrontPage) {
$('#main > ul > li.newupdates').each(function() {
if (isElementVisible(this)) {
- $(this).animate({backgroundColor:'transparent'}, {duration: 2500});
- $(this).removeClass('newupdates');
+ $(this).animate({backgroundColor:'transparent'}, {duration: 2500, complete: function(){
+ $(this).removeClass('newupdates').css({backgroundColor:''});
+ }});
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment