- Support loop
- User can easy custom animate function.
- Support jQuery and Zepto
- Support touch screen.
var picIslider;
$("#pic-islider").islider({
currentIndex: 0,
duration: .6,
// easing: "ease-in",
touch: true,
loop: true,
defaultPosition: "relative",
start: undefined,
ended: undefined,
container: ".isilder-container",
indicators: ".isilder-indicators li",
prevBtn: ".prev-btn",
nextBtn: ".next-btn"
},function(){
picIslider = this;
});
Just overwrite $.fn.islider.animate function.
$.fn.islider.animate = function(leftValue, t, easing) {
var scope = this;
scope.container.css("transition", "");
setTimeout(function(){
move(scope.container).set("left", leftValue).duration(t*1000).ease(easing).end(function(){
scope.container.css("transition", "none");
setTimeout(function(){
scope.end();
}, 50);
});
}, 50);
};
- seekTo(index, t, easing, [direction])
- index: the index of slide item.
- t: animate time, 0 will has no animate.
- easing: easing, need to pay attention to what animate function you used.
- direction: optional, only can fill in "pref" and "next"
- prev(t, easing)
- t: animate time, 0 will has no animate.
- easing: easing, need to pay attention to what animate function you used.
- next(t, easing)
- t: animate time, 0 will has no animate.
- easing: easing, need to pay attention to what animate function you used.
- 支持循环
- 用户可自定义动画方法
- 支持jQuery和Zepto
- 支持桌面和触摸屏
<div id="pic-islider">
<ul class="islider-container">
<li><img src="images/pic-1.jpg"/></li>
<li><img src="images/pic-2.jpg"/></li>
<li><img src="images/pic-3.jpg"/></li>
<li><img src="images/pic-4.jpg"/></li>
<li><img src="images/pic-5.jpg"/></li>
</ul>
<div id="prev" class="prev-btn"><</div>
<div id="next" class="next-btn">></div>
<ul class="islider-indicators">
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</div>
var picIslider;
$("#pic-islider").islider({
currentIndex: 0, //初始化后,默认显示的index
duration: .6, //动画时长
easing: "ease-in", //缓动,要注意Zepto的缓动和jQuery的是不一样的. ease-in只支持Zepto
touch: true, //是否支持滑动效果,默认为true支持滑动
loop: true, //是否支持循环效果,默认为true支持循环
defaultPosition: "relative", //指定父级容器的定位方式,所默认为relative
start: undefined, //开始切换的调用的function
ended: undefined, //切换结束后调用的function
container: ".isilder-container", //元素的容器
indicators: ".isilder-indicators li", //指示器的容器
prevBtn: ".prev-btn", //上一个按钮,若不在container容器内,需要写完整的选择器路径
nextBtn: ".next-btn" //下一个按钮,若不在container容器内,需要写完整的选择器路径
},function(){
picIslider = this; //slider对象
});
直接重写 $.fn.islider.animate 方法.
$.fn.islider.animate = function(leftValue, t, easing) {
var scope = this;
scope.container.css("transition", "");
setTimeout(function(){
move(scope.container).set("left", leftValue).duration(t*1000).ease(easing).end(function(){
scope.container.css("transition", "none");
setTimeout(function(){
scope.end();
}, 50);
});
}, 50);
};
- seekTo(index, t, easing, [direction])
- index: 元素的index.
- t: 动画时间,0表示无动画.
- easing: 缓动,要注意Zepto的缓动和jQuery的是不一样的.
- direction: 备用,只能使用"pref" 和 "next"
- prev(t, easing)
- t: 动画时间,0表示无动画.
- easing: 缓动,要注意Zepto的缓动和jQuery的是不一样的.
- next(t, easing)
- t: 动画时间,0表示无动画.
- easing: 缓动,要注意Zepto的缓动和jQuery的是不一样的.