<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js"></script>
<meta charset=utf-8 />
<title>Demo by roXon</title>
</head>
<body>
<div id="gallery">
<div id="slider">
<div class="box">
1 Slider Content Will Go Here
</div>
<div class="box">
2 Slider Content Will Go Here
</div>
<div class="box">
3 Slider Content Will Go Here
</div>
<div class="box">
4 Slider Content Will Go Here
</div>
<div class="box">
5 Slider Content Will Go Here
</div>
</div>
<div id="prev"></div>
<div id="next"></div>
<div id="nav_btns">
<div id="scroller"></div>
<ul>
<li>FIRST ITEM</li>
<li>SECOND ITEM</li>
<li>THIRD ITEM</li>
<li>FOURTH ITEM</li>
<li>FIFTH ITEM</li>
</ul>
</div>
</div>
</body>
</html>
// Gallery by roXon 2012.
var $sl = $('#slider'),
slW = $sl.outerWidth(true),
slN = $sl.children().length,
c = 0,
W = slW/slN,
int,
dragging=false;
$('#scroller, #nav_btns li').width(W);
function move(){
c=c==-1?slN-1:c%slN;
$sl.stop().animate({scrollLeft: slW*c},1000);
if(dragging===false){
$('#scroller').stop().animate({left: W*c},500);
}
}
$('#prev, #next').click(function(e){
var btn=this.id==='next'?c++:c--;
move();
});
$('#nav_btns li').click(function(){
c= $(this).index();
move();
});
var cChanged = c; // while dragging chech for c val changed before doing animations!
$("#scroller").draggable({
containment:'parent',
drag: function(){
dragging=true;
var stopPos = $(this).position().left;
c = (Math.abs(stopPos/W).toFixed(0));
if(c!=cChanged){
move(); // animate just if we're not dragging over the same place
cChanged = c;
}
},
stop: function(){
dragging=false;
move();
}
});
function auto(){
int = setInterval(function(){
$('#next').click();
},3500); // SET HERE THE DELAY
}
auto();
$('#gallery').on('mouseenter mouseleave',function(e){
var evt= e.type=='mouseenter' ? clearInterval(int) : auto();
});
Output
You can jump to the latest bin by adding /latest
to your URL
Keyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |