From 7e0ba165618d79ecd9e1ee439bb45f5c4c67ea68 Mon Sep 17 00:00:00 2001 From: Eric Wafford Date: Sat, 7 Feb 2015 21:41:37 -0600 Subject: [PATCH] bxSlider 4.1.2 freezes on touch devices #540 --- dist/jquery.bxslider.css | 8 ++- dist/jquery.bxslider.js | 124 +++++++++++++++++++++++++--------- dist/jquery.bxslider.min.js | 4 +- src/js/jquery.bxslider.js | 124 +++++++++++++++++++++++++--------- src/less/jquery.bxslider.less | 8 ++- 5 files changed, 200 insertions(+), 68 deletions(-) diff --git a/dist/jquery.bxslider.css b/dist/jquery.bxslider.css index a7c202ea..83fddcbd 100644 --- a/dist/jquery.bxslider.css +++ b/dist/jquery.bxslider.css @@ -1,5 +1,5 @@ /*** - * BxSlider v4.2.1 - Fully loaded, responsive content slider + * BxSlider v4.2.2 - Fully loaded, responsive content slider * http://bxslider.com * * Written by: Steven Wanderski, 2014 @@ -16,6 +16,8 @@ margin: 0 auto 60px; padding: 0; *zoom: 1; + -ms-touch-action: pan-y; + touch-action: pan-y; } .bx-wrapper img { max-width: 100%; @@ -87,6 +89,10 @@ ul.bxslider { *zoom: 1; *display: inline; } +.bx-wrapper .bx-pager-item { + font-size: 0; + line-height: 0; +} /* DIRECTION CONTROLS (NEXT / PREV) */ .bx-wrapper .bx-prev { left: 10px; diff --git a/dist/jquery.bxslider.js b/dist/jquery.bxslider.js index dafe0b0e..aa8e83d5 100644 --- a/dist/jquery.bxslider.js +++ b/dist/jquery.bxslider.js @@ -1,5 +1,5 @@ /*** - * BxSlider v4.2.1 - Fully loaded, responsive content slider + * BxSlider v4.2.2 - Fully loaded, responsive content slider * http://bxslider.com * * Copyright 2014, Steven Wanderski - http://stevenwanderski.com - http://bxcreative.com @@ -552,19 +552,21 @@ // add the CSS transition-duration el.css('-' + slider.cssPrefix + '-transition-duration', duration / 1000 + 's'); if(type === 'slide'){ - // set the property value - el.css(slider.animProp, propValue); - // if value 0, just update - if(value === 0) { - updateAfterSlideTransition(); - } else { - // bind a callback method - executes when CSS transition completes - el.bind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function(){ - // unbind the callback - el.unbind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd'); + setTimeout(function() { + // set the property value + el.css(slider.animProp, propValue); + // if value 0, just update + if(value === 0) { updateAfterSlideTransition(); - }); - } + } else { + // bind a callback method - executes when CSS transition completes + el.bind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function(){ + // unbind the callback + el.unbind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd'); + updateAfterSlideTransition(); + }); + } + }, 0); }else if(type === 'reset'){ el.css(slider.animProp, propValue); }else if(type === 'ticker'){ @@ -646,7 +648,7 @@ slider.pagerEl = $(slider.settings.pagerCustom); } // assign the pager click binding - slider.pagerEl.on('click', 'a', clickPagerBind); + slider.pagerEl.on('click touchend', 'a', clickPagerBind); }; /** @@ -656,8 +658,8 @@ slider.controls.next = $('' + slider.settings.nextText + ''); slider.controls.prev = $('' + slider.settings.prevText + ''); // bind click actions to the controls - slider.controls.next.bind('click', clickNextBind); - slider.controls.prev.bind('click', clickPrevBind); + slider.controls.next.bind('click touchend', clickNextBind); + slider.controls.prev.bind('click touchend', clickPrevBind); // if nextSelector was supplied, populate it if(slider.settings.nextSelector){ $(slider.settings.nextSelector).append(slider.controls.next); @@ -728,10 +730,13 @@ * - DOM event object */ var clickNextBind = function(e){ + e.preventDefault(); + if (slider.controls.el.hasClass('disabled')) { + return; + } // if auto show is running, stop it if(slider.settings.auto){ el.stopAuto(); } el.goToNextSlide(); - e.preventDefault(); }; /** @@ -741,10 +746,13 @@ * - DOM event object */ var clickPrevBind = function(e){ + e.preventDefault(); + if (slider.controls.el.hasClass('disabled')) { + return; + } // if auto show is running, stop it if(slider.settings.auto){ el.stopAuto(); } el.goToPrevSlide(); - e.preventDefault(); }; /** @@ -776,6 +784,10 @@ * - DOM event object */ var clickPagerBind = function(e){ + e.preventDefault(); + if (slider.controls.el.hasClass('disabled')) { + return; + } // if auto show is running, stop it if(slider.settings.auto){ el.stopAuto(); } var pagerLink = $(e.currentTarget); @@ -783,7 +795,6 @@ var pagerIndex = parseInt(pagerLink.attr('data-slide-index')); // if clicked pager link is not active, continue with the goToSlide call if(pagerIndex !== slider.active.index){ el.goToSlide(pagerIndex); } - e.preventDefault(); } }; @@ -1055,7 +1066,16 @@ start: {x: 0, y: 0}, end: {x: 0, y: 0} }; - slider.viewport.bind('touchstart', onTouchStart); + slider.viewport.bind('touchstart MSPointerDown pointerdown', onTouchStart); + + //for browsers that have implemented pointer events and fire a click after + //every pointerup regardless of whether pointerup is on same screen location as pointerdown or not + slider.viewport.on('click', '.bxslider a', function(e) { + if (slider.viewport.hasClass('click-disabled')) { + e.preventDefault(); + slider.viewport.removeClass('click-disabled'); + } + }); }; /** @@ -1065,22 +1085,54 @@ * - DOM event object */ var onTouchStart = function(e){ + //disable slider controls while user is interacting with slides to avoid slider freeze that happens on touch devices when a slide swipe happens immediately after interacting with slider controls + slider.controls.el.addClass('disabled'); + if(slider.working){ e.preventDefault(); + slider.controls.el.removeClass('disabled'); }else{ // record the original position when touch starts slider.touch.originalPos = el.position(); var orig = e.originalEvent; + var touchPoints = (typeof orig.changedTouches != 'undefined') ? orig.changedTouches : [orig]; // record the starting touch x, y coordinates - slider.touch.start.x = orig.changedTouches[0].pageX; - slider.touch.start.y = orig.changedTouches[0].pageY; + slider.touch.start.x = touchPoints[0].pageX; + slider.touch.start.y = touchPoints[0].pageY; + + if (slider.viewport.get(0).setPointerCapture) { + slider.pointerId = orig.pointerId; + slider.viewport.get(0).setPointerCapture(slider.pointerId); + } // bind a "touchmove" event to the viewport - slider.viewport.bind('touchmove', onTouchMove); + slider.viewport.bind('touchmove MSPointerMove pointermove', onTouchMove); // bind a "touchend" event to the viewport - slider.viewport.bind('touchend', onTouchEnd); + slider.viewport.bind('touchend MSPointerUp pointerup', onTouchEnd); + slider.viewport.bind('MSPointerCancel pointercancel', onPointerCancel); } }; + /** + * Cancel Pointer for Windows Phone + * + * @param e (event) + * - DOM event object + */ + var onPointerCancel = function(e) { + /* onPointerCancel handler is needed to deal with situations when a touchend + doesn't fire after a touchstart (this happens on windows phones only) */ + setPositionProperty(slider.touch.originalPos.left, 'reset', 0); + + //remove handlers + slider.controls.el.removeClass('disabled'); + slider.viewport.unbind('MSPointerCancel pointercancel', onPointerCancel); + slider.viewport.unbind('touchmove MSPointerMove pointermove', onTouchMove); + slider.viewport.unbind('touchend MSPointerUp pointerup', onTouchEnd); + if (slider.viewport.get(0).releasePointerCapture) { + slider.viewport.get(0).releasePointerCapture(slider.pointerId); + } + } + /** * Event handler for "touchmove" * @@ -1089,9 +1141,10 @@ */ var onTouchMove = function(e){ var orig = e.originalEvent; + var touchPoints = (typeof orig.changedTouches != 'undefined') ? orig.changedTouches : [orig]; // if scrolling on y axis, do not prevent default - var xMovement = Math.abs(orig.changedTouches[0].pageX - slider.touch.start.x); - var yMovement = Math.abs(orig.changedTouches[0].pageY - slider.touch.start.y); + var xMovement = Math.abs(touchPoints[0].pageX - slider.touch.start.x); + var yMovement = Math.abs(touchPoints[0].pageY - slider.touch.start.y); // x axis swipe if((xMovement * 3) > yMovement && slider.settings.preventDefaultSwipeX){ e.preventDefault(); @@ -1103,11 +1156,11 @@ var value = 0, change = 0; // if horizontal, drag along x axis if(slider.settings.mode === 'horizontal'){ - change = orig.changedTouches[0].pageX - slider.touch.start.x; + change = touchPoints[0].pageX - slider.touch.start.x; value = slider.touch.originalPos.left + change; // if vertical, drag along y axis }else{ - change = orig.changedTouches[0].pageY - slider.touch.start.y; + change = touchPoints[0].pageY - slider.touch.start.y; value = slider.touch.originalPos.top + change; } setPositionProperty(value, 'reset', 0); @@ -1121,13 +1174,16 @@ * - DOM event object */ var onTouchEnd = function(e){ - slider.viewport.unbind('touchmove', onTouchMove); + slider.viewport.unbind('touchmove MSPointerMove pointermove', onTouchMove); + //enable slider controls as soon as user stops interacing with slides + slider.controls.el.removeClass('disabled'); var orig = e.originalEvent; + var touchPoints = (typeof orig.changedTouches != 'undefined') ? orig.changedTouches : [orig]; var value = 0; var distance = 0; // record end x, y positions - slider.touch.end.x = orig.changedTouches[0].pageX; - slider.touch.end.y = orig.changedTouches[0].pageY; + slider.touch.end.x = touchPoints[0].pageX; + slider.touch.end.y = touchPoints[0].pageY; // if fade mode, check if absolute x distance clears the threshold if(slider.settings.mode === 'fade'){ distance = Math.abs(slider.touch.start.x - slider.touch.end.x); @@ -1167,7 +1223,10 @@ } } } - slider.viewport.unbind('touchend', onTouchEnd); + slider.viewport.unbind('touchend MSPointerUp pointerup', onTouchEnd); + if (slider.viewport.get(0).releasePointerCapture) { + slider.viewport.get(0).releasePointerCapture(slider.pointerId); + } }; /** @@ -1318,6 +1377,7 @@ position = slider.children.eq(requestEl).position(); } + /* If the position doesn't exist * (e.g. if you destroy the slider on a next click), * it doesn't throw an error. diff --git a/dist/jquery.bxslider.min.js b/dist/jquery.bxslider.min.js index aec7fafd..697451c7 100644 --- a/dist/jquery.bxslider.min.js +++ b/dist/jquery.bxslider.min.js @@ -1,5 +1,5 @@ /*** - * BxSlider v4.2.1 - Fully loaded, responsive content slider + * BxSlider v4.2.2 - Fully loaded, responsive content slider * http://bxslider.com * * Copyright 2014, Steven Wanderski - http://stevenwanderski.com - http://bxcreative.com @@ -7,4 +7,4 @@ * * Released under the MIT license - http://opensource.org/licenses/MIT ***/ -!function(t){var e={mode:"horizontal",slideSelector:"",infiniteLoop:!0,hideControlOnEnd:!1,speed:500,easing:null,slideMargin:0,startSlide:0,randomStart:!1,captions:!1,ticker:!1,tickerHover:!1,adaptiveHeight:!1,adaptiveHeightSpeed:500,video:!1,useCSS:!0,preloadImages:"visible",responsive:!0,slideZIndex:50,wrapperClass:"bx-wrapper",touchEnabled:!0,swipeThreshold:50,oneToOneTouch:!0,preventDefaultSwipeX:!0,preventDefaultSwipeY:!1,keyboardEnabled:!1,pager:!0,pagerType:"full",pagerShortSeparator:" / ",pagerSelector:null,buildPager:null,pagerCustom:null,controls:!0,nextText:"Next",prevText:"Prev",nextSelector:null,prevSelector:null,autoControls:!1,startText:"Start",stopText:"Stop",autoControlsCombine:!1,autoControlsSelector:null,auto:!1,pause:4e3,autoStart:!0,autoDirection:"next",autoHover:!1,autoDelay:0,autoSlideForOnePage:!1,minSlides:1,maxSlides:1,moveSlides:0,slideWidth:0,onSliderLoad:function(){return!0},onSlideBefore:function(){return!0},onSlideAfter:function(){return!0},onSlideNext:function(){return!0},onSlidePrev:function(){return!0},onSliderResize:function(){return!0}};t.fn.bxSlider=function(n){if(0===this.length)return this;if(this.length>1)return this.each(function(){t(this).bxSlider(n)}),this;var s={},o=this,r=t(window).width(),a=t(window).height(),l=function(){s.settings=t.extend({},e,n),s.settings.slideWidth=parseInt(s.settings.slideWidth),s.children=o.children(s.settings.slideSelector),s.children.length1||s.settings.maxSlides>1?!0:!1,s.carousel&&(s.settings.preloadImages="all"),s.minThreshold=s.settings.minSlides*s.settings.slideWidth+(s.settings.minSlides-1)*s.settings.slideMargin,s.maxThreshold=s.settings.maxSlides*s.settings.slideWidth+(s.settings.maxSlides-1)*s.settings.slideMargin,s.working=!1,s.controls={},s.interval=null,s.animProp="vertical"===s.settings.mode?"top":"left",s.usingCSS=s.settings.useCSS&&"fade"!==s.settings.mode&&function(){var t=document.createElement("div"),e=["WebkitPerspective","MozPerspective","OPerspective","msPerspective"];for(var i in e)if(void 0!==t.style[e[i]])return s.cssPrefix=e[i].replace("Perspective","").toLowerCase(),s.animProp="-"+s.cssPrefix+"-transform",!0;return!1}(),"vertical"===s.settings.mode&&(s.settings.maxSlides=s.settings.minSlides),o.data("origStyle",o.attr("style")),o.children(s.settings.slideSelector).each(function(){t(this).data("origStyle",t(this).attr("style"))}),d()},d=function(){o.wrap('
'),s.viewport=o.parent(),s.loader=t('
'),s.viewport.prepend(s.loader),o.css({width:"horizontal"===s.settings.mode?1e3*s.children.length+215+"%":"auto",position:"absolute"}),s.usingCSS&&s.settings.easing?o.css("-"+s.cssPrefix+"-transition-timing-function",s.settings.easing):s.settings.easing||(s.settings.easing="swing");v();s.viewport.css({width:"100%",overflow:"hidden",position:"relative"}),s.viewport.parent().css({maxWidth:p()}),s.settings.pager||s.settings.controls||s.viewport.parent().css({margin:"0 auto 0px"}),s.children.css({"float":"horizontal"===s.settings.mode?"left":"none",listStyle:"none",position:"relative"}),s.children.css("width",u()),"horizontal"===s.settings.mode&&s.settings.slideMargin>0&&s.children.css("marginRight",s.settings.slideMargin),"vertical"===s.settings.mode&&s.settings.slideMargin>0&&s.children.css("marginBottom",s.settings.slideMargin),"fade"===s.settings.mode&&(s.children.css({position:"absolute",zIndex:0,display:"none"}),s.children.eq(s.settings.startSlide).css({zIndex:s.settings.slideZIndex,display:"block"})),s.controls.el=t('
'),s.settings.captions&&E(),s.active.last=s.settings.startSlide===f()-1,s.settings.video&&o.fitVids();var e=s.children.eq(s.settings.startSlide);("all"===s.settings.preloadImages||s.settings.ticker)&&(e=s.children),s.settings.ticker?s.settings.pager=!1:(s.settings.controls&&T(),s.settings.auto&&s.settings.autoControls&&C(),s.settings.pager&&w(),(s.settings.controls||s.settings.autoControls||s.settings.pager)&&s.viewport.after(s.controls.el)),e.find('img:not([src=""]), iframe').first().one("load",function(){s.viewport.height(t(this).height()),c(e,g)})},c=function(e,i){var n=e.find('img:not([src=""]), iframe').length;if(0===n)return void i();var s=0;e.find('img:not([src=""]), iframe').each(function(){t(this).one("load error",function(){++s===n&&i()}).each(function(){this.complete&&t(this).load()})})},g=function(){if(s.settings.infiniteLoop&&"fade"!==s.settings.mode&&!s.settings.ticker){var e="vertical"===s.settings.mode?s.settings.minSlides:s.settings.maxSlides,i=s.children.slice(0,e).clone(!0).addClass("bx-clone"),n=s.children.slice(-e).clone(!0).addClass("bx-clone");o.append(i).prepend(n)}s.loader.remove(),m(),"vertical"===s.settings.mode&&(s.settings.adaptiveHeight=!0),s.viewport.height(h()),o.redrawSlider(),s.settings.onSliderLoad(s.active.index),s.initialized=!0,s.settings.responsive&&t(window).bind("resize",V),s.settings.auto&&s.settings.autoStart&&(f()>1||s.settings.autoSlideForOnePage)&&D(),s.settings.ticker&&H(),s.settings.pager&&I(s.settings.startSlide),s.settings.controls&&A(),s.settings.touchEnabled&&!s.settings.ticker&&O(),s.settings.keyboardEnabled&&!s.settings.ticker&&t(document).keydown(N)},h=function(){var e=0,n=t();if("vertical"===s.settings.mode||s.settings.adaptiveHeight)if(s.carousel){var o=1===s.settings.moveSlides?s.active.index:s.active.index*x();for(n=s.children.eq(o),i=1;i<=s.settings.maxSlides-1;i++)n=n.add(o+i>=s.children.length?s.children.eq(i-1):s.children.eq(o+i))}else n=s.children.eq(s.active.index);else n=s.children;return"vertical"===s.settings.mode?(n.each(function(){e+=t(this).outerHeight()}),s.settings.slideMargin>0&&(e+=s.settings.slideMargin*(s.settings.minSlides-1))):e=Math.max.apply(Math,n.map(function(){return t(this).outerHeight(!1)}).get()),"border-box"===s.viewport.css("box-sizing")?e+=parseFloat(s.viewport.css("padding-top"))+parseFloat(s.viewport.css("padding-bottom"))+parseFloat(s.viewport.css("border-top-width"))+parseFloat(s.viewport.css("border-bottom-width")):"padding-box"===s.viewport.css("box-sizing")&&(e+=parseFloat(s.viewport.css("padding-top"))+parseFloat(s.viewport.css("padding-bottom"))),e},p=function(){var t="100%";return s.settings.slideWidth>0&&(t="horizontal"===s.settings.mode?s.settings.maxSlides*s.settings.slideWidth+(s.settings.maxSlides-1)*s.settings.slideMargin:s.settings.slideWidth),t},u=function(){var t=s.settings.slideWidth,e=s.viewport.width();return 0===s.settings.slideWidth||s.settings.slideWidth>e&&!s.carousel||"vertical"===s.settings.mode?t=e:s.settings.maxSlides>1&&"horizontal"===s.settings.mode&&(e>s.maxThreshold||e0)if(s.viewport.width()s.maxThreshold)t=s.settings.maxSlides;else{var e=s.children.first().width()+s.settings.slideMargin;t=Math.floor((s.viewport.width()+s.settings.slideMargin)/e)}else"vertical"===s.settings.mode&&(t=s.settings.minSlides);return t},f=function(){var t=0;if(s.settings.moveSlides>0)if(s.settings.infiniteLoop)t=Math.ceil(s.children.length/x());else for(var e=0,i=0;e0&&s.settings.moveSlides<=v()?s.settings.moveSlides:v()},m=function(){var t;if(s.children.length>s.settings.maxSlides&&s.active.last&&!s.settings.infiniteLoop){if("horizontal"===s.settings.mode){var e=s.children.last();t=e.position(),S(-(t.left-(s.viewport.width()-e.outerWidth())),"reset",0)}else if("vertical"===s.settings.mode){var i=s.children.length-s.settings.minSlides;t=s.children.eq(i).position(),S(-t.top,"reset",0)}}else t=s.children.eq(s.active.index*x()).position(),s.active.index===f()-1&&(s.active.last=!0),void 0!==t&&("horizontal"===s.settings.mode?S(-t.left,"reset",0):"vertical"===s.settings.mode&&S(-t.top,"reset",0))},S=function(t,e,i,n){if(s.usingCSS){var r="vertical"===s.settings.mode?"translate3d(0, "+t+"px, 0)":"translate3d("+t+"px, 0, 0)";o.css("-"+s.cssPrefix+"-transition-duration",i/1e3+"s"),"slide"===e?(o.css(s.animProp,r),0===t?q():o.bind("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd",function(){o.unbind("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd"),q()})):"reset"===e?o.css(s.animProp,r):"ticker"===e&&(o.css("-"+s.cssPrefix+"-transition-timing-function","linear"),o.css(s.animProp,r),o.bind("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd",function(){o.unbind("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd"),S(n.resetValue,"reset",0),L()}))}else{var a={};a[s.animProp]=t,"slide"===e?o.animate(a,i,s.settings.easing,function(){q()}):"reset"===e?o.css(s.animProp,t):"ticker"===e&&o.animate(a,speed,"linear",function(){S(n.resetValue,"reset",0),L()})}},b=function(){for(var e="",i=f(),n=0;i>n;n++){var o="";s.settings.buildPager&&t.isFunction(s.settings.buildPager)||s.settings.pagerCustom?(o=s.settings.buildPager(n),s.pagerEl.addClass("bx-custom-pager")):(o=n+1,s.pagerEl.addClass("bx-default-pager")),e+='"}s.pagerEl.html(e)},w=function(){s.settings.pagerCustom?s.pagerEl=t(s.settings.pagerCustom):(s.pagerEl=t('
'),s.settings.pagerSelector?t(s.settings.pagerSelector).html(s.pagerEl):s.controls.el.addClass("bx-has-pager").append(s.pagerEl),b()),s.pagerEl.on("click","a",M)},T=function(){s.controls.next=t(''+s.settings.nextText+""),s.controls.prev=t(''+s.settings.prevText+""),s.controls.next.bind("click",y),s.controls.prev.bind("click",k),s.settings.nextSelector&&t(s.settings.nextSelector).append(s.controls.next),s.settings.prevSelector&&t(s.settings.prevSelector).append(s.controls.prev),s.settings.nextSelector||s.settings.prevSelector||(s.controls.directionEl=t('
'),s.controls.directionEl.append(s.controls.prev).append(s.controls.next),s.controls.el.addClass("bx-has-controls-direction").append(s.controls.directionEl))},C=function(){s.controls.start=t('"),s.controls.stop=t('"),s.controls.autoEl=t('
'),s.controls.autoEl.on("click",".bx-start",P),s.controls.autoEl.on("click",".bx-stop",z),s.settings.autoControlsCombine?s.controls.autoEl.append(s.controls.start):s.controls.autoEl.append(s.controls.start).append(s.controls.stop),s.settings.autoControlsSelector?t(s.settings.autoControlsSelector).html(s.controls.autoEl):s.controls.el.addClass("bx-has-controls-auto").append(s.controls.autoEl),W(s.settings.autoStart?"stop":"start")},E=function(){s.children.each(function(){var e=t(this).find("img:first").attr("title");void 0!==e&&(""+e).length&&t(this).append('
'+e+"
")})},y=function(t){s.settings.auto&&o.stopAuto(),o.goToNextSlide(),t.preventDefault()},k=function(t){s.settings.auto&&o.stopAuto(),o.goToPrevSlide(),t.preventDefault()},P=function(t){o.startAuto(),t.preventDefault()},z=function(t){o.stopAuto(),t.preventDefault()},M=function(e){s.settings.auto&&o.stopAuto();var i=t(e.currentTarget);if(void 0!==i.attr("data-slide-index")){var n=parseInt(i.attr("data-slide-index"));n!==s.active.index&&o.goToSlide(n),e.preventDefault()}},I=function(e){var i=s.children.length;return"short"===s.settings.pagerType?(s.settings.maxSlides>1&&(i=Math.ceil(s.children.length/s.settings.maxSlides)),void s.pagerEl.html(e+1+s.settings.pagerShortSeparator+i)):(s.pagerEl.find("a").removeClass("active"),void s.pagerEl.each(function(i,n){t(n).find("a").eq(e).addClass("active")}))},q=function(){if(s.settings.infiniteLoop){var t="";0===s.active.index?t=s.children.eq(0).position():s.active.index===f()-1&&s.carousel?t=s.children.eq((f()-1)*x()).position():s.active.index===s.children.length-1&&(t=s.children.eq(s.children.length-1).position()),t&&("horizontal"===s.settings.mode?S(-t.left,"reset",0):"vertical"===s.settings.mode&&S(-t.top,"reset",0))}s.working=!1,s.settings.onSlideAfter(s.children.eq(s.active.index),s.oldIndex,s.active.index)},W=function(t){s.settings.autoControlsCombine?s.controls.autoEl.html(s.controls[t]):(s.controls.autoEl.find("a").removeClass("active"),s.controls.autoEl.find("a:not(.bx-"+t+")").addClass("active"))},A=function(){1===f()?(s.controls.prev.addClass("disabled"),s.controls.next.addClass("disabled")):!s.settings.infiniteLoop&&s.settings.hideControlOnEnd&&(0===s.active.index?(s.controls.prev.addClass("disabled"),s.controls.next.removeClass("disabled")):s.active.index===f()-1?(s.controls.next.addClass("disabled"),s.controls.prev.removeClass("disabled")):(s.controls.prev.removeClass("disabled"),s.controls.next.removeClass("disabled")))},D=function(){if(s.settings.autoDelay>0){setTimeout(o.startAuto,s.settings.autoDelay)}else o.startAuto(),t(window).focus(function(){o.startAuto()}).blur(function(){o.stopAuto()});s.settings.autoHover&&o.hover(function(){s.interval&&(o.stopAuto(!0),s.autoPaused=!0)},function(){s.autoPaused&&(o.startAuto(!0),s.autoPaused=null)})},H=function(){var e=0;if("next"===s.settings.autoDirection)o.append(s.children.clone().addClass("bx-clone"));else{o.prepend(s.children.clone().addClass("bx-clone"));var i=s.children.first().position();e="horizontal"===s.settings.mode?-i.left:-i.top}if(S(e,"reset",0),s.settings.pager=!1,s.settings.controls=!1,s.settings.autoControls=!1,s.settings.tickerHover)if(s.usingCSS){var n,r="horizontal"==s.settings.mode?4:5;s.viewport.hover(function(){var t=o.css("-"+s.cssPrefix+"-transform");n=parseFloat(t.split(",")[r]),S(n,"reset",0)},function(){var e=0;s.children.each(function(){e+="horizontal"==s.settings.mode?t(this).outerWidth(!0):t(this).outerHeight(!0)});var i=s.settings.speed/e,o=("horizontal"==s.settings.mode?"left":"top",i*(e-Math.abs(parseInt(n))));L(o)})}else s.viewport.hover(function(){o.stop()},function(){var e=0;s.children.each(function(){e+="horizontal"==s.settings.mode?t(this).outerWidth(!0):t(this).outerHeight(!0)});var i=s.settings.speed/e,n="horizontal"==s.settings.mode?"left":"top",r=i*(e-Math.abs(parseInt(o.css(n))));L(r)});L()},L=function(t){speed=t?t:s.settings.speed;var e={left:0,top:0},i={left:0,top:0};"next"===s.settings.autoDirection?e=o.find(".bx-clone").first().position():i=s.children.first().position();var n="horizontal"===s.settings.mode?-e.left:-e.top,r="horizontal"===s.settings.mode?-i.left:-i.top,a={resetValue:r};S(n,"ticker",speed,a)},F=function(e){var i=t(window),n={top:i.scrollTop(),left:i.scrollLeft()};n.right=n.left+i.width(),n.bottom=n.top+i.height();var s=e.offset();return s.right=s.left+e.outerWidth(),s.bottom=s.top+e.outerHeight(),!(n.rights.right||n.bottoms.bottom)},N=function(t){var e=document.activeElement.tagName.toLowerCase(),i="input|textarea",n=new RegExp(e,["i"]),s=n.exec(i);if(null==s&&F(o)){if(39==t.keyCode)return y(t),!1;if(37==t.keyCode)return k(t),!1}},O=function(){s.touch={start:{x:0,y:0},end:{x:0,y:0}},s.viewport.bind("touchstart",X)},X=function(t){if(s.working)t.preventDefault();else{s.touch.originalPos=o.position();var e=t.originalEvent;s.touch.start.x=e.changedTouches[0].pageX,s.touch.start.y=e.changedTouches[0].pageY,s.viewport.bind("touchmove",Y),s.viewport.bind("touchend",R)}},Y=function(t){var e=t.originalEvent,i=Math.abs(e.changedTouches[0].pageX-s.touch.start.x),n=Math.abs(e.changedTouches[0].pageY-s.touch.start.y);if(3*i>n&&s.settings.preventDefaultSwipeX?t.preventDefault():3*n>i&&s.settings.preventDefaultSwipeY&&t.preventDefault(),"fade"!==s.settings.mode&&s.settings.oneToOneTouch){var o=0,r=0;"horizontal"===s.settings.mode?(r=e.changedTouches[0].pageX-s.touch.start.x,o=s.touch.originalPos.left+r):(r=e.changedTouches[0].pageY-s.touch.start.y,o=s.touch.originalPos.top+r),S(o,"reset",0)}},R=function(t){s.viewport.unbind("touchmove",Y);var e=t.originalEvent,i=0,n=0;s.touch.end.x=e.changedTouches[0].pageX,s.touch.end.y=e.changedTouches[0].pageY,"fade"===s.settings.mode?(n=Math.abs(s.touch.start.x-s.touch.end.x),n>=s.settings.swipeThreshold&&(s.touch.start.x>s.touch.end.x?o.goToNextSlide():o.goToPrevSlide(),o.stopAuto())):("horizontal"===s.settings.mode?(n=s.touch.end.x-s.touch.start.x,i=s.touch.originalPos.left):(n=s.touch.end.y-s.touch.start.y,i=s.touch.originalPos.top),!s.settings.infiniteLoop&&(0===s.active.index&&n>0||s.active.last&&0>n)?S(i,"reset",200):Math.abs(n)>=s.settings.swipeThreshold?(0>n?o.goToNextSlide():o.goToPrevSlide(),o.stopAuto()):S(i,"reset",200)),s.viewport.unbind("touchend",R)},V=function(){if(s.initialized)if(s.working)window.setTimeout(V,10);else{var e=t(window).width(),i=t(window).height();(r!==e||a!==i)&&(r=e,a=i,o.redrawSlider(),s.settings.onSliderResize.call(o,s.active.index))}};return o.goToSlide=function(e,i){if(!s.working&&s.active.index!==e){s.working=!0,s.oldIndex=s.active.index,s.active.index=0>e?f()-1:e>=f()?0:e;var n=!0;if(n=s.settings.onSlideBefore(s.children.eq(s.active.index),s.oldIndex,s.active.index),"undefined"!=typeof n&&!n)return s.active.index=s.oldIndex,void(s.working=!1);if("next"===i?s.settings.onSlideNext(s.children.eq(s.active.index),s.oldIndex,s.active.index)||(n=!1):"prev"===i&&(s.settings.onSlidePrev(s.children.eq(s.active.index),s.oldIndex,s.active.index)||(n=!1)),"undefined"!=typeof n&&!n)return s.active.index=s.oldIndex,void(s.working=!1);if(s.active.last=s.active.index>=f()-1,(s.settings.pager||s.settings.pagerCustom)&&I(s.active.index),s.settings.controls&&A(),"fade"===s.settings.mode)s.settings.adaptiveHeight&&s.viewport.height()!==h()&&s.viewport.animate({height:h()},s.settings.adaptiveHeightSpeed),s.children.filter(":visible").fadeOut(s.settings.speed).css({zIndex:0}),s.children.eq(s.active.index).css("zIndex",s.settings.slideZIndex+1).fadeIn(s.settings.speed,function(){t(this).css("zIndex",s.settings.slideZIndex),q()});else{s.settings.adaptiveHeight&&s.viewport.height()!==h()&&s.viewport.animate({height:h()},s.settings.adaptiveHeightSpeed);var r=0,a={left:0,top:0},l=null;if(!s.settings.infiniteLoop&&s.carousel&&s.active.last)if("horizontal"===s.settings.mode)l=s.children.eq(s.children.length-1),a=l.position(),r=s.viewport.width()-l.outerWidth();else{var d=s.children.length-s.settings.minSlides;a=s.children.eq(d).position()}else if(s.carousel&&s.active.last&&"prev"===i){var c=1===s.settings.moveSlides?s.settings.maxSlides-x():(f()-1)*x()-(s.children.length-s.settings.maxSlides);l=o.children(".bx-clone").eq(c),a=l.position()}else if("next"===i&&0===s.active.index)a=o.find("> .bx-clone").eq(s.settings.maxSlides).position(),s.active.last=!1;else if(e>=0){var g=e*x();a=s.children.eq(g).position()}if("undefined"!=typeof a){var p="horizontal"===s.settings.mode?-(a.left-r):-a.top;S(p,"slide",s.settings.speed)}}}},o.goToNextSlide=function(){if(s.settings.infiniteLoop||!s.active.last){var t=parseInt(s.active.index)+1;o.goToSlide(t,"next")}},o.goToPrevSlide=function(){if(s.settings.infiniteLoop||0!==s.active.index){var t=parseInt(s.active.index)-1;o.goToSlide(t,"prev")}},o.startAuto=function(t){s.interval||(s.interval=setInterval(function(){"next"===s.settings.autoDirection?o.goToNextSlide():o.goToPrevSlide()},s.settings.pause),s.settings.autoControls&&t!==!0&&W("stop"))},o.stopAuto=function(t){s.interval&&(clearInterval(s.interval),s.interval=null,s.settings.autoControls&&t!==!0&&W("start"))},o.getCurrentSlide=function(){return s.active.index},o.getCurrentSlideElement=function(){return s.children.eq(s.active.index)},o.getSlideCount=function(){return s.children.length},o.isWorking=function(){return s.working},o.redrawSlider=function(){s.children.add(o.find(".bx-clone")).outerWidth(u()),s.viewport.css("height",h()),s.settings.ticker||m(),s.active.last&&(s.active.index=f()-1),s.active.index>=f()&&(s.active.last=!0),s.settings.pager&&!s.settings.pagerCustom&&(b(),I(s.active.index))},o.destroySlider=function(){s.initialized&&(s.initialized=!1,t(".bx-clone",this).remove(),s.children.each(function(){void 0!==t(this).data("origStyle")?t(this).attr("style",t(this).data("origStyle")):t(this).removeAttr("style")}),void 0!==t(this).data("origStyle")?this.attr("style",t(this).data("origStyle")):t(this).removeAttr("style"),t(this).unwrap().unwrap(),s.controls.el&&s.controls.el.remove(),s.controls.next&&s.controls.next.remove(),s.controls.prev&&s.controls.prev.remove(),s.pagerEl&&s.settings.controls&&!s.settings.pagerCustom&&s.pagerEl.remove(),t(".bx-caption",this).remove(),s.controls.autoEl&&s.controls.autoEl.remove(),clearInterval(s.interval),s.settings.responsive&&t(window).unbind("resize",V),s.settings.keyboardEnabled&&t(document).unbind("keydown",N))},o.reloadSlider=function(t){void 0!==t&&(n=t),o.destroySlider(),l()},l(),this}}(jQuery); \ No newline at end of file +!function(e){var t={mode:"horizontal",slideSelector:"",infiniteLoop:!0,hideControlOnEnd:!1,speed:500,easing:null,slideMargin:0,startSlide:0,randomStart:!1,captions:!1,ticker:!1,tickerHover:!1,adaptiveHeight:!1,adaptiveHeightSpeed:500,video:!1,useCSS:!0,preloadImages:"visible",responsive:!0,slideZIndex:50,wrapperClass:"bx-wrapper",touchEnabled:!0,swipeThreshold:50,oneToOneTouch:!0,preventDefaultSwipeX:!0,preventDefaultSwipeY:!1,keyboardEnabled:!1,pager:!0,pagerType:"full",pagerShortSeparator:" / ",pagerSelector:null,buildPager:null,pagerCustom:null,controls:!0,nextText:"Next",prevText:"Prev",nextSelector:null,prevSelector:null,autoControls:!1,startText:"Start",stopText:"Stop",autoControlsCombine:!1,autoControlsSelector:null,auto:!1,pause:4e3,autoStart:!0,autoDirection:"next",autoHover:!1,autoDelay:0,autoSlideForOnePage:!1,minSlides:1,maxSlides:1,moveSlides:0,slideWidth:0,onSliderLoad:function(){return!0},onSlideBefore:function(){return!0},onSlideAfter:function(){return!0},onSlideNext:function(){return!0},onSlidePrev:function(){return!0},onSliderResize:function(){return!0}};e.fn.bxSlider=function(n){if(0===this.length)return this;if(this.length>1)return this.each(function(){e(this).bxSlider(n)}),this;var s={},o=this,r=e(window).width(),a=e(window).height(),l=function(){s.settings=e.extend({},t,n),s.settings.slideWidth=parseInt(s.settings.slideWidth),s.children=o.children(s.settings.slideSelector),s.children.length1||s.settings.maxSlides>1?!0:!1,s.carousel&&(s.settings.preloadImages="all"),s.minThreshold=s.settings.minSlides*s.settings.slideWidth+(s.settings.minSlides-1)*s.settings.slideMargin,s.maxThreshold=s.settings.maxSlides*s.settings.slideWidth+(s.settings.maxSlides-1)*s.settings.slideMargin,s.working=!1,s.controls={},s.interval=null,s.animProp="vertical"===s.settings.mode?"top":"left",s.usingCSS=s.settings.useCSS&&"fade"!==s.settings.mode&&function(){var e=document.createElement("div"),t=["WebkitPerspective","MozPerspective","OPerspective","msPerspective"];for(var i in t)if(void 0!==e.style[t[i]])return s.cssPrefix=t[i].replace("Perspective","").toLowerCase(),s.animProp="-"+s.cssPrefix+"-transform",!0;return!1}(),"vertical"===s.settings.mode&&(s.settings.maxSlides=s.settings.minSlides),o.data("origStyle",o.attr("style")),o.children(s.settings.slideSelector).each(function(){e(this).data("origStyle",e(this).attr("style"))}),d()},d=function(){o.wrap('
'),s.viewport=o.parent(),s.loader=e('
'),s.viewport.prepend(s.loader),o.css({width:"horizontal"===s.settings.mode?1e3*s.children.length+215+"%":"auto",position:"absolute"}),s.usingCSS&&s.settings.easing?o.css("-"+s.cssPrefix+"-transition-timing-function",s.settings.easing):s.settings.easing||(s.settings.easing="swing");v();s.viewport.css({width:"100%",overflow:"hidden",position:"relative"}),s.viewport.parent().css({maxWidth:u()}),s.settings.pager||s.settings.controls||s.viewport.parent().css({margin:"0 auto 0px"}),s.children.css({"float":"horizontal"===s.settings.mode?"left":"none",listStyle:"none",position:"relative"}),s.children.css("width",h()),"horizontal"===s.settings.mode&&s.settings.slideMargin>0&&s.children.css("marginRight",s.settings.slideMargin),"vertical"===s.settings.mode&&s.settings.slideMargin>0&&s.children.css("marginBottom",s.settings.slideMargin),"fade"===s.settings.mode&&(s.children.css({position:"absolute",zIndex:0,display:"none"}),s.children.eq(s.settings.startSlide).css({zIndex:s.settings.slideZIndex,display:"block"})),s.controls.el=e('
'),s.settings.captions&&P(),s.active.last=s.settings.startSlide===f()-1,s.settings.video&&o.fitVids();var t=s.children.eq(s.settings.startSlide);("all"===s.settings.preloadImages||s.settings.ticker)&&(t=s.children),s.settings.ticker?s.settings.pager=!1:(s.settings.controls&&C(),s.settings.auto&&s.settings.autoControls&&T(),s.settings.pager&&b(),(s.settings.controls||s.settings.autoControls||s.settings.pager)&&s.viewport.after(s.controls.el)),t.find('img:not([src=""]), iframe').first().one("load",function(){s.viewport.height(e(this).height()),c(t,g)})},c=function(t,i){var n=t.find('img:not([src=""]), iframe').length;if(0===n)return void i();var s=0;t.find('img:not([src=""]), iframe').each(function(){e(this).one("load error",function(){++s===n&&i()}).each(function(){this.complete&&e(this).load()})})},g=function(){if(s.settings.infiniteLoop&&"fade"!==s.settings.mode&&!s.settings.ticker){var t="vertical"===s.settings.mode?s.settings.minSlides:s.settings.maxSlides,i=s.children.slice(0,t).clone(!0).addClass("bx-clone"),n=s.children.slice(-t).clone(!0).addClass("bx-clone");o.append(i).prepend(n)}s.loader.remove(),x(),"vertical"===s.settings.mode&&(s.settings.adaptiveHeight=!0),s.viewport.height(p()),o.redrawSlider(),s.settings.onSliderLoad(s.active.index),s.initialized=!0,s.settings.responsive&&e(window).bind("resize",Z),s.settings.auto&&s.settings.autoStart&&(f()>1||s.settings.autoSlideForOnePage)&&A(),s.settings.ticker&&H(),s.settings.pager&&I(s.settings.startSlide),s.settings.controls&&W(),s.settings.touchEnabled&&!s.settings.ticker&&O(),s.settings.keyboardEnabled&&!s.settings.ticker&&e(document).keydown(N)},p=function(){var t=0,n=e();if("vertical"===s.settings.mode||s.settings.adaptiveHeight)if(s.carousel){var o=1===s.settings.moveSlides?s.active.index:s.active.index*m();for(n=s.children.eq(o),i=1;i<=s.settings.maxSlides-1;i++)n=n.add(o+i>=s.children.length?s.children.eq(i-1):s.children.eq(o+i))}else n=s.children.eq(s.active.index);else n=s.children;return"vertical"===s.settings.mode?(n.each(function(){t+=e(this).outerHeight()}),s.settings.slideMargin>0&&(t+=s.settings.slideMargin*(s.settings.minSlides-1))):t=Math.max.apply(Math,n.map(function(){return e(this).outerHeight(!1)}).get()),"border-box"===s.viewport.css("box-sizing")?t+=parseFloat(s.viewport.css("padding-top"))+parseFloat(s.viewport.css("padding-bottom"))+parseFloat(s.viewport.css("border-top-width"))+parseFloat(s.viewport.css("border-bottom-width")):"padding-box"===s.viewport.css("box-sizing")&&(t+=parseFloat(s.viewport.css("padding-top"))+parseFloat(s.viewport.css("padding-bottom"))),t},u=function(){var e="100%";return s.settings.slideWidth>0&&(e="horizontal"===s.settings.mode?s.settings.maxSlides*s.settings.slideWidth+(s.settings.maxSlides-1)*s.settings.slideMargin:s.settings.slideWidth),e},h=function(){var e=s.settings.slideWidth,t=s.viewport.width();return 0===s.settings.slideWidth||s.settings.slideWidth>t&&!s.carousel||"vertical"===s.settings.mode?e=t:s.settings.maxSlides>1&&"horizontal"===s.settings.mode&&(t>s.maxThreshold||t0)if(s.viewport.width()s.maxThreshold)e=s.settings.maxSlides;else{var t=s.children.first().width()+s.settings.slideMargin;e=Math.floor((s.viewport.width()+s.settings.slideMargin)/t)}else"vertical"===s.settings.mode&&(e=s.settings.minSlides);return e},f=function(){var e=0;if(s.settings.moveSlides>0)if(s.settings.infiniteLoop)e=Math.ceil(s.children.length/m());else for(var t=0,i=0;t0&&s.settings.moveSlides<=v()?s.settings.moveSlides:v()},x=function(){var e;if(s.children.length>s.settings.maxSlides&&s.active.last&&!s.settings.infiniteLoop){if("horizontal"===s.settings.mode){var t=s.children.last();e=t.position(),S(-(e.left-(s.viewport.width()-t.outerWidth())),"reset",0)}else if("vertical"===s.settings.mode){var i=s.children.length-s.settings.minSlides;e=s.children.eq(i).position(),S(-e.top,"reset",0)}}else e=s.children.eq(s.active.index*m()).position(),s.active.index===f()-1&&(s.active.last=!0),void 0!==e&&("horizontal"===s.settings.mode?S(-e.left,"reset",0):"vertical"===s.settings.mode&&S(-e.top,"reset",0))},S=function(e,t,i,n){if(s.usingCSS){var r="vertical"===s.settings.mode?"translate3d(0, "+e+"px, 0)":"translate3d("+e+"px, 0, 0)";o.css("-"+s.cssPrefix+"-transition-duration",i/1e3+"s"),"slide"===t?setTimeout(function(){o.css(s.animProp,r),0===e?q():o.bind("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd",function(){o.unbind("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd"),q()})},0):"reset"===t?o.css(s.animProp,r):"ticker"===t&&(o.css("-"+s.cssPrefix+"-transition-timing-function","linear"),o.css(s.animProp,r),o.bind("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd",function(){o.unbind("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd"),S(n.resetValue,"reset",0),L()}))}else{var a={};a[s.animProp]=e,"slide"===t?o.animate(a,i,s.settings.easing,function(){q()}):"reset"===t?o.css(s.animProp,e):"ticker"===t&&o.animate(a,speed,"linear",function(){S(n.resetValue,"reset",0),L()})}},w=function(){for(var t="",i=f(),n=0;i>n;n++){var o="";s.settings.buildPager&&e.isFunction(s.settings.buildPager)||s.settings.pagerCustom?(o=s.settings.buildPager(n),s.pagerEl.addClass("bx-custom-pager")):(o=n+1,s.pagerEl.addClass("bx-default-pager")),t+='"}s.pagerEl.html(t)},b=function(){s.settings.pagerCustom?s.pagerEl=e(s.settings.pagerCustom):(s.pagerEl=e('
'),s.settings.pagerSelector?e(s.settings.pagerSelector).html(s.pagerEl):s.controls.el.addClass("bx-has-pager").append(s.pagerEl),w()),s.pagerEl.on("click touchend","a",z)},C=function(){s.controls.next=e(''+s.settings.nextText+""),s.controls.prev=e(''+s.settings.prevText+""),s.controls.next.bind("click touchend",E),s.controls.prev.bind("click touchend",y),s.settings.nextSelector&&e(s.settings.nextSelector).append(s.controls.next),s.settings.prevSelector&&e(s.settings.prevSelector).append(s.controls.prev),s.settings.nextSelector||s.settings.prevSelector||(s.controls.directionEl=e('
'),s.controls.directionEl.append(s.controls.prev).append(s.controls.next),s.controls.el.addClass("bx-has-controls-direction").append(s.controls.directionEl))},T=function(){s.controls.start=e('"),s.controls.stop=e('"),s.controls.autoEl=e('
'),s.controls.autoEl.on("click",".bx-start",k),s.controls.autoEl.on("click",".bx-stop",M),s.settings.autoControlsCombine?s.controls.autoEl.append(s.controls.start):s.controls.autoEl.append(s.controls.start).append(s.controls.stop),s.settings.autoControlsSelector?e(s.settings.autoControlsSelector).html(s.controls.autoEl):s.controls.el.addClass("bx-has-controls-auto").append(s.controls.autoEl),D(s.settings.autoStart?"stop":"start")},P=function(){s.children.each(function(){var t=e(this).find("img:first").attr("title");void 0!==t&&(""+t).length&&e(this).append('
'+t+"
")})},E=function(e){e.preventDefault(),s.controls.el.hasClass("disabled")||(s.settings.auto&&o.stopAuto(),o.goToNextSlide())},y=function(e){e.preventDefault(),s.controls.el.hasClass("disabled")||(s.settings.auto&&o.stopAuto(),o.goToPrevSlide())},k=function(e){o.startAuto(),e.preventDefault()},M=function(e){o.stopAuto(),e.preventDefault()},z=function(t){if(t.preventDefault(),!s.controls.el.hasClass("disabled")){s.settings.auto&&o.stopAuto();var i=e(t.currentTarget);if(void 0!==i.attr("data-slide-index")){var n=parseInt(i.attr("data-slide-index"));n!==s.active.index&&o.goToSlide(n)}}},I=function(t){var i=s.children.length;return"short"===s.settings.pagerType?(s.settings.maxSlides>1&&(i=Math.ceil(s.children.length/s.settings.maxSlides)),void s.pagerEl.html(t+1+s.settings.pagerShortSeparator+i)):(s.pagerEl.find("a").removeClass("active"),void s.pagerEl.each(function(i,n){e(n).find("a").eq(t).addClass("active")}))},q=function(){if(s.settings.infiniteLoop){var e="";0===s.active.index?e=s.children.eq(0).position():s.active.index===f()-1&&s.carousel?e=s.children.eq((f()-1)*m()).position():s.active.index===s.children.length-1&&(e=s.children.eq(s.children.length-1).position()),e&&("horizontal"===s.settings.mode?S(-e.left,"reset",0):"vertical"===s.settings.mode&&S(-e.top,"reset",0))}s.working=!1,s.settings.onSlideAfter(s.children.eq(s.active.index),s.oldIndex,s.active.index)},D=function(e){s.settings.autoControlsCombine?s.controls.autoEl.html(s.controls[e]):(s.controls.autoEl.find("a").removeClass("active"),s.controls.autoEl.find("a:not(.bx-"+e+")").addClass("active"))},W=function(){1===f()?(s.controls.prev.addClass("disabled"),s.controls.next.addClass("disabled")):!s.settings.infiniteLoop&&s.settings.hideControlOnEnd&&(0===s.active.index?(s.controls.prev.addClass("disabled"),s.controls.next.removeClass("disabled")):s.active.index===f()-1?(s.controls.next.addClass("disabled"),s.controls.prev.removeClass("disabled")):(s.controls.prev.removeClass("disabled"),s.controls.next.removeClass("disabled")))},A=function(){if(s.settings.autoDelay>0){setTimeout(o.startAuto,s.settings.autoDelay)}else o.startAuto(),e(window).focus(function(){o.startAuto()}).blur(function(){o.stopAuto()});s.settings.autoHover&&o.hover(function(){s.interval&&(o.stopAuto(!0),s.autoPaused=!0)},function(){s.autoPaused&&(o.startAuto(!0),s.autoPaused=null)})},H=function(){var t=0;if("next"===s.settings.autoDirection)o.append(s.children.clone().addClass("bx-clone"));else{o.prepend(s.children.clone().addClass("bx-clone"));var i=s.children.first().position();t="horizontal"===s.settings.mode?-i.left:-i.top}if(S(t,"reset",0),s.settings.pager=!1,s.settings.controls=!1,s.settings.autoControls=!1,s.settings.tickerHover)if(s.usingCSS){var n,r="horizontal"==s.settings.mode?4:5;s.viewport.hover(function(){var e=o.css("-"+s.cssPrefix+"-transform");n=parseFloat(e.split(",")[r]),S(n,"reset",0)},function(){var t=0;s.children.each(function(){t+="horizontal"==s.settings.mode?e(this).outerWidth(!0):e(this).outerHeight(!0)});var i=s.settings.speed/t,o=("horizontal"==s.settings.mode?"left":"top",i*(t-Math.abs(parseInt(n))));L(o)})}else s.viewport.hover(function(){o.stop()},function(){var t=0;s.children.each(function(){t+="horizontal"==s.settings.mode?e(this).outerWidth(!0):e(this).outerHeight(!0)});var i=s.settings.speed/t,n="horizontal"==s.settings.mode?"left":"top",r=i*(t-Math.abs(parseInt(o.css(n))));L(r)});L()},L=function(e){speed=e?e:s.settings.speed;var t={left:0,top:0},i={left:0,top:0};"next"===s.settings.autoDirection?t=o.find(".bx-clone").first().position():i=s.children.first().position();var n="horizontal"===s.settings.mode?-t.left:-t.top,r="horizontal"===s.settings.mode?-i.left:-i.top,a={resetValue:r};S(n,"ticker",speed,a)},F=function(t){var i=e(window),n={top:i.scrollTop(),left:i.scrollLeft()};n.right=n.left+i.width(),n.bottom=n.top+i.height();var s=t.offset();return s.right=s.left+t.outerWidth(),s.bottom=s.top+t.outerHeight(),!(n.rights.right||n.bottoms.bottom)},N=function(e){var t=document.activeElement.tagName.toLowerCase(),i="input|textarea",n=new RegExp(t,["i"]),s=n.exec(i);if(null==s&&F(o)){if(39==e.keyCode)return E(e),!1;if(37==e.keyCode)return y(e),!1}},O=function(){s.touch={start:{x:0,y:0},end:{x:0,y:0}},s.viewport.bind("touchstart MSPointerDown pointerdown",X),s.viewport.on("click",".bxslider a",function(e){s.viewport.hasClass("click-disabled")&&(e.preventDefault(),s.viewport.removeClass("click-disabled"))})},X=function(e){if(s.controls.el.addClass("disabled"),s.working)e.preventDefault(),s.controls.el.removeClass("disabled");else{s.touch.originalPos=o.position();var t=e.originalEvent,i="undefined"!=typeof t.changedTouches?t.changedTouches:[t];s.touch.start.x=i[0].pageX,s.touch.start.y=i[0].pageY,s.viewport.get(0).setPointerCapture&&(s.pointerId=t.pointerId,s.viewport.get(0).setPointerCapture(s.pointerId)),s.viewport.bind("touchmove MSPointerMove pointermove",R),s.viewport.bind("touchend MSPointerUp pointerup",V),s.viewport.bind("MSPointerCancel pointercancel",Y)}},Y=function(){S(s.touch.originalPos.left,"reset",0),s.controls.el.removeClass("disabled"),s.viewport.unbind("MSPointerCancel pointercancel",Y),s.viewport.unbind("touchmove MSPointerMove pointermove",R),s.viewport.unbind("touchend MSPointerUp pointerup",V),s.viewport.get(0).releasePointerCapture&&s.viewport.get(0).releasePointerCapture(s.pointerId)},R=function(e){var t=e.originalEvent,i="undefined"!=typeof t.changedTouches?t.changedTouches:[t],n=Math.abs(i[0].pageX-s.touch.start.x),o=Math.abs(i[0].pageY-s.touch.start.y);if(3*n>o&&s.settings.preventDefaultSwipeX?e.preventDefault():3*o>n&&s.settings.preventDefaultSwipeY&&e.preventDefault(),"fade"!==s.settings.mode&&s.settings.oneToOneTouch){var r=0,a=0;"horizontal"===s.settings.mode?(a=i[0].pageX-s.touch.start.x,r=s.touch.originalPos.left+a):(a=i[0].pageY-s.touch.start.y,r=s.touch.originalPos.top+a),S(r,"reset",0)}},V=function(e){s.viewport.unbind("touchmove MSPointerMove pointermove",R),s.controls.el.removeClass("disabled");var t=e.originalEvent,i="undefined"!=typeof t.changedTouches?t.changedTouches:[t],n=0,r=0;s.touch.end.x=i[0].pageX,s.touch.end.y=i[0].pageY,"fade"===s.settings.mode?(r=Math.abs(s.touch.start.x-s.touch.end.x),r>=s.settings.swipeThreshold&&(s.touch.start.x>s.touch.end.x?o.goToNextSlide():o.goToPrevSlide(),o.stopAuto())):("horizontal"===s.settings.mode?(r=s.touch.end.x-s.touch.start.x,n=s.touch.originalPos.left):(r=s.touch.end.y-s.touch.start.y,n=s.touch.originalPos.top),!s.settings.infiniteLoop&&(0===s.active.index&&r>0||s.active.last&&0>r)?S(n,"reset",200):Math.abs(r)>=s.settings.swipeThreshold?(0>r?o.goToNextSlide():o.goToPrevSlide(),o.stopAuto()):S(n,"reset",200)),s.viewport.unbind("touchend MSPointerUp pointerup",V),s.viewport.get(0).releasePointerCapture&&s.viewport.get(0).releasePointerCapture(s.pointerId)},Z=function(){if(s.initialized)if(s.working)window.setTimeout(Z,10);else{var t=e(window).width(),i=e(window).height();(r!==t||a!==i)&&(r=t,a=i,o.redrawSlider(),s.settings.onSliderResize.call(o,s.active.index))}};return o.goToSlide=function(t,i){if(!s.working&&s.active.index!==t){s.working=!0,s.oldIndex=s.active.index,s.active.index=0>t?f()-1:t>=f()?0:t;var n=!0;if(n=s.settings.onSlideBefore(s.children.eq(s.active.index),s.oldIndex,s.active.index),"undefined"!=typeof n&&!n)return s.active.index=s.oldIndex,void(s.working=!1);if("next"===i?s.settings.onSlideNext(s.children.eq(s.active.index),s.oldIndex,s.active.index)||(n=!1):"prev"===i&&(s.settings.onSlidePrev(s.children.eq(s.active.index),s.oldIndex,s.active.index)||(n=!1)),"undefined"!=typeof n&&!n)return s.active.index=s.oldIndex,void(s.working=!1);if(s.active.last=s.active.index>=f()-1,(s.settings.pager||s.settings.pagerCustom)&&I(s.active.index),s.settings.controls&&W(),"fade"===s.settings.mode)s.settings.adaptiveHeight&&s.viewport.height()!==p()&&s.viewport.animate({height:p()},s.settings.adaptiveHeightSpeed),s.children.filter(":visible").fadeOut(s.settings.speed).css({zIndex:0}),s.children.eq(s.active.index).css("zIndex",s.settings.slideZIndex+1).fadeIn(s.settings.speed,function(){e(this).css("zIndex",s.settings.slideZIndex),q()});else{s.settings.adaptiveHeight&&s.viewport.height()!==p()&&s.viewport.animate({height:p()},s.settings.adaptiveHeightSpeed);var r=0,a={left:0,top:0},l=null;if(!s.settings.infiniteLoop&&s.carousel&&s.active.last)if("horizontal"===s.settings.mode)l=s.children.eq(s.children.length-1),a=l.position(),r=s.viewport.width()-l.outerWidth();else{var d=s.children.length-s.settings.minSlides;a=s.children.eq(d).position()}else if(s.carousel&&s.active.last&&"prev"===i){var c=1===s.settings.moveSlides?s.settings.maxSlides-m():(f()-1)*m()-(s.children.length-s.settings.maxSlides);l=o.children(".bx-clone").eq(c),a=l.position()}else if("next"===i&&0===s.active.index)a=o.find("> .bx-clone").eq(s.settings.maxSlides).position(),s.active.last=!1;else if(t>=0){var g=t*m();a=s.children.eq(g).position()}if("undefined"!=typeof a){var u="horizontal"===s.settings.mode?-(a.left-r):-a.top;S(u,"slide",s.settings.speed)}}}},o.goToNextSlide=function(){if(s.settings.infiniteLoop||!s.active.last){var e=parseInt(s.active.index)+1;o.goToSlide(e,"next")}},o.goToPrevSlide=function(){if(s.settings.infiniteLoop||0!==s.active.index){var e=parseInt(s.active.index)-1;o.goToSlide(e,"prev")}},o.startAuto=function(e){s.interval||(s.interval=setInterval(function(){"next"===s.settings.autoDirection?o.goToNextSlide():o.goToPrevSlide()},s.settings.pause),s.settings.autoControls&&e!==!0&&D("stop"))},o.stopAuto=function(e){s.interval&&(clearInterval(s.interval),s.interval=null,s.settings.autoControls&&e!==!0&&D("start"))},o.getCurrentSlide=function(){return s.active.index},o.getCurrentSlideElement=function(){return s.children.eq(s.active.index)},o.getSlideCount=function(){return s.children.length},o.isWorking=function(){return s.working},o.redrawSlider=function(){s.children.add(o.find(".bx-clone")).outerWidth(h()),s.viewport.css("height",p()),s.settings.ticker||x(),s.active.last&&(s.active.index=f()-1),s.active.index>=f()&&(s.active.last=!0),s.settings.pager&&!s.settings.pagerCustom&&(w(),I(s.active.index))},o.destroySlider=function(){s.initialized&&(s.initialized=!1,e(".bx-clone",this).remove(),s.children.each(function(){void 0!==e(this).data("origStyle")?e(this).attr("style",e(this).data("origStyle")):e(this).removeAttr("style")}),void 0!==e(this).data("origStyle")?this.attr("style",e(this).data("origStyle")):e(this).removeAttr("style"),e(this).unwrap().unwrap(),s.controls.el&&s.controls.el.remove(),s.controls.next&&s.controls.next.remove(),s.controls.prev&&s.controls.prev.remove(),s.pagerEl&&s.settings.controls&&!s.settings.pagerCustom&&s.pagerEl.remove(),e(".bx-caption",this).remove(),s.controls.autoEl&&s.controls.autoEl.remove(),clearInterval(s.interval),s.settings.responsive&&e(window).unbind("resize",Z),s.settings.keyboardEnabled&&e(document).unbind("keydown",N))},o.reloadSlider=function(e){void 0!==e&&(n=e),o.destroySlider(),l()},l(),this}}(jQuery); \ No newline at end of file diff --git a/src/js/jquery.bxslider.js b/src/js/jquery.bxslider.js index dafe0b0e..aa8e83d5 100644 --- a/src/js/jquery.bxslider.js +++ b/src/js/jquery.bxslider.js @@ -1,5 +1,5 @@ /*** - * BxSlider v4.2.1 - Fully loaded, responsive content slider + * BxSlider v4.2.2 - Fully loaded, responsive content slider * http://bxslider.com * * Copyright 2014, Steven Wanderski - http://stevenwanderski.com - http://bxcreative.com @@ -552,19 +552,21 @@ // add the CSS transition-duration el.css('-' + slider.cssPrefix + '-transition-duration', duration / 1000 + 's'); if(type === 'slide'){ - // set the property value - el.css(slider.animProp, propValue); - // if value 0, just update - if(value === 0) { - updateAfterSlideTransition(); - } else { - // bind a callback method - executes when CSS transition completes - el.bind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function(){ - // unbind the callback - el.unbind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd'); + setTimeout(function() { + // set the property value + el.css(slider.animProp, propValue); + // if value 0, just update + if(value === 0) { updateAfterSlideTransition(); - }); - } + } else { + // bind a callback method - executes when CSS transition completes + el.bind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function(){ + // unbind the callback + el.unbind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd'); + updateAfterSlideTransition(); + }); + } + }, 0); }else if(type === 'reset'){ el.css(slider.animProp, propValue); }else if(type === 'ticker'){ @@ -646,7 +648,7 @@ slider.pagerEl = $(slider.settings.pagerCustom); } // assign the pager click binding - slider.pagerEl.on('click', 'a', clickPagerBind); + slider.pagerEl.on('click touchend', 'a', clickPagerBind); }; /** @@ -656,8 +658,8 @@ slider.controls.next = $('' + slider.settings.nextText + ''); slider.controls.prev = $('' + slider.settings.prevText + ''); // bind click actions to the controls - slider.controls.next.bind('click', clickNextBind); - slider.controls.prev.bind('click', clickPrevBind); + slider.controls.next.bind('click touchend', clickNextBind); + slider.controls.prev.bind('click touchend', clickPrevBind); // if nextSelector was supplied, populate it if(slider.settings.nextSelector){ $(slider.settings.nextSelector).append(slider.controls.next); @@ -728,10 +730,13 @@ * - DOM event object */ var clickNextBind = function(e){ + e.preventDefault(); + if (slider.controls.el.hasClass('disabled')) { + return; + } // if auto show is running, stop it if(slider.settings.auto){ el.stopAuto(); } el.goToNextSlide(); - e.preventDefault(); }; /** @@ -741,10 +746,13 @@ * - DOM event object */ var clickPrevBind = function(e){ + e.preventDefault(); + if (slider.controls.el.hasClass('disabled')) { + return; + } // if auto show is running, stop it if(slider.settings.auto){ el.stopAuto(); } el.goToPrevSlide(); - e.preventDefault(); }; /** @@ -776,6 +784,10 @@ * - DOM event object */ var clickPagerBind = function(e){ + e.preventDefault(); + if (slider.controls.el.hasClass('disabled')) { + return; + } // if auto show is running, stop it if(slider.settings.auto){ el.stopAuto(); } var pagerLink = $(e.currentTarget); @@ -783,7 +795,6 @@ var pagerIndex = parseInt(pagerLink.attr('data-slide-index')); // if clicked pager link is not active, continue with the goToSlide call if(pagerIndex !== slider.active.index){ el.goToSlide(pagerIndex); } - e.preventDefault(); } }; @@ -1055,7 +1066,16 @@ start: {x: 0, y: 0}, end: {x: 0, y: 0} }; - slider.viewport.bind('touchstart', onTouchStart); + slider.viewport.bind('touchstart MSPointerDown pointerdown', onTouchStart); + + //for browsers that have implemented pointer events and fire a click after + //every pointerup regardless of whether pointerup is on same screen location as pointerdown or not + slider.viewport.on('click', '.bxslider a', function(e) { + if (slider.viewport.hasClass('click-disabled')) { + e.preventDefault(); + slider.viewport.removeClass('click-disabled'); + } + }); }; /** @@ -1065,22 +1085,54 @@ * - DOM event object */ var onTouchStart = function(e){ + //disable slider controls while user is interacting with slides to avoid slider freeze that happens on touch devices when a slide swipe happens immediately after interacting with slider controls + slider.controls.el.addClass('disabled'); + if(slider.working){ e.preventDefault(); + slider.controls.el.removeClass('disabled'); }else{ // record the original position when touch starts slider.touch.originalPos = el.position(); var orig = e.originalEvent; + var touchPoints = (typeof orig.changedTouches != 'undefined') ? orig.changedTouches : [orig]; // record the starting touch x, y coordinates - slider.touch.start.x = orig.changedTouches[0].pageX; - slider.touch.start.y = orig.changedTouches[0].pageY; + slider.touch.start.x = touchPoints[0].pageX; + slider.touch.start.y = touchPoints[0].pageY; + + if (slider.viewport.get(0).setPointerCapture) { + slider.pointerId = orig.pointerId; + slider.viewport.get(0).setPointerCapture(slider.pointerId); + } // bind a "touchmove" event to the viewport - slider.viewport.bind('touchmove', onTouchMove); + slider.viewport.bind('touchmove MSPointerMove pointermove', onTouchMove); // bind a "touchend" event to the viewport - slider.viewport.bind('touchend', onTouchEnd); + slider.viewport.bind('touchend MSPointerUp pointerup', onTouchEnd); + slider.viewport.bind('MSPointerCancel pointercancel', onPointerCancel); } }; + /** + * Cancel Pointer for Windows Phone + * + * @param e (event) + * - DOM event object + */ + var onPointerCancel = function(e) { + /* onPointerCancel handler is needed to deal with situations when a touchend + doesn't fire after a touchstart (this happens on windows phones only) */ + setPositionProperty(slider.touch.originalPos.left, 'reset', 0); + + //remove handlers + slider.controls.el.removeClass('disabled'); + slider.viewport.unbind('MSPointerCancel pointercancel', onPointerCancel); + slider.viewport.unbind('touchmove MSPointerMove pointermove', onTouchMove); + slider.viewport.unbind('touchend MSPointerUp pointerup', onTouchEnd); + if (slider.viewport.get(0).releasePointerCapture) { + slider.viewport.get(0).releasePointerCapture(slider.pointerId); + } + } + /** * Event handler for "touchmove" * @@ -1089,9 +1141,10 @@ */ var onTouchMove = function(e){ var orig = e.originalEvent; + var touchPoints = (typeof orig.changedTouches != 'undefined') ? orig.changedTouches : [orig]; // if scrolling on y axis, do not prevent default - var xMovement = Math.abs(orig.changedTouches[0].pageX - slider.touch.start.x); - var yMovement = Math.abs(orig.changedTouches[0].pageY - slider.touch.start.y); + var xMovement = Math.abs(touchPoints[0].pageX - slider.touch.start.x); + var yMovement = Math.abs(touchPoints[0].pageY - slider.touch.start.y); // x axis swipe if((xMovement * 3) > yMovement && slider.settings.preventDefaultSwipeX){ e.preventDefault(); @@ -1103,11 +1156,11 @@ var value = 0, change = 0; // if horizontal, drag along x axis if(slider.settings.mode === 'horizontal'){ - change = orig.changedTouches[0].pageX - slider.touch.start.x; + change = touchPoints[0].pageX - slider.touch.start.x; value = slider.touch.originalPos.left + change; // if vertical, drag along y axis }else{ - change = orig.changedTouches[0].pageY - slider.touch.start.y; + change = touchPoints[0].pageY - slider.touch.start.y; value = slider.touch.originalPos.top + change; } setPositionProperty(value, 'reset', 0); @@ -1121,13 +1174,16 @@ * - DOM event object */ var onTouchEnd = function(e){ - slider.viewport.unbind('touchmove', onTouchMove); + slider.viewport.unbind('touchmove MSPointerMove pointermove', onTouchMove); + //enable slider controls as soon as user stops interacing with slides + slider.controls.el.removeClass('disabled'); var orig = e.originalEvent; + var touchPoints = (typeof orig.changedTouches != 'undefined') ? orig.changedTouches : [orig]; var value = 0; var distance = 0; // record end x, y positions - slider.touch.end.x = orig.changedTouches[0].pageX; - slider.touch.end.y = orig.changedTouches[0].pageY; + slider.touch.end.x = touchPoints[0].pageX; + slider.touch.end.y = touchPoints[0].pageY; // if fade mode, check if absolute x distance clears the threshold if(slider.settings.mode === 'fade'){ distance = Math.abs(slider.touch.start.x - slider.touch.end.x); @@ -1167,7 +1223,10 @@ } } } - slider.viewport.unbind('touchend', onTouchEnd); + slider.viewport.unbind('touchend MSPointerUp pointerup', onTouchEnd); + if (slider.viewport.get(0).releasePointerCapture) { + slider.viewport.get(0).releasePointerCapture(slider.pointerId); + } }; /** @@ -1318,6 +1377,7 @@ position = slider.children.eq(requestEl).position(); } + /* If the position doesn't exist * (e.g. if you destroy the slider on a next click), * it doesn't throw an error. diff --git a/src/less/jquery.bxslider.less b/src/less/jquery.bxslider.less index 6753d3cc..ea0f3d13 100644 --- a/src/less/jquery.bxslider.less +++ b/src/less/jquery.bxslider.less @@ -1,5 +1,5 @@ /*** - * BxSlider v4.2.1 - Fully loaded, responsive content slider + * BxSlider v4.2.2 - Fully loaded, responsive content slider * http://bxslider.com * * Written by: Steven Wanderski, 2014 @@ -19,6 +19,8 @@ margin: 0 auto 60px; padding: 0; *zoom: 1; + -ms-touch-action: pan-y; + touch-action: pan-y; img { max-width: 100%; display: block; @@ -101,6 +103,10 @@ ul.bxslider { *zoom: 1; *display: inline; } + .bx-pager-item { + font-size: 0; + line-height: 0; + } } /* DIRECTION CONTROLS (NEXT / PREV) */