Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lory.js

Package Overview
Dependencies
Maintainers
1
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lory.js

Touch enabled minimalistic slider written in vanilla JavaScript.

  • 2.5.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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

Touch enabled minimalistic slider written in vanilla JavaScript.

license npm CDNJS jsDelivr Hits

build devDependencies js-standard-style

Join the chat at https://gitter.im/loryjs/lory semantic-release Commitizen friendly

Download

lory is released under the MIT license & supports modern environments. There is also a prebundled CDN version which you can use.

CDN: https://cdnjs.com/libraries/lory.js/

Install with yarn:

yarn add lory.js

Consume it as an ES2015 module:

import { lory } from 'lory.js';

document.addEventListener('DOMContentLoaded', () => {
    const slider = document.querySelector('.js_slider');

    lory(slider, {
        // options going here
    });
});

Consume it as an commonJS module:

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

document.addEventListener('DOMContentLoaded', function() {
    var slider = document.querySelector('.js_slider');

    lory(slider, {
        // options going here
    });
});

Install with bower

bower install lory --save

Local development

// To install dev dependencies run:

yarn

// To start the development server run:

yarn run dev

// To lint your code run:

yarn run lint

// To make a full new build run:

yarn run build

Run tests

// To install dev dependencies run:

yarn install

// To start the karma tests locally run:

yarn run karma-local

Prerequisited markup

<div class="slider js_slider">
    <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

/**
 * (optional) define here the style definitions which should be applied on the slider container
 * e.g. width including further controls like arrows etc.
 */
.slider {
}

.frame {
    /**
     * (optional) wrapper width, specifies width of the slider frame.
     */
    width: 880px;

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

.slides {
    display: inline-block;
}

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

    /**
     * (optional) if the content inside the slide element has a defined size.
     */
    width: 880px;
}

Integration

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

    document.addEventListener('DOMContentLoaded', function() {
        var slider = document.querySelector('.js_slider');

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

Integration as a jQuery Plugin

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

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

Integration of multiple sliders on one page

<script src="dist/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

prevslides to the previous slide
nextslides to the next slide
slideToslides to the index given as an argument: (arguments: index {number})
returnIndexreturns the index of the current slide element
setupBinds 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.
resetsets the slider back to the starting position and resets the current index (called on Resize event)
destroydestroys the lory instance by removing all lory specific event listeners

Options

slidesToScrollslides scrolled at oncedefault: 1
infinitelike carousel, works with multiple slides. (do not combine with rewind)default: false (number of visible slides)
enableMouseEventsenabled mouse eventsdefault: false
rewindif slider reached the last slide, with next click the slider goes back to the startindex. (do not combine with infinite)default: false
rewindPrevif slider is on the first slide, with prev click the slider goes to the last slide. (do not combine with infinite)default: false
slideSpeedtime in milliseconds for the animation of a valid slide attemptdefault: 300
rewindSpeedtime in milliseconds for the animation of the rewind after the last slidedefault: 600
snapBackSpeedtime for the snapBack of the slider if the slide attempt was not validdefault: 200
easecubic bezier easing functions: http://easings.net/dedefault: 'ease'
initialIndexthe slide index to show when the slider is initializeddefault: 0
classNameFrameclass name for slider framedefault: 'js_frame'
classNameSlideContainerclass name for slides containerdefault: 'js_slides'
classNamePrevCtrlclass name for slider previous controldefault: 'js_prev'
classNameNextCtrlclass name for slider next controldefault: 'js_next'
classNameDisabledPrevCtrlclass name for slider previous control then disableddefault: 'disabled'
classNameDisabledNextCtrlclass name for slider next control then disableddefault: 'disabled'

Events

before.lory.initfires before initialisation (first in setup function)
after.lory.initfires after initialisation (end of setup function)
before.lory.slidefires before slide change | arguments: currentSlide, nextSlide
after.lory.slidefires after slide change | arguments: currentSlide
before.lory.destroyfires before the slider instance gets destroyed
after.lory.destroyfires after the slider instance gets destroyed
on.lory.resizefires on every resize event
on.lory.touchstartfires on every slider touchstart event
on.lory.touchmovefires on every slider touchmove event
on.lory.touchendfires on every slider touchend event

Getting Help

Please, do not open issues for general support questions as we want to keep GitHub issues for bug reports and feature requests. You've got much better chances of getting your question answered on StackOverflow where maintainers are looking at questions tagged with loryJS.

StackOverflow is a much better place to ask questions since:

  • There are hundreds of people willing to help on StackOverflow
  • Questions and answers stay available for public viewing so your question / answer might help someone else
  • The StackOverflow voting system assures that the best answers are prominently visible.

To enforce this rule will be systematically closing all the issues that are requests for general support and redirecting people to StackOverflow.

Browser Support

  • Chrome

  • Safari

  • FireFox

  • Opera

  • Internet Explorer 10+

  • Internet Explorer 9 (graceful, without transitions + classlistp)

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

Keywords

FAQs

Package last updated on 19 Jan 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc