Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
27
rated 0 times [  34] [ 7]  / answers: 1 / hits: 96913  / 11 Years ago, wed, march 27, 2013, 12:00:00

got a code here from someone....



what I like is to make the sliding div from right slide to left, i mean it hides the div to the right and slowly slides to the left for 300px width.



HTML



<a id=loginPanel>quote</a>
<div id=userNav>User Area</div>


CSS



#loginPanel {
color: #000;
cursor:pointer;
}

#userNav {
width: 200px;
height: 200px;
display: none;
background: #ff0000;
}


Jquery



// Open / Close Panel According to Cookie //    
if ($.cookie('panel') == 'open'){
$('#userNav').slideDown('fast');
} else {
$('#userNav').slideUp('fast');
}

// Toggle Panel and Set Cookie //
$('#loginPanel').click(function(){
$('#userNav').slideToggle('fast', function(){
if ($(this).is(':hidden')) {
$.cookie('panel', 'closed');
} else {
$.cookie('panel', 'open');
}
});
});


Please need help on this one. just to make the div slide right to left



here is the fiddle http://jsfiddle.net/7m7uK/195/


More From » jquery

 Answers
9

You can use jQueryUI and additional effects Slide



http://docs.jquery.com/UI/Effects/Slide



Example:



$('#userNav').hide(slide, {direction: left }, 1000);
$('#userNav').show(slide, { direction: right }, 1000);


You can't use .slideToggle() to slide from left to right or vice versa, from http://api.jquery.com/slideToggle/:




The .slideToggle() method animates the height of the matched elements.
This causes lower parts of the page to slide up or down, appearing to
reveal or conceal the items. If the element is initially displayed, it
will be hidden; if hidden, it will be shown.




You should try and change your code to implement this code, but I think it's maybe better if you try with @s15199d answer, than you don't need to use jQueryUI



Ok, I created jsfiddle, you must include jQueryUI in order to work, you have different combinations of slide directions:



http://jsfiddle.net/7m7uK/197/



Ok, created another fiddle with cookies



http://jsfiddle.net/7m7uK/198/


[#79310] Tuesday, March 26, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
hasanjustusf

Total Points: 76
Total Questions: 116
Total Answers: 100

Location: Virgin Islands (U.S.)
Member since Tue, Jul 7, 2020
4 Years ago
hasanjustusf questions
;