Slider (Transdev) DEV 0.5 with touch
by moob
HTML
<script src="http://www.stunn.co.uk/stunnplate/lib/touchListener/touchListener.1.0.js"></script>
<div id="aParent">
<div class="flexslider">
<ul>
<li style="background-image:url('http://lorempixel.com/400/200/')">
<h2 class="slide-in-from-left">1</h2>
<h3 class="slide-in-from-bottom">jhjhj</h3>
</li>
<li style="background-image:url('http://lorempixel.com/400/300/')">
<div id="bigger" class="slide-in-from-top">
2 inner 2 inner 2 inner 2 inner 2 inner 2 inner 2 inner 2 inner 2 inner 2 inner 2 inner 2 inner 2 inner 2 inner 2</div>
</li>
<li style="background-image:url('http://lorempixel.com/400/400/')"><h2 class="slide-in-from-right">3</h2></li>
</ul>
</div>
<!-- <header><h1>Imagine there's an element <em>inside</em> the slider...</h1>
<p>This content that may be required to hold the slider open.</p>
</header>-->
</div>
<div style="margin:20px">
<h3>Responsive background slider thing</h3>
<p>Settings</p>
<code>
loop : true, //endless looping next/prev (boolean)<br />
transitionSpeed : 600, //animation speed (milliseconds)<br />
cycle : 6000, //automatically cycle through slides (pauses on hover). Delay in milliseconds (0 = no cycling)<br />
startPosition : 0, //Starting Slide Index (zero index)<br />
complete : null //function callback on complete<br />
</code>
<p><strong>Animated slide text</strong><br />
Your text can be animated when the slide comes into view. Style and position the elements as you like then apply one of the following classnames. Don't edit the '.slide-in-from-' styles.</p>
<code>
.slide-in-from-left
.slide-in-from-right
.slide-in-from-top
.slide-in-from-bottom
</code>
</div>
CSS
/* for demo only > */
html, body {
margin:0;
}
#bigger {
font-size:180%;
}
#aParent {
min-height:300px;
background-color:#666;
position:relative;
}
@media only screen and (max-width : 400px) {
#aParent {
border:0px solid green;
min-height:0;
height:200px!important;
max-height:200px!important;
}
}
/* < for demo only */
/* flexslider styles */
.flexslider {
width: 100%;
min-width:100%;
max-width:100%;
max-height:100%;
overflow:hidden;
position:relative;
z-index:1;
}
.flexslider.fill {
display:block; top:0; right:0; bottom:0; left:0;
overflow:hidden;
position:absolute;
z-index:1;
height:100%; min-height:100%;
border:0px solid red;
}
.flexslider.fill ul {
display:block; top:0; right:0; bottom:0; left:0;
position:absolute;
height:100%; min-height:100%;
}
.flexslider.fill ul li {
height:100%; min-height:100%;
}
.flexslider.fill ul li:first-of-type, .slyduh.fill ul li:last-of-type {
box-shadow:0px 0 14px black;
}
.flexslider ul {
list-style: none;
margin: 0;
padding: 0;
position: relative;
width: 10000%;
display:block;
}
.flexslider ul > li {
display:inline-block;
position:relative;
margin-right:-4px;
width:1%;
font-size: 30px;
text-align: center;
vertical-align:top;
height:100%;
max-height:100%;
background: #666666 repeat center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
color:black;
text-shadow:0px 0px 10px white;
overflow:hidden;
}
.flexslider-nextButton, .flexslider-prevButton {
display:block;
position:absolute;
height:50px;
z-index:100;
top:0;
bottom:0;
margin:auto;
right:-1px;
background:rgba(255, 255, 255, .6);
border-radius:5px 0 0 5px;
width:80px;
text-align:center;
line-height:50px;
border:1px solid...
JavaScript
/*
a background-image slider
*/
(function ($) {
$.fn.flexslider = function (options) {
// default settings
var settings = $.extend({
fillMode: 'flexfill', //other modes dont work!
transitionSpeed: 600, //ms (should speed should be uniform like MPH or the time taken to do one transition?)
cycle: 6000, //Should it automatically move to next slide? 0=off, 6000 = every 6 seconds
startPosition: 0, //startingSlide (zero index)
loop: false,
complete: null //function callback on complete
}, options);
return this.each(function () {
var slider = $(this),
parent = slider.parent(),
cassette = slider.find("ul").first(),
slides = cassette.find("li"),
count = slides.length,
index = settings.startPosition,
minh = parseInt(parent.css("min-height"));
function setHeight(){
slides.children().each(function(){
var c = $(this).attr("class");
$(this).attr("class",c.replace("slide-","xslide-"));
});
slides.height(slider.height());
slides.children().each(function(){
var c = $(this).attr("class");
$(this).attr("class",c.replace("xslide-","slide-"));
});
}
goToSlide(); //ititial slide
//add controls
var nextbutton = $("<span class='flexslider-nextButton'>NEXT</span>");
var prevbutton = $("<span class='flexslider-prevButton'>PREV</span>");
nextbutton.click(function () {
move(+1);
});
prevbutton.click(function () {
move(-1);
});
//append the buttons
if(settings.fillMode == "fill" ||...