Coder Social home page Coder Social logo

oshit / lory Goto Github PK

View Code? Open in Web Editor NEW

This project forked from loryjs/lory

0.0 2.0 0.0 533 KB

Touch enabled minimalistic slider written in vanilla JavaScript.

Home Page: http://meandmax.github.io/lory/

License: MIT License

CSS 3.34% HTML 39.12% JavaScript 57.54%

lory's Introduction

Please visit: http://meandmax.github.io/lory/

Touch enabled minimalistic slider written in vanilla JavaScript.

license npm

build code climate devDependencies

Join the chat at https://gitter.im/meandmax/lory

Install with node

npm install --save lory.js

var lory = require('lory.js');

Install with bower

bower install lory --save

Local development

// To install dev dependencies run:

npm install -g grunt-cli
npm install

// To start the development server run:

grunt start

// To lint your code run:

grunt lint

// To make a full new build run:

grunt build

Run tests

// To install dev dependencies run:

npm install

// To start karma in chrome browser and run tests:

grunt karma

Prerequisited markup

<div class="slider js_simple simple">
    <div class="frame js_frame">
        <ul class="slides js_slides">
            <li class="js_slide">1</li>
            <li class="js_slide">2</li>
            <li class="js_slide">3</li>
            <li class="js_slide">4</li>
            <li class="js_slide">5</li>
            <li class="js_slide">6</li>
        </ul>
    </div>
</div>

Prerequisited css

  .frame {
        position: relative;
        font-size: 0;
        line-height: 0;
        overflow: hidden;
        white-space: nowrap;
    }

    .slides {
        display: inline-block;
    }

    li {
        position: relative;
        display: inline-block;

        // example width has to specified for the different views (media queries)
        width: 880px;
    }

Integration

    <script src="js/lory.min.js"></script>
    <script>
        'use strict';

        document.addEventListener('DOMContentLoaded', function() {
            var simple = document.querySelector('.js_simple');

            lory(simple, {
                // options going here
            });
        });
    </script>

Integration as a jQuery Plugin

    <script src="js/jquery.lory.min.js"></script>
    <script>
        'use strict';

        $(function() {
            $('.js_simple').lory({
                infinite: 1
            });
        });
    </script>

Integration of multiple sliders on one page

    <script src="js/lory.js"></script>
    <script>
        'use strict';

        document.addEventListener('DOMContentLoaded', function() {
            Array.prototype.slice.call(document.querySelectorAll('.js_slider')).forEach(function (element, index) {
                lory(element, {});
            });
        });
    </script>

Public API

prev slides to the previous slide
next slides to the next slide
slideTo slides to the index given as an argument: (arguments: index {number})
returnIndex returns the index of the current slide element
setup Binds eventlisteners, merging default and user options, setup the slides based on DOM (called once during initialisation). Call setup if DOM or user options have changed or eventlisteners needs to be rebinded.
reset sets the slider back to the starting position and resets the current index (called on Resize event)
destroy destroys the lory instance by removing all lory specific event listeners

Options

slidesToScroll slides scrolled at once default: 1
infinite like carousel, works with multiple slides. (do not combine with rewind) default: false (number of visible slides)
rewind if slider reached the last slide, with next click the slider goes back to the startindex. (do not combine with infinite) default: false
slideSpeed time in milliseconds for the animation of a valid slide attempt default: 300
rewindSpeed time in milliseconds for the animation of the rewind after the last slide default: 600
snapBackSpeed time for the snapBack of the slider if the slide attempt was not valid default: 200
ease cubic bezier easing functions: http://easings.net/de default: 'ease'
classNameFrame class name for slider frame default: 'js_frame'
classNameSlideContainer class name for slides container default: 'js_slides'
classNamePrevCtrl class name for slider previous control default: 'js_prev'
classNameNextCtrl class name for slider next control default: 'js_next'

Events

before.lory.init fires before initialisation (first in setup function)
after.lory.init fires after initialisation (end of setup function)
before.lory.slide fires before slide change | arguments: currentSlide, nextSlide
after.lory.slide fires after slide change | arguments: currentSlide
on.lory.resize fires on every resize event
on.lory.touchstart fires on every slider touchstart event
on.lory.touchmove fires on every slider touchmove event
on.lory.touchend fires on every slider touchend event
on.lory.destroy fires when the slider instance gets destroyed

Browser Support

  • Chrome
  • Safari
  • FireFox
  • Opera
  • Internet Explorer 10+
  • Internet Explorer 9 (graceful, without transitions)

Copyright

Copyright © 2015 Maximilian Heinz, contributors. Released under the MIT License

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.