I have a div that slides in using a toggle. I would like the user to be able to click the toggle which slides in the div and then if they click outside of #hiddenpanel the #hiddenpanel slides out of screen.
I currently have the div sliding in and out using the toggle, i just need to make it so when the user clicks outside of the div (once it has slid in) the div slides back out...
Hope this makes any sense!
Here is my JQuery code so far:
var speed = 800;
$('#close-bar').on('click', function(){
var $$ = $(this),
panelWidth = $('#hiddenPanel').outerWidth();
if( $$.is('.myButton') ){
$('#hiddenPanel').animate({right:0}, speed);
$$.removeClass('myButton')
} else {
$('#hiddenPanel').animate({right:-panelWidth}, speed);
$$.addClass('myButton')
}
});
Here is the mark up :
<div id="hiddenPanel" class="txt-highlight-color bg-color bg-pattern">
</div>
Here is the URL : http://www.bboyrival.com/
The toggle is the 'Profile Info' text at the bottom right.
Thanks for your time.