/** * @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({ "width":this._width + "px", "overflow":"visible" }); 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 gap) this._left = gap; if(this._left < - gap) this._left = - gap; } if(this.opts.roll) { var tmp_pos = []; for(var i=0; i= 0) || (this._drag && tmp_pos[0] >= 100)) { for(var i=0; i= 0) || (this._drag && tmp_pos[0] > 0)) { for(var i=0; i this._range) r = 1; if(!this._drag || this._scroll) r = 0; return r; }, limit_chk : function () { var last_p = parseInt((this._len - 1) / this._view) * this._view; return ( (this._start[0] == 0 && this._left > 0) || (this._start[last_p] == 0 && this._left < 0) ); }, go_page : function (i, e) { var crt = ($.inArray(0, this._pos) / this._view) + 1; var cal = crt - (i + 1); while(cal != 0) { if(cal < 0) { this.animate(-1, true); cal++; } else if(cal > 0) { this.animate(1, true); cal--; } } }, counter : function () { if(typeof(this.opts.counter) == "function") { var param = { total : Math.ceil(this._len / this._view), current : ($.inArray(0, this._pos) / this._view) + 1 }; this.opts.counter(param); } } }; })(jQuery); $(document).ready(function () { $(".main_visual").hover(function(){ $("#btn_prev,#btn_next").fadeIn() },function(){ $("#btn_prev,#btn_next").fadeOut() }) $dragBln = false; $(".main_image").touchSlider({ flexible : true, speed : 200, btn_prev : $("#btn_prev"), btn_next : $("#btn_next"), paging : $(".flicking_con a"), counter : function (e) { $(".flicking_con a").removeClass("on").eq(e.current-1).addClass("on"); } }); $(".main_image").bind("mousedown", function() { $dragBln = false; }) $(".main_image").bind("dragstart", function() { $dragBln = true; }) $(".main_image a").click(function() { if($dragBln) { return false; } }) timer = setInterval(function() { $("#btn_next").click();}, 5000); $(".main_visual").hover(function() { clearInterval(timer); }, function() { timer = setInterval(function() { $("#btn_next").click();}, 5000); }) $(".main_image").bind("touchstart", function() { clearInterval(timer); }).bind("touchend", function() { timer = setInterval(function() { $("#btn_next").click();}, 5000); }) }); /*yewu*/ jQuery.easing.jswing=jQuery.easing.swing;jQuery.extend(jQuery.easing,{def:"easeOutQuad",swing:function(e,f,a,h,g){return jQuery.easing[jQuery.easing.def](e,f,a,h,g)},easeInQuad:function(e,f,a,h,g){return h*(f/=g)*f+a},easeOutQuad:function(e,f,a,h,g){return -h*(f/=g)*(f-2)+a},easeInOutQuad:function(e,f,a,h,g){if((f/=g/2)<1){return h/2*f*f+a}return -h/2*((--f)*(f-2)-1)+a},easeInCubic:function(e,f,a,h,g){return h*(f/=g)*f*f+a},easeOutCubic:function(e,f,a,h,g){return h*((f=f/g-1)*f*f+1)+a},easeInOutCubic:function(e,f,a,h,g){if((f/=g/2)<1){return h/2*f*f*f+a}return h/2*((f-=2)*f*f+2)+a},easeInQuart:function(e,f,a,h,g){return h*(f/=g)*f*f*f+a},easeOutQuart:function(e,f,a,h,g){return -h*((f=f/g-1)*f*f*f-1)+a},easeInOutQuart:function(e,f,a,h,g){if((f/=g/2)<1){return h/2*f*f*f*f+a}return -h/2*((f-=2)*f*f*f-2)+a},easeInQuint:function(e,f,a,h,g){return h*(f/=g)*f*f*f*f+a},easeOutQuint:function(e,f,a,h,g){return h*((f=f/g-1)*f*f*f*f+1)+a},easeInOutQuint:function(e,f,a,h,g){if((f/=g/2)<1){return h/2*f*f*f*f*f+a}return h/2*((f-=2)*f*f*f*f+2)+a},easeInSine:function(e,f,a,h,g){return -h*Math.cos(f/g*(Math.PI/2))+h+a},easeOutSine:function(e,f,a,h,g){return h*Math.sin(f/g*(Math.PI/2))+a},easeInOutSine:function(e,f,a,h,g){return -h/2*(Math.cos(Math.PI*f/g)-1)+a},easeInExpo:function(e,f,a,h,g){return(f==0)?a:h*Math.pow(2,10*(f/g-1))+a},easeOutExpo:function(e,f,a,h,g){return(f==g)?a+h:h*(-Math.pow(2,-10*f/g)+1)+a},easeInOutExpo:function(e,f,a,h,g){if(f==0){return a}if(f==g){return a+h}if((f/=g/2)<1){return h/2*Math.pow(2,10*(f-1))+a}return h/2*(-Math.pow(2,-10*--f)+2)+a},easeInCirc:function(e,f,a,h,g){return -h*(Math.sqrt(1-(f/=g)*f)-1)+a},easeOutCirc:function(e,f,a,h,g){return h*Math.sqrt(1-(f=f/g-1)*f)+a},easeInOutCirc:function(e,f,a,h,g){if((f/=g/2)<1){return -h/2*(Math.sqrt(1-f*f)-1)+a}return h/2*(Math.sqrt(1-(f-=2)*f)+1)+a},easeInElastic:function(f,h,e,l,k){var i=1.70158;var j=0;var g=l;if(h==0){return e}if((h/=k)==1){return e+l}if(!j){j=k*0.3}if(g