diff --git a/js/lc-micro-slider.js b/js/lc-micro-slider.js index 56aa133..e29b630 100644 --- a/js/lc-micro-slider.js +++ b/js/lc-micro-slider.js @@ -11,6 +11,7 @@ var settings = $.extend({ slide_fx : 'fadeslide', // (string) sliding effect / none - slide - fade - fadeslide - zoom-in - zoom-out + slide_easing : 'ease', // (string) CSS animation easing to use / ease - linear - ease-in (etc) [supports also cubic-bezier] nav_arrows : true, // (bool) shows navigation arrows nav_dots : true, // (bool) shows navigation dots slideshow_cmd : true, // (bool) shows slideshow commands (play/pause) @@ -88,20 +89,32 @@ } - // setup inline CSS for animation timings - $('head').append( - ''); - - // animation class - $wrap_obj.find('.lcms_wrap').addClass('lcms_'+ settings.slide_fx +'_fx'); + if(settings.slide_fx && settings.slide_fx != 'none') { + + // use custom easing? + if(settings.slide_easing && settings.slide_easing != 'ease') { + var easing_code = + '-webkit-animation-timing-function: '+ settings.slide_easing +' !important;'+ + 'animation-timing-function: '+ settings.slide_easing +' !important;'; + } else { + var easing_code = ''; + } + + // setup inline CSS for animation timings + $('head').append( + ''); + + // animation class + $wrap_obj.find('.lcms_wrap').addClass('lcms_'+ settings.slide_fx +'_fx'); + } // autoplay diff --git a/js/lc-micro-slider.min.js b/js/lc-micro-slider.min.js index 85d6539..6777ca6 100644 --- a/js/lc-micro-slider.min.js +++ b/js/lc-micro-slider.min.js @@ -6,19 +6,20 @@ * Licensed under the MIT license */ -(function(c){var p=function(n,d){var f=c.extend({slide_fx:"fadeslide",nav_arrows:!0,nav_dots:!0,slideshow_cmd:!0,carousel:!0,touchswipe:!0,autoplay:!1,animation_time:700,slideshow_time:5E3,pause_on_hover:!0,loader_code:''},d),k=c(n);k.data("lcms_vars",{slides:[],shown_slide:0,cached_img:[],uniqid:"",is_sliding:!1,is_playing:!1,paused_on_hover:!1});k.data("lcms_settings",f);var q=function(b,m,e){var l=b.data("lcms_vars"),d=b.data("lcms_settings"),h=l.slides[e],g=h.img? -"lcms_preload":"";d=h.img?d.loader_code:"";switch(m){case "init":var f="lcms_active_slide";break;case "fade":f="lcms_fadein";break;case "prev":f="lcms_before";break;case "next":f="lcms_after"}b.find(".lcms_nav_dots span").removeClass("lcms_sel_dot");b.find(".lcms_nav_dots span").eq(e).addClass("lcms_sel_dot");m=h.img?'
':"";var k=c.trim(h.content)?'
'+h.content+"
":"";g='
'+m+k+"
"+d+"
";b.find(".lcms_container").append(g);h.img&&(-1===c.inArray(h.img,l.cached_img)?c("").bind("load",function(){l.cached_img.push(this.src);c(".lcms_slide[rel="+e+"]").removeClass("lcms_preload");c(".lcms_slide[rel="+e+"]").find("> *").not(".lcms_inner").fadeOut(300,function(){c(this).remove()});b.trigger("lcms_slide_shown",[e,h]);c(".lcms_slide[rel="+e+"]").hasClass("lcms_active_slide")&&b.trigger("lcms_initial_slide_shown", -[e,h])}).attr("src",h.img):(c(".lcms_slide[rel="+e+"]").removeClass("lcms_preload").addClass("lcms_cached"),c(".lcms_slide[rel="+e+"]").find("> *").not(".lcms_inner").remove(),b.trigger("lcms_slide_shown",[e,h])));1").bind("load",function(){l.cached_img.push(this.src)}).attr("src",l.slides[g].img));2").bind("load", -function(){l.cached_img.push(this.src)}).attr("src",l.slides[g].img))};lcms_slide=function(b,c){var e=b.data("lcms_vars"),m=b.data("lcms_settings"),d=m.animation_time,h=e.shown_slide;if(!m.carousel&&("prev"==c&&!e.shown_slide||"next"==c&&e.shown_slide==e.slides.length-1)||e.lcms_is_sliding||1==e.slides.length||"number"==typeof c&&(0>c||c>e.slides.length-1))return!1;if("prev"==c)var g=0===h?e.slides.length-1:h-1;else"next"==c?g=h==e.slides.length-1?0:h+1:(g=c,c=g>h?"next":"prev");e.lcms_is_sliding= -!0;b.addClass("lcms_is_sliding lcms_moving_"+c);b.find(".lcms_active_slide").addClass("lcms_prepare_for_"+c);q(b,"fade"==m.slide_fx?"fade":c,g);e.shown_slide=g;b.trigger("lcms_changing_slide",[g,e.slides[g],h]);m.carousel||(b.find(".lcms_prev, .lcms_next, .lcms_play > span").removeClass("lcms_disabled_btn"),g?g==e.slides.length-1&&b.find(".lcms_next, .lcms_play > span").addClass("lcms_disabled_btn"):b.find(".lcms_prev").addClass("lcms_disabled_btn"));setTimeout(function(){b.find(".lcms_active_slide").remove(); -e.lcms_is_sliding=!1;b.removeClass("lcms_is_sliding lcms_moving_"+c);b.find(".lcms_slide").removeClass("lcms_fadein lcms_before lcms_after").addClass("lcms_active_slide");b.trigger("lcms_new_active_slide",[g,e.slides[g]])},d)};c(".lcms_prev").unbind("click");k.delegate(".lcms_play","click",function(){var b=c(this).parents(".lcms_wrap").parent();jQuery(this).hasClass("lcms_pause")?b.lcms_stop_slideshow():b.lcms_start_slideshow()});c(".lcms_prev").unbind("click");k.delegate(".lcms_prev:not(.lcms_disabled)", -"click",function(){var b=c(this).parents(".lcms_wrap").parent();"undefined"!=typeof lcms_one_click&&clearTimeout(lcms_one_click);lcms_one_click=setTimeout(function(){b.lcms_stop_slideshow();lcms_slide(b,"prev")},5)});c(".lcms_next").unbind("click");k.delegate(".lcms_next:not(.lcms_disabled)","click",function(){var b=c(this).parents(".lcms_wrap").parent();"undefined"!=typeof lcms_one_click&&clearTimeout(lcms_one_click);lcms_one_click=setTimeout(function(){b.lcms_stop_slideshow();lcms_slide(b,"next")}, -5)});c(".lcms_next").unbind("click");k.delegate(".lcms_nav_dots span:not(.lcms_sel_dot)","click",function(){var b=c(this).parents(".lcms_wrap").parent(),m=parseInt(jQuery(this).attr("rel"));"undefined"!=typeof lcms_one_click&&clearTimeout(lcms_one_click);lcms_one_click=setTimeout(function(){b.lcms_stop_slideshow();lcms_slide(b,m)},5)});var p=function(){"function"==typeof c.fn.swipe?k.find(".lcms_wrap").swipe({swipeRight:function(){var b=jQuery(this).parent();b.lcms_stop_slideshow();lcms_slide(b,"prev")}, -swipeLeft:function(){var b=jQuery(this).parent();b.lcms_stop_slideshow();lcms_slide(b,"next")},threshold:40,allowPageScroll:"vertical"}):"function"==typeof AlloyFinger&&new AlloyFinger(k.find(".lcms_wrap")[0],{swipe:function(b){var c=jQuery(this).parent();c.lcms_stop_slideshow();"Right"===b.direction?lcms_slide(c,"prev"):"Left"===b.direction&&lcms_slide(c,"next")}})};f.pause_on_hover&&k.delegate(".lcms_wrap","mouseenter",function(){var b=c(this).parent(),d=b.data("lcms_vars");b.data("lcms_settings"); +(function(c){var p=function(n,d){var h=c.extend({slide_fx:"fadeslide",slide_easing:"ease",nav_arrows:!0,nav_dots:!0,slideshow_cmd:!0,carousel:!0,touchswipe:!0,autoplay:!1,animation_time:700,slideshow_time:5E3,pause_on_hover:!0,loader_code:''},d),l=c(n);l.data("lcms_vars",{slides:[],shown_slide:0,cached_img:[],uniqid:"",is_sliding:!1,is_playing:!1,paused_on_hover:!1});l.data("lcms_settings",h);var q=function(b,m,e){var g=b.data("lcms_vars"),d=b.data("lcms_settings"), +k=g.slides[e],f=k.img?"lcms_preload":"";d=k.img?d.loader_code:"";switch(m){case "init":var h="lcms_active_slide";break;case "fade":h="lcms_fadein";break;case "prev":h="lcms_before";break;case "next":h="lcms_after"}b.find(".lcms_nav_dots span").removeClass("lcms_sel_dot");b.find(".lcms_nav_dots span").eq(e).addClass("lcms_sel_dot");m=k.img?'
':"";var l=c.trim(k.content)?'
'+k.content+"
":"";f='
'+m+l+"
"+d+"
";b.find(".lcms_container").append(f);k.img&&(-1===c.inArray(k.img,g.cached_img)?c("").bind("load",function(){g.cached_img.push(this.src);c(".lcms_slide[rel="+e+"]").removeClass("lcms_preload");c(".lcms_slide[rel="+e+"]").find("> *").not(".lcms_inner").fadeOut(300,function(){c(this).remove()});b.trigger("lcms_slide_shown",[e,k]);c(".lcms_slide[rel="+e+"]").hasClass("lcms_active_slide")&&b.trigger("lcms_initial_slide_shown", +[e,k])}).attr("src",k.img):(c(".lcms_slide[rel="+e+"]").removeClass("lcms_preload").addClass("lcms_cached"),c(".lcms_slide[rel="+e+"]").find("> *").not(".lcms_inner").remove(),b.trigger("lcms_slide_shown",[e,k])));1").bind("load",function(){g.cached_img.push(this.src)}).attr("src",g.slides[f].img));2").bind("load", +function(){g.cached_img.push(this.src)}).attr("src",g.slides[f].img))};lcms_slide=function(b,c){var e=b.data("lcms_vars"),m=b.data("lcms_settings"),d=m.animation_time,k=e.shown_slide;if(!m.carousel&&("prev"==c&&!e.shown_slide||"next"==c&&e.shown_slide==e.slides.length-1)||e.lcms_is_sliding||1==e.slides.length||"number"==typeof c&&(0>c||c>e.slides.length-1))return!1;if("prev"==c)var f=0===k?e.slides.length-1:k-1;else"next"==c?f=k==e.slides.length-1?0:k+1:(f=c,c=f>k?"next":"prev");e.lcms_is_sliding= +!0;b.addClass("lcms_is_sliding lcms_moving_"+c);b.find(".lcms_active_slide").addClass("lcms_prepare_for_"+c);q(b,"fade"==m.slide_fx?"fade":c,f);e.shown_slide=f;b.trigger("lcms_changing_slide",[f,e.slides[f],k]);m.carousel||(b.find(".lcms_prev, .lcms_next, .lcms_play > span").removeClass("lcms_disabled_btn"),f?f==e.slides.length-1&&b.find(".lcms_next, .lcms_play > span").addClass("lcms_disabled_btn"):b.find(".lcms_prev").addClass("lcms_disabled_btn"));setTimeout(function(){b.find(".lcms_active_slide").remove(); +e.lcms_is_sliding=!1;b.removeClass("lcms_is_sliding lcms_moving_"+c);b.find(".lcms_slide").removeClass("lcms_fadein lcms_before lcms_after").addClass("lcms_active_slide");b.trigger("lcms_new_active_slide",[f,e.slides[f]])},d)};c(".lcms_prev").unbind("click");l.delegate(".lcms_play","click",function(){var b=c(this).parents(".lcms_wrap").parent();jQuery(this).hasClass("lcms_pause")?b.lcms_stop_slideshow():b.lcms_start_slideshow()});c(".lcms_prev").unbind("click");l.delegate(".lcms_prev:not(.lcms_disabled)", +"click",function(){var b=c(this).parents(".lcms_wrap").parent();"undefined"!=typeof lcms_one_click&&clearTimeout(lcms_one_click);lcms_one_click=setTimeout(function(){b.lcms_stop_slideshow();lcms_slide(b,"prev")},5)});c(".lcms_next").unbind("click");l.delegate(".lcms_next:not(.lcms_disabled)","click",function(){var b=c(this).parents(".lcms_wrap").parent();"undefined"!=typeof lcms_one_click&&clearTimeout(lcms_one_click);lcms_one_click=setTimeout(function(){b.lcms_stop_slideshow();lcms_slide(b,"next")}, +5)});c(".lcms_next").unbind("click");l.delegate(".lcms_nav_dots span:not(.lcms_sel_dot)","click",function(){var b=c(this).parents(".lcms_wrap").parent(),m=parseInt(jQuery(this).attr("rel"));"undefined"!=typeof lcms_one_click&&clearTimeout(lcms_one_click);lcms_one_click=setTimeout(function(){b.lcms_stop_slideshow();lcms_slide(b,m)},5)});var p=function(){"function"==typeof c.fn.swipe?l.find(".lcms_wrap").swipe({swipeRight:function(){var b=jQuery(this).parent();b.lcms_stop_slideshow();lcms_slide(b,"prev")}, +swipeLeft:function(){var b=jQuery(this).parent();b.lcms_stop_slideshow();lcms_slide(b,"next")},threshold:40,allowPageScroll:"vertical"}):"function"==typeof AlloyFinger&&new AlloyFinger(l.find(".lcms_wrap")[0],{swipe:function(b){var c=jQuery(this).parent();c.lcms_stop_slideshow();"Right"===b.direction?lcms_slide(c,"prev"):"Left"===b.direction&&lcms_slide(c,"next")}})};h.pause_on_hover&&l.delegate(".lcms_wrap","mouseenter",function(){var b=c(this).parent(),d=b.data("lcms_vars");b.data("lcms_settings"); d.is_playing&&(b.lcms_stop_slideshow(),d.paused_on_hover=!0)}).delegate(".lcms_wrap","mouseleave",function(){var b=c(this).parent(),d=b.data("lcms_vars");b.data("lcms_settings");d.paused_on_hover&&(b.lcms_start_slideshow(),d.paused_on_hover=!1)});(function(b){var d=b.data("lcms_vars"),e=b.data("lcms_settings");b.find("li").each(function(b,e){c(this).find("noscript").remove();var f={content:c(this).html(),img:c(this).attr("lcms_img"),classes:"undefined"==typeof c(this).attr("class")?"":c(this).attr("class")}; -d.slides.push(f)});d.uniqid="lcms_"+Math.floor(1E6*Math.random())+(new Date).getMilliseconds();b.html('
');d.shown_slide=0;q(b,"init",0);if(e.nav_arrows&&1')}e.slideshow_cmd&&1'); -if(e.nav_dots&&1';for(a=0;a';b.find(".lcms_wrap").addClass("lcms_has_nav_dots").prepend(f+"");b.find(".lcms_nav_dots span").first().addClass("lcms_sel_dot")}c("head").append('");b.find(".lcms_wrap").addClass("lcms_"+e.slide_fx+"_fx");e.autoplay&&b.lcms_start_slideshow();b.trigger("lcms_ready");c(document).ready(function(b){"function"!=typeof c.fn.swipe&&"function"!=typeof AlloyFinger||p()})})(k);return this};c.fn.lc_micro_slider=function(n){c.fn.lcms_destroy=function(){var d=c(this);d.find(".lcms_wrap").remove();var f=d.data("lcms_vars");f.is_playing&&clearInterval(f.is_playing); -d.find(".lcms_next, .lcms_prev").undelegate("click");d.removeData("lcms_vars");d.removeData("lcms_settings");d.removeData("lc_micro_slider");return!0};c.fn.lcms_paginate=function(d){var f=c(this);f.data("lcms_vars");f.data("lcms_settings");f.lcms_stop_slideshow();lcms_slide(f,d);return!0};c.fn.lcms_start_slideshow=function(){var d=c(this),f=d.data("lcms_vars"),k=d.data("lcms_settings");f.is_playing=setInterval(function(){lcms_slide(d,"next")},k.slideshow_time+k.animation_time);d.find(".lcms_play").addClass("lcms_pause"); -d.trigger("lcms_play_slideshow");return!0};c.fn.lcms_stop_slideshow=function(){var d=c(this),f=d.data("lcms_vars");d.data("lcms_settings");clearInterval(f.is_playing);f.is_playing=null;d.find(".lcms_play").removeClass("lcms_pause");d.trigger("lcms_stop_slideshow");return!0};return this.each(function(){if(c(this).data("lc_micro_slider"))return c(this).data("lc_micro_slider");var d=new p(this,n);c(this).data("lc_micro_slider",d)})}})(jQuery); \ No newline at end of file +d.slides.push(f)});d.uniqid="lcms_"+Math.floor(1E6*Math.random())+(new Date).getMilliseconds();b.html('
');d.shown_slide=0;q(b,"init",0);if(e.nav_arrows&&1')}e.slideshow_cmd&&1'); +if(e.nav_dots&&1';for(a=0;a';b.find(".lcms_wrap").addClass("lcms_has_nav_dots").prepend(g+"");b.find(".lcms_nav_dots span").first().addClass("lcms_sel_dot")}e.slide_fx&&"none"!=e.slide_fx&&(g=e.slide_easing&&"ease"!=e.slide_easing?"-webkit-animation-timing-function: "+e.slide_easing+" !important;animation-timing-function: "+e.slide_easing+" !important;":"",c("head").append('"),b.find(".lcms_wrap").addClass("lcms_"+e.slide_fx+"_fx"));e.autoplay&&b.lcms_start_slideshow();b.trigger("lcms_ready");c(document).ready(function(b){"function"!=typeof c.fn.swipe&&"function"!=typeof AlloyFinger||p()})})(l);return this};c.fn.lc_micro_slider= +function(n){c.fn.lcms_destroy=function(){var d=c(this);d.find(".lcms_wrap").remove();var h=d.data("lcms_vars");h.is_playing&&clearInterval(h.is_playing);d.find(".lcms_next, .lcms_prev").undelegate("click");d.removeData("lcms_vars");d.removeData("lcms_settings");d.removeData("lc_micro_slider");return!0};c.fn.lcms_paginate=function(d){var h=c(this);h.data("lcms_vars");h.data("lcms_settings");h.lcms_stop_slideshow();lcms_slide(h,d);return!0};c.fn.lcms_start_slideshow=function(){var d=c(this),h=d.data("lcms_vars"), +l=d.data("lcms_settings");h.is_playing=setInterval(function(){lcms_slide(d,"next")},l.slideshow_time+l.animation_time);d.find(".lcms_play").addClass("lcms_pause");d.trigger("lcms_play_slideshow");return!0};c.fn.lcms_stop_slideshow=function(){var d=c(this),h=d.data("lcms_vars");d.data("lcms_settings");clearInterval(h.is_playing);h.is_playing=null;d.find(".lcms_play").removeClass("lcms_pause");d.trigger("lcms_stop_slideshow");return!0};return this.each(function(){if(c(this).data("lc_micro_slider"))return c(this).data("lc_micro_slider"); +var d=new p(this,n);c(this).data("lc_micro_slider",d)})}})(jQuery); \ No newline at end of file