做网站|网站建设,就上易助科技网

前端技术文档及相关资料下载

关于前端html、css、js等技术上的各种疑难棘手问题的解决方案探讨及相关资料下载!

JQuery可触屏极简滑块插件lory.js
来源:易助科技网浏览量:1收藏

简介

lory.js是一款JQuery可触屏极简滑块插件。插件特定:

1)硬件加速转换;

2)可用作jQuery插件;

3)支持自定义动画功能;

4)无限循环。

 


(下载的附件中附有DEMO)

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


使用

1.  引入文件

<script src="js/lory.min.js"></script>

<script src="js/jquery.min.js"></script>


2.  HTML

<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> [CSS]

.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;
}


3.  用法示例

将其作为ES2015模块使用:

import { lory } from 'lory.js';

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

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

将其作为commonJS模块使用:

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

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

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

以JQuery方式使用:

<script>
'use strict';

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


相关链接

官方地址:http://loryjs.github.io/lory/

GitHub 地址 :https://github.com/loryjs/lory