/**
* @name jQuery.touchSlider
* @version 201209_2
* @since 201106
* @param Object settings
* roll - (default true)
* flexible - (default false)
* view - (default 1)
* speed - (default 75)
* range - (default 0.15)
* page - (default 1)
* transition - CSS3 transition (default false)
* btn_prev - prev (jQuery Object, default null)
* btn_next - next (jQuery Object, default null)
* paging - page (jQuery Object, default null)
* initComplete -
* counter -
*
* @example
$("#target").touchSlider({
flexible : true
});
*/
(function ($) {
$.fn.touchSlider = function (settings) {
settings.supportsCssTransitions = (function (style) {
var prefixes = ['Webkit','Moz','Ms'];
for(var i=0, l=prefixes.length; i < l; i++ ) {
if( typeof style[prefixes[i] + 'Transition'] !== 'undefined') {
return true;
}
}
return false;
})(document.createElement('div').style);
settings = jQuery.extend({
roll : true,
flexible : false,
btn_prev : null,
btn_next : null,
paging : null,
speed : 75,
view : 1,
range : 0.15,
page : 1,
transition : false,
initComplete : null,
counter : null,
multi : false
}, settings);
var opts = [];
opts = $.extend({}, $.fn.touchSlider.defaults, settings);
return this.each(function () {
$.fn.extend(this, touchSlider);
var _this = this;
this.opts = opts;
this._view = this.opts.view;
this._speed = this.opts.speed;
this._tg = $(this);
this._list = this._tg.children().children();
this._width = parseInt(this._tg.css("width"));
this._item_w = parseInt(this._list.css("width"));
this._len = this._list.length;
this._range = this.opts.range * this._width;
this._pos = [];
this._start = [];
this._startX = 0;
this._startY = 0;
this._left = 0;
this._top = 0;
this._drag = false;
this._scroll = false;
this._btn_prev;
this._btn_next;
this.init();
$(this)
.bind("touchstart", this.touchstart)
.bind("touchmove", this.touchmove)
.bind("touchend", this.touchend)
.bind("dragstart", this.touchstart)
.bind("drag", this.touchmove)
.bind("dragend", this.touchend)
$(window).bind("orientationchange resize", function () {
_this.resize(_this);
});
});
};
var touchSlider = {
init : function () {
var _this = this;
$(this).children().css({
});
if(this.opts.flexible) this._item_w = this._width / this._view;
if(this.opts.roll) this._len = Math.ceil(this._len / this._view) * this._view;
var page_gap = (this.opts.page > 1 && this.opts.page <= this._len) ? (this.opts.page - 1) * this._item_w : 0;
for(var i=0; i