Can anyone help with adding navigation arrows to the code snippet found here
Slide a div offscreen using jQuery
and the first answer given …. http://jsfiddle.net/jtbowden/ykbgT/2/
I want to be able to add direction arrows or prev/next links
Code below
html:
<div id="container">
<div id="box1" class="box">Div #1</div>
<div id="box2" class="box">Div #2</div>
<div id="box3" class="box">Div #3</div>
<div id="box4" class="box">Div #4</div>
<div id="box5" class="box">Div #5</div>
</div>
css:
body {
padding: 0px;
}
#container {
position: absolute;
margin: 0px;
padding: 0px;
width: 100%;
height: 100%;
overflow: hidden;
}
.box {
position: absolute;
width: 50%;
height: 300px;
line-height: 300px;
font-size: 50px;
text-align: center;
border: 2px solid black;
left: 150%;
top: 100px;
margin-left: -25%;
}
#box1 {
background-color: green;
left: 50%;
}
#box2 {
background-color: yellow;
}
#box3 {
background-color: red;
}
#box4 {
background-color: orange;
}
#box5 {
background-color: blue;
}
javascript:
$('.box').click(function() {
$(this).animate({
left: '-50%'
}, 500, function() {
$(this).css('left', '150%');
$(this).appendTo('#container');
});
$(this).next().animate({
left: '50%'
}, 500);
});
It works brilliantly but navigation is one direction and activated by clicking the boxes
thanks in advance
aor
Should be easy to do 🙂
make a “navigation control” wrapper element:
add 2 main elements to act as left and right movement buttons:
add an event handler to each movement element for each animation:
replace the comments with function calls to move the nav (you already have the logic to move it left 😉 )
NOTE: Make sure you add “cursor: pointer” to the button element CSS classes so that they appear to be clickable to the user.