Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Notification alert similar to how stackoverflow functions

Tags:

javascript

css

How does stackoverflow create the slidedown effect to alert a user of a change ?

like image 834
Chris Avatar asked Sep 15 '10 13:09

Chris


2 Answers

Stack Overflow uses the jQuery framework, which has a method to show a hidden element using a simple animation, something like:

$('#notification-bar').show('slow');

http://api.jquery.com/show/ (check out the demos).

It is fixed to the top of the page using position:fixed in CSS:

#notification-bar { 
   position:fixed;
   top: 0px; 
   left: 0px;
   width: 100%;
}
like image 136
Andy E Avatar answered Sep 21 '22 14:09

Andy E


I think they use a timed event: jQuery Timed Event

Which sends an AJAX call to the SO severs: http://api.jquery.com/jQuery.ajax/

And then shows it in the div using the effect Andy E mentioned

like image 26
bjudson Avatar answered Sep 23 '22 14:09

bjudson