Recently I completed a project where I had to show a panel to the left side using JQuery, on mouse hover it comes out and on mouse leave it goes back. Its seems to be easy but to maintain the functionality is not that easy.
Here's a small snippet on how to do it.
HTML
[html]
<div id="sidePanel">
<div id="panelContent">
<iframe src="//www.facebook.com/plugins/likebox.php?href=http%3A%2F%2Fwww.facebook.com%2FWebsTutorial&width=200&height=258&colorscheme=light&show_faces=true&border_color&stream=false&header=false&appId=253401284678598" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:200px; height:258px;" allowTransparency="true"></iframe>
</div>
<div id="panelHandle">
<p>Facebook</p>
</div>
</div>
[/html]
JQuery
[js]
jQuery(function($) {
$(document).ready(function() {
$('#panelHandle').hover(function() {
$('#sidePanel').stop(true, false).animate({
'left': '0px'
}, 900);
}, function() {
jQuery.noConflict();
});
jQuery('#sidePanel').hover(function() {
// Do nothing
}, function() {
jQuery.noConflict();
jQuery('#sidePanel').animate({
left: '-201px'
}, 800);
});
});
});
[/js]
Demo :
Great!!
ReplyDeletevery cool and simple..
ReplyDeleteIt helps a lot for me! Thank you!
ReplyDeletelooks very slick, but being new to jquery, can this be done without downloading plugins? Facebook like box?
ReplyDeleteNice, i like your approach to it.,
ReplyDeletewow , it is so surprise !
ReplyDeleteReally nice. How can we animate it using on click function.
ReplyDeleteHi, nice work! When scrolling the page, the handle will stay in place but it will not function anymore. I therefore set the position of #sidePanel absolute, so it stys at top of the page.
ReplyDeleteThanks for this tutorial, it has saved my day ;)!
ReplyDeletethanks dude
ReplyDeleteworks fine with chrome and ff... but not working properly on IE.. :(
ReplyDeleteok
ReplyDeleteHello. Thank you. Because the problem is not with Microsoft Internet Explorer Zero lines can be added.
ReplyDelete* html #sidePanel {
position: absolute;}
#panelHandle{
background-color:#00F;
....}
please let me how to add the panel handle on right side of the screen with same functionality.. it will be great help from you
ReplyDelete