I've tried searching but can't find a definitive answer, does anyone know what Stackoverflow uses to highlight changes to a page through that fade-in orange highlight?
Is it just a jquery fade or some sort of pulsate effect?
So for example I've a page that I change a few elements on when a user clicks in various places, I'd like to draw attention to these page updates by p开发者_StackOverflow中文版ulsating them like StackOverflow does.
Presume it's jquery, just not sure which effect.
Thanks.
After looking in the source code a bit, found the exact code that does the "pulse":
// if you have firebug, run this in the console, it will first hide all
$("#notify-container div").hide();
$("body").css('marginTop','0px');
// this actually show the pulse
$("#notify-container div").fadeIn("slow");
$("body").animate({
marginTop: "2.5em"
}, "fast", "linear");
You need better reverse engineering skills, especially when you have the source code.
Take note that the body animation has a couple of vars that make sure marginTop has the proper size. This exact code is used for new users, giving the notify:
Welcome to Q&A for professional and enthusiast programmers — check out the FAQ!
Using jquery you can do so like following:
<input type="button" value="TEST" id="button"/>
<div id="fade" style="display:none">This is test</div>
$('#button').click(function(){
$('#fade').fadeIn(5000,function(){
$('#fade').fadeOut(5000);
});
});
精彩评论