Coverflow - external controls
POC - http://www.jqueryrain.com/?BUqu2LZk
by Eric Pias
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.2/jquery-ui.js"></script>
<script src="https://rawgit.com/vanderlee/coverflow/master/jquery.coverflow.js"></script>
<script src="https://rawgit.com/vanderlee/coverflow/master/jquery.mousewheel.js"></script>
<div id="numbers">
<div>Zero</div>
<div>One</div>
<div>Two</div>
<div>Three</div>
<div>Four</div>
<div>Five</div>
<div>
<div>
<img src="http://www.dogbreedinfo.com/images12/GordonSetteruntitledDexter.jpg" height="90" width="77"/>
<a class="perform-link" href="http://www.frevvo.com" target="new">
<span class="link-text">Perform</span>
</a>
</div>
</div>
<div>Seven</div>
<div>Eight</div>
<div>Nine</div>
</div>
<div class="controls">
<div class="button first">«</div>
<div class="button previous"><</div>
<span class="dots">
<div class="current"></div> <div></div> <div></div> <div></div> <div></div>
<div></div> <div></div> <div></div> <div></div> <div></div>
</span>
<div class="button next">></div>
<div class="button last">»</div>
</div>
CSS
#numbers {
background-color: #eee;
padding: 10px;
}
#numbers > * {
width: 100px;
height: 100px;
border: solid 2px black;
text-align: center;
line-height: 10px;
font-size: 25px;
background-color: rgba(123,45,67,.5);
cursor: pointer;
}
.controls {
background-color: #ccc;
font-family: "Segoe UI", Verdana, Arial, sans-serif;
font-size: 20px;
font-weight: bold;
padding: 5px;
text-align: center;
}
.button {
display: inline-block;
padding: 10px;
color: #999;
cursor:pointer;
}
.button:hover {
color: #333;
}
.dots > * {
display: inline-block;
background-color: #999;
border-radius: 100%;
width: 10px;
height: 10px;
margin: 1px;
cursor:pointer;
}
.dots > *.current {
background-color: rgb(123,45,67);
}
.dots > *:hover {
background-color: #333;
}
.link-text {
line-height: 10px;
}
.perform-link {
display: none;
}
.perform-link.show {
display: block;
}
JavaScript
$('#numbers').coverflow({
select: function(event, cover, index) {
$('.dots > *').removeClass('current').eq(index).addClass('current');
},
outerScale: 0.1,
select: function(event, cover, index) {
$("#numbers div").find(".perform-link").hide();
$(cover).find(".perform-link").show();
// append a new items at the end
var nextItemNum = $("#numbers div").length;
if (index+7 >= nextItemNum) {
console.log("*** Apending content item: "+nextItemNum+"-"+(nextItemNum+5));
for (var i=0;i<5;i++) {
var itemNum = nextItemNum+i
$("#numbers").append("<div>"+itemNum+"</div>")
}
$('#numbers').coverflow('refresh');
}
}
});
$('.first').click(function() {
$('#numbers').coverflow('index', 0);
});
$('.last').click(function() {
$('#numbers').coverflow('index', -1);
});
$('.previous').click(function() {
$('#numbers').coverflow('index', Math.max(0, $('#numbers').coverflow('index') - 1));
});
$('.next').click(function() {
$('#numbers').coverflow('index', $('#numbers').coverflow('index') + 1);
});
$('.dots > *').click(function() {
$('#numbers').coverflow('index', $(this).index());
});