Slider DEV

by moob

HTML

<div id="aParent">
    <div class="slyduh">
        <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">
                    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.</div>
            </li>
            <li style="background-image:url('http://lorempixel.com/400/400/')">3</li>
        </ul>
    </div>
    <header><h1>hmm</h1>Here's some content that may be required to hold the slider open</header>
</div>
<div style="margin:20px">
     <h3>Responsive background slider thing</h3>

    <p>Flexible slider that takes html.</p>
<code>
    <b>'fillMode' : '[fill | flex | fit]'</b><br />
'fill' = all slides are scaled to fill parent wrapper whatever the wrapper's current size (so it the wrapper is flexible so is the content).<br />
'flex' = slides can be any size<br />
'fit' = all slides are scaled up to match largest slide.<br />
    <br />
			transitionSpeed        : 300, <br />
			cycle    : 6000, <br />
			startPosition	 : 0, //startingSlide (zero index)<br />
            complete	 : null //function callback on complete<br />

    </code>

</div>

CSS

html, body {
    margin:0;
}
header {
    width:60%;
    margin:auto;
    border:1px dotted white;
    color:#ddd;
}
header:hover {
    height:300px;
    border-color:yellow;
}
.slyduh {
    width: 100%;
    min-width:100%;
    max-width:100%;
    max-height:100%;
    overflow:hidden;
    position:relative;
    z-index:0;
}
.slyduh.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;
}
.slyduh.fill ul {
    display:block; top:0; right:0; bottom:0; left:0;
    position:absolute;
    height:100%; min-height:100%;
}
.slyduh.fill ul li {
    height:100%; min-height:100%;
}
.slyduh ul {
    list-style: none;
    margin: 0;
    padding: 0;
    position: relative;
    width: 10000%;
    display:block;
}
.slyduh 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;
}
.nextButton, .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 white;
    box-shadow:0px 0px 3px 2px rgba(0, 0, 0, .5);
}
.prevButton {
    right:auto;
    left:-1px;
    border-radius:0 5px 5px 0;
}
.nextButton:hover, .prevButton:hover {
 background-color:rgba(25,255,255,.5)
}
#bigger {
    font-size:180%;
}
#aParent {
    min-height:200px;
    position:relative;
}
@media only screen and (max-width : 400px) {
    #aParent {
        border:0px...

JavaScript

/*
can be used as a background slider
slider should stretch to fill parent (default)
OR optionally flex to fit content
*/
(function ($) {

    $.fn.slyduh = function (options) {

        // default settings
        var settings = $.extend({
            fillMode: 'fill', //fill (fill parent) || flex (adaptive to fits content) || fit (all scaled to match largest slide)
            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;

            //settings
            console.log(settings.fillMode);
            //initial sizes
            if (settings.fillMode == "fit") { //scale to largest slide
                slides.height(cassette.height());
            }
            if (settings.fillMode == "flex") { //grow/shrink to current visible content
            }
            if (settings.fillMode == "fill") { //grow/shrink to fill in parent
               // slides.height(parent.height());
                slider.addClass("fill");
            }
            if (settings.fillMode == "flexfill") {
                    slider.removeClass("fill");
                    parent.css("height","auto");
                    slides.css("height", "auto");
                    slides.height(slider.height());
                    parent.css("min-height",slider.height());
                    slider.addClass("fill");
                }



            //set the transition speed...