合一猎豆雷达、合一看盟、猎豆37标识物

swiper.jquery.js 160KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779
  1. /**
  2. * Swiper 3.3.1
  3. * Most modern mobile touch slider and framework with hardware accelerated transitions
  4. *
  5. * http://www.idangero.us/swiper/
  6. *
  7. * Copyright 2016, Vladimir Kharlampidi
  8. * The iDangero.us
  9. * http://www.idangero.us/
  10. *
  11. * Licensed under MIT
  12. *
  13. * Released on: February 7, 2016
  14. */
  15. (function () {
  16. 'use strict';
  17. var $;
  18. /*===========================
  19. Swiper
  20. ===========================*/
  21. var Swiper = function (container, params) {
  22. if (!(this instanceof Swiper)) return new Swiper(container, params);
  23. var defaults = {
  24. direction: 'horizontal',
  25. touchEventsTarget: 'container',
  26. initialSlide: 0,
  27. speed: 300,
  28. // autoplay
  29. autoplay: false,
  30. autoplayDisableOnInteraction: true,
  31. autoplayStopOnLast: false,
  32. // To support iOS's swipe-to-go-back gesture (when being used in-app, with UIWebView).
  33. iOSEdgeSwipeDetection: false,
  34. iOSEdgeSwipeThreshold: 20,
  35. // Free mode
  36. freeMode: false,
  37. freeModeMomentum: true,
  38. freeModeMomentumRatio: 1,
  39. freeModeMomentumBounce: true,
  40. freeModeMomentumBounceRatio: 1,
  41. freeModeSticky: false,
  42. freeModeMinimumVelocity: 0.02,
  43. // Autoheight
  44. autoHeight: false,
  45. // Set wrapper width
  46. setWrapperSize: false,
  47. // Virtual Translate
  48. virtualTranslate: false,
  49. // Effects
  50. effect: 'slide', // 'slide' or 'fade' or 'cube' or 'coverflow' or 'flip'
  51. coverflow: {
  52. rotate: 50,
  53. stretch: 0,
  54. depth: 100,
  55. modifier: 1,
  56. slideShadows : true
  57. },
  58. flip: {
  59. slideShadows : true,
  60. limitRotation: true
  61. },
  62. cube: {
  63. slideShadows: true,
  64. shadow: true,
  65. shadowOffset: 20,
  66. shadowScale: 0.94
  67. },
  68. fade: {
  69. crossFade: false
  70. },
  71. // Parallax
  72. parallax: false,
  73. // Scrollbar
  74. scrollbar: null,
  75. scrollbarHide: true,
  76. scrollbarDraggable: false,
  77. scrollbarSnapOnRelease: false,
  78. // Keyboard Mousewheel
  79. keyboardControl: false,
  80. mousewheelControl: false,
  81. mousewheelReleaseOnEdges: false,
  82. mousewheelInvert: false,
  83. mousewheelForceToAxis: false,
  84. mousewheelSensitivity: 1,
  85. // Hash Navigation
  86. hashnav: false,
  87. // Breakpoints
  88. breakpoints: undefined,
  89. // Slides grid
  90. spaceBetween: 0,
  91. slidesPerView: 1,
  92. slidesPerColumn: 1,
  93. slidesPerColumnFill: 'column',
  94. slidesPerGroup: 1,
  95. centeredSlides: false,
  96. slidesOffsetBefore: 0, // in px
  97. slidesOffsetAfter: 0, // in px
  98. // Round length
  99. roundLengths: false,
  100. // Touches
  101. touchRatio: 1,
  102. touchAngle: 45,
  103. simulateTouch: true,
  104. shortSwipes: true,
  105. longSwipes: true,
  106. longSwipesRatio: 0.5,
  107. longSwipesMs: 300,
  108. followFinger: true,
  109. onlyExternal: false,
  110. threshold: 0,
  111. touchMoveStopPropagation: true,
  112. // Unique Navigation Elements
  113. uniqueNavElements: true,
  114. // Pagination
  115. pagination: null,
  116. paginationElement: 'span',
  117. paginationClickable: false,
  118. paginationHide: false,
  119. paginationBulletRender: null,
  120. paginationProgressRender: null,
  121. paginationFractionRender: null,
  122. paginationCustomRender: null,
  123. paginationType: 'bullets', // 'bullets' or 'progress' or 'fraction' or 'custom'
  124. // Resistance
  125. resistance: true,
  126. resistanceRatio: 0.85,
  127. // Next/prev buttons
  128. nextButton: null,
  129. prevButton: null,
  130. // Progress
  131. watchSlidesProgress: false,
  132. watchSlidesVisibility: false,
  133. // Cursor
  134. grabCursor: false,
  135. // Clicks
  136. preventClicks: true,
  137. preventClicksPropagation: true,
  138. slideToClickedSlide: false,
  139. // Lazy Loading
  140. lazyLoading: false,
  141. lazyLoadingInPrevNext: false,
  142. lazyLoadingInPrevNextAmount: 1,
  143. lazyLoadingOnTransitionStart: false,
  144. // Images
  145. preloadImages: true,
  146. updateOnImagesReady: true,
  147. // loop
  148. loop: false,
  149. loopAdditionalSlides: 0,
  150. loopedSlides: null,
  151. // Control
  152. control: undefined,
  153. controlInverse: false,
  154. controlBy: 'slide', //or 'container'
  155. // Swiping/no swiping
  156. allowSwipeToPrev: true,
  157. allowSwipeToNext: true,
  158. swipeHandler: null, //'.swipe-handler',
  159. noSwiping: true,
  160. noSwipingClass: 'swiper-no-swiping',
  161. // NS
  162. slideClass: 'swiper-slide',
  163. slideActiveClass: 'swiper-slide-active',
  164. slideVisibleClass: 'swiper-slide-visible',
  165. slideDuplicateClass: 'swiper-slide-duplicate',
  166. slideNextClass: 'swiper-slide-next',
  167. slidePrevClass: 'swiper-slide-prev',
  168. wrapperClass: 'swiper-wrapper',
  169. bulletClass: 'swiper-pagination-bullet',
  170. bulletActiveClass: 'swiper-pagination-bullet-active',
  171. buttonDisabledClass: 'swiper-button-disabled',
  172. paginationCurrentClass: 'swiper-pagination-current',
  173. paginationTotalClass: 'swiper-pagination-total',
  174. paginationHiddenClass: 'swiper-pagination-hidden',
  175. paginationProgressbarClass: 'swiper-pagination-progressbar',
  176. // Observer
  177. observer: false,
  178. observeParents: false,
  179. // Accessibility
  180. a11y: false,
  181. prevSlideMessage: 'Previous slide',
  182. nextSlideMessage: 'Next slide',
  183. firstSlideMessage: 'This is the first slide',
  184. lastSlideMessage: 'This is the last slide',
  185. paginationBulletMessage: 'Go to slide {{index}}',
  186. // Callbacks
  187. runCallbacksOnInit: true
  188. /*
  189. Callbacks:
  190. onInit: function (swiper)
  191. onDestroy: function (swiper)
  192. onClick: function (swiper, e)
  193. onTap: function (swiper, e)
  194. onDoubleTap: function (swiper, e)
  195. onSliderMove: function (swiper, e)
  196. onSlideChangeStart: function (swiper)
  197. onSlideChangeEnd: function (swiper)
  198. onTransitionStart: function (swiper)
  199. onTransitionEnd: function (swiper)
  200. onImagesReady: function (swiper)
  201. onProgress: function (swiper, progress)
  202. onTouchStart: function (swiper, e)
  203. onTouchMove: function (swiper, e)
  204. onTouchMoveOpposite: function (swiper, e)
  205. onTouchEnd: function (swiper, e)
  206. onReachBeginning: function (swiper)
  207. onReachEnd: function (swiper)
  208. onSetTransition: function (swiper, duration)
  209. onSetTranslate: function (swiper, translate)
  210. onAutoplayStart: function (swiper)
  211. onAutoplayStop: function (swiper),
  212. onLazyImageLoad: function (swiper, slide, image)
  213. onLazyImageReady: function (swiper, slide, image)
  214. */
  215. };
  216. var initialVirtualTranslate = params && params.virtualTranslate;
  217. params = params || {};
  218. var originalParams = {};
  219. for (var param in params) {
  220. if (typeof params[param] === 'object' && params[param] !== null && !(params[param].nodeType || params[param] === window || params[param] === document || (typeof Dom7 !== 'undefined' && params[param] instanceof Dom7) || (typeof jQuery !== 'undefined' && params[param] instanceof jQuery))) {
  221. originalParams[param] = {};
  222. for (var deepParam in params[param]) {
  223. originalParams[param][deepParam] = params[param][deepParam];
  224. }
  225. }
  226. else {
  227. originalParams[param] = params[param];
  228. }
  229. }
  230. for (var def in defaults) {
  231. if (typeof params[def] === 'undefined') {
  232. params[def] = defaults[def];
  233. }
  234. else if (typeof params[def] === 'object') {
  235. for (var deepDef in defaults[def]) {
  236. if (typeof params[def][deepDef] === 'undefined') {
  237. params[def][deepDef] = defaults[def][deepDef];
  238. }
  239. }
  240. }
  241. }
  242. // Swiper
  243. var s = this;
  244. // Params
  245. s.params = params;
  246. s.originalParams = originalParams;
  247. // Classname
  248. s.classNames = [];
  249. /*=========================
  250. Dom Library and plugins
  251. ===========================*/
  252. if (typeof $ !== 'undefined' && typeof Dom7 !== 'undefined'){
  253. $ = Dom7;
  254. }
  255. if (typeof $ === 'undefined') {
  256. if (typeof Dom7 === 'undefined') {
  257. $ = window.Dom7 || window.Zepto || window.jQuery;
  258. }
  259. else {
  260. $ = Dom7;
  261. }
  262. if (!$) return;
  263. }
  264. // Export it to Swiper instance
  265. s.$ = $;
  266. /*=========================
  267. Breakpoints
  268. ===========================*/
  269. s.currentBreakpoint = undefined;
  270. s.getActiveBreakpoint = function () {
  271. //Get breakpoint for window width
  272. if (!s.params.breakpoints) return false;
  273. var breakpoint = false;
  274. var points = [], point;
  275. for ( point in s.params.breakpoints ) {
  276. if (s.params.breakpoints.hasOwnProperty(point)) {
  277. points.push(point);
  278. }
  279. }
  280. points.sort(function (a, b) {
  281. return parseInt(a, 10) > parseInt(b, 10);
  282. });
  283. for (var i = 0; i < points.length; i++) {
  284. point = points[i];
  285. if (point >= window.innerWidth && !breakpoint) {
  286. breakpoint = point;
  287. }
  288. }
  289. return breakpoint || 'max';
  290. };
  291. s.setBreakpoint = function () {
  292. //Set breakpoint for window width and update parameters
  293. var breakpoint = s.getActiveBreakpoint();
  294. if (breakpoint && s.currentBreakpoint !== breakpoint) {
  295. var breakPointsParams = breakpoint in s.params.breakpoints ? s.params.breakpoints[breakpoint] : s.originalParams;
  296. var needsReLoop = s.params.loop && (breakPointsParams.slidesPerView !== s.params.slidesPerView);
  297. for ( var param in breakPointsParams ) {
  298. s.params[param] = breakPointsParams[param];
  299. }
  300. s.currentBreakpoint = breakpoint;
  301. if(needsReLoop && s.destroyLoop) {
  302. s.reLoop(true);
  303. }
  304. }
  305. };
  306. // Set breakpoint on load
  307. if (s.params.breakpoints) {
  308. s.setBreakpoint();
  309. }
  310. /*=========================
  311. Preparation - Define Container, Wrapper and Pagination
  312. ===========================*/
  313. s.container = $(container);
  314. if (s.container.length === 0) return;
  315. if (s.container.length > 1) {
  316. var swipers = [];
  317. s.container.each(function () {
  318. var container = this;
  319. swipers.push(new Swiper(this, params));
  320. });
  321. return swipers;
  322. }
  323. // Save instance in container HTML Element and in data
  324. s.container[0].swiper = s;
  325. s.container.data('swiper', s);
  326. s.classNames.push('swiper-container-' + s.params.direction);
  327. if (s.params.freeMode) {
  328. s.classNames.push('swiper-container-free-mode');
  329. }
  330. if (!s.support.flexbox) {
  331. s.classNames.push('swiper-container-no-flexbox');
  332. s.params.slidesPerColumn = 1;
  333. }
  334. if (s.params.autoHeight) {
  335. s.classNames.push('swiper-container-autoheight');
  336. }
  337. // Enable slides progress when required
  338. if (s.params.parallax || s.params.watchSlidesVisibility) {
  339. s.params.watchSlidesProgress = true;
  340. }
  341. // Coverflow / 3D
  342. if (['cube', 'coverflow', 'flip'].indexOf(s.params.effect) >= 0) {
  343. if (s.support.transforms3d) {
  344. s.params.watchSlidesProgress = true;
  345. s.classNames.push('swiper-container-3d');
  346. }
  347. else {
  348. s.params.effect = 'slide';
  349. }
  350. }
  351. if (s.params.effect !== 'slide') {
  352. s.classNames.push('swiper-container-' + s.params.effect);
  353. }
  354. if (s.params.effect === 'cube') {
  355. s.params.resistanceRatio = 0;
  356. s.params.slidesPerView = 1;
  357. s.params.slidesPerColumn = 1;
  358. s.params.slidesPerGroup = 1;
  359. s.params.centeredSlides = false;
  360. s.params.spaceBetween = 0;
  361. s.params.virtualTranslate = true;
  362. s.params.setWrapperSize = false;
  363. }
  364. if (s.params.effect === 'fade' || s.params.effect === 'flip') {
  365. s.params.slidesPerView = 1;
  366. s.params.slidesPerColumn = 1;
  367. s.params.slidesPerGroup = 1;
  368. s.params.watchSlidesProgress = true;
  369. s.params.spaceBetween = 0;
  370. s.params.setWrapperSize = false;
  371. if (typeof initialVirtualTranslate === 'undefined') {
  372. s.params.virtualTranslate = true;
  373. }
  374. }
  375. // Grab Cursor
  376. if (s.params.grabCursor && s.support.touch) {
  377. s.params.grabCursor = false;
  378. }
  379. // Wrapper
  380. s.wrapper = s.container.children('.' + s.params.wrapperClass);
  381. // Pagination
  382. if (s.params.pagination) {
  383. s.paginationContainer = $(s.params.pagination);
  384. if (s.params.uniqueNavElements && typeof s.params.pagination === 'string' && s.paginationContainer.length > 1 && s.container.find(s.params.pagination).length === 1) {
  385. s.paginationContainer = s.container.find(s.params.pagination);
  386. }
  387. if (s.params.paginationType === 'bullets' && s.params.paginationClickable) {
  388. s.paginationContainer.addClass('swiper-pagination-clickable');
  389. }
  390. else {
  391. s.params.paginationClickable = false;
  392. }
  393. s.paginationContainer.addClass('swiper-pagination-' + s.params.paginationType);
  394. }
  395. // Next/Prev Buttons
  396. if (s.params.nextButton || s.params.prevButton) {
  397. if (s.params.nextButton) {
  398. s.nextButton = $(s.params.nextButton);
  399. if (s.params.uniqueNavElements && typeof s.params.nextButton === 'string' && s.nextButton.length > 1 && s.container.find(s.params.nextButton).length === 1) {
  400. s.nextButton = s.container.find(s.params.nextButton);
  401. }
  402. }
  403. if (s.params.prevButton) {
  404. s.prevButton = $(s.params.prevButton);
  405. if (s.params.uniqueNavElements && typeof s.params.prevButton === 'string' && s.prevButton.length > 1 && s.container.find(s.params.prevButton).length === 1) {
  406. s.prevButton = s.container.find(s.params.prevButton);
  407. }
  408. }
  409. }
  410. // Is Horizontal
  411. s.isHorizontal = function () {
  412. return s.params.direction === 'horizontal';
  413. };
  414. // s.isH = isH;
  415. // RTL
  416. s.rtl = s.isHorizontal() && (s.container[0].dir.toLowerCase() === 'rtl' || s.container.css('direction') === 'rtl');
  417. if (s.rtl) {
  418. s.classNames.push('swiper-container-rtl');
  419. }
  420. // Wrong RTL support
  421. if (s.rtl) {
  422. s.wrongRTL = s.wrapper.css('display') === '-webkit-box';
  423. }
  424. // Columns
  425. if (s.params.slidesPerColumn > 1) {
  426. s.classNames.push('swiper-container-multirow');
  427. }
  428. // Check for Android
  429. if (s.device.android) {
  430. s.classNames.push('swiper-container-android');
  431. }
  432. // Add classes
  433. s.container.addClass(s.classNames.join(' '));
  434. // Translate
  435. s.translate = 0;
  436. // Progress
  437. s.progress = 0;
  438. // Velocity
  439. s.velocity = 0;
  440. /*=========================
  441. Locks, unlocks
  442. ===========================*/
  443. s.lockSwipeToNext = function () {
  444. s.params.allowSwipeToNext = false;
  445. };
  446. s.lockSwipeToPrev = function () {
  447. s.params.allowSwipeToPrev = false;
  448. };
  449. s.lockSwipes = function () {
  450. s.params.allowSwipeToNext = s.params.allowSwipeToPrev = false;
  451. };
  452. s.unlockSwipeToNext = function () {
  453. s.params.allowSwipeToNext = true;
  454. };
  455. s.unlockSwipeToPrev = function () {
  456. s.params.allowSwipeToPrev = true;
  457. };
  458. s.unlockSwipes = function () {
  459. s.params.allowSwipeToNext = s.params.allowSwipeToPrev = true;
  460. };
  461. /*=========================
  462. Round helper
  463. ===========================*/
  464. function round(a) {
  465. return Math.floor(a);
  466. }
  467. /*=========================
  468. Set grab cursor
  469. ===========================*/
  470. if (s.params.grabCursor) {
  471. s.container[0].style.cursor = 'move';
  472. s.container[0].style.cursor = '-webkit-grab';
  473. s.container[0].style.cursor = '-moz-grab';
  474. s.container[0].style.cursor = 'grab';
  475. }
  476. /*=========================
  477. Update on Images Ready
  478. ===========================*/
  479. s.imagesToLoad = [];
  480. s.imagesLoaded = 0;
  481. s.loadImage = function (imgElement, src, srcset, checkForComplete, callback) {
  482. var image;
  483. function onReady () {
  484. if (callback) callback();
  485. }
  486. if (!imgElement.complete || !checkForComplete) {
  487. if (src) {
  488. image = new window.Image();
  489. image.onload = onReady;
  490. image.onerror = onReady;
  491. if (srcset) {
  492. image.srcset = srcset;
  493. }
  494. if (src) {
  495. image.src = src;
  496. }
  497. } else {
  498. onReady();
  499. }
  500. } else {//image already loaded...
  501. onReady();
  502. }
  503. };
  504. s.preloadImages = function () {
  505. s.imagesToLoad = s.container.find('img');
  506. function _onReady() {
  507. if (typeof s === 'undefined' || s === null) return;
  508. if (s.imagesLoaded !== undefined) s.imagesLoaded++;
  509. if (s.imagesLoaded === s.imagesToLoad.length) {
  510. if (s.params.updateOnImagesReady) s.update();
  511. s.emit('onImagesReady', s);
  512. }
  513. }
  514. for (var i = 0; i < s.imagesToLoad.length; i++) {
  515. s.loadImage(s.imagesToLoad[i], (s.imagesToLoad[i].currentSrc || s.imagesToLoad[i].getAttribute('src')), (s.imagesToLoad[i].srcset || s.imagesToLoad[i].getAttribute('srcset')), true, _onReady);
  516. }
  517. };
  518. /*=========================
  519. Autoplay
  520. ===========================*/
  521. s.autoplayTimeoutId = undefined;
  522. s.autoplaying = false;
  523. s.autoplayPaused = false;
  524. function autoplay() {
  525. s.autoplayTimeoutId = setTimeout(function () {
  526. if (s.params.loop) {
  527. s.fixLoop();
  528. s._slideNext();
  529. s.emit('onAutoplay', s);
  530. }
  531. else {
  532. if (!s.isEnd) {
  533. s._slideNext();
  534. s.emit('onAutoplay', s);
  535. }
  536. else {
  537. if (!params.autoplayStopOnLast) {
  538. s._slideTo(0);
  539. s.emit('onAutoplay', s);
  540. }
  541. else {
  542. s.stopAutoplay();
  543. }
  544. }
  545. }
  546. }, s.params.autoplay);
  547. }
  548. s.startAutoplay = function () {
  549. if (typeof s.autoplayTimeoutId !== 'undefined') return false;
  550. if (!s.params.autoplay) return false;
  551. if (s.autoplaying) return false;
  552. s.autoplaying = true;
  553. s.emit('onAutoplayStart', s);
  554. autoplay();
  555. };
  556. s.stopAutoplay = function (internal) {
  557. if (!s.autoplayTimeoutId) return;
  558. if (s.autoplayTimeoutId) clearTimeout(s.autoplayTimeoutId);
  559. s.autoplaying = false;
  560. s.autoplayTimeoutId = undefined;
  561. s.emit('onAutoplayStop', s);
  562. };
  563. s.pauseAutoplay = function (speed) {
  564. if (s.autoplayPaused) return;
  565. if (s.autoplayTimeoutId) clearTimeout(s.autoplayTimeoutId);
  566. s.autoplayPaused = true;
  567. if (speed === 0) {
  568. s.autoplayPaused = false;
  569. autoplay();
  570. }
  571. else {
  572. s.wrapper.transitionEnd(function () {
  573. if (!s) return;
  574. s.autoplayPaused = false;
  575. if (!s.autoplaying) {
  576. s.stopAutoplay();
  577. }
  578. else {
  579. autoplay();
  580. }
  581. });
  582. }
  583. };
  584. /*=========================
  585. Min/Max Translate
  586. ===========================*/
  587. s.minTranslate = function () {
  588. return (-s.snapGrid[0]);
  589. };
  590. s.maxTranslate = function () {
  591. return (-s.snapGrid[s.snapGrid.length - 1]);
  592. };
  593. /*=========================
  594. Slider/slides sizes
  595. ===========================*/
  596. s.updateAutoHeight = function () {
  597. // Update Height
  598. var slide = s.slides.eq(s.activeIndex)[0];
  599. if (typeof slide !== 'undefined') {
  600. var newHeight = slide.offsetHeight;
  601. if (newHeight) s.wrapper.css('height', newHeight + 'px');
  602. }
  603. };
  604. s.updateContainerSize = function () {
  605. var width, height;
  606. if (typeof s.params.width !== 'undefined') {
  607. width = s.params.width;
  608. }
  609. else {
  610. width = s.container[0].clientWidth;
  611. }
  612. if (typeof s.params.height !== 'undefined') {
  613. height = s.params.height;
  614. }
  615. else {
  616. height = s.container[0].clientHeight;
  617. }
  618. if (width === 0 && s.isHorizontal() || height === 0 && !s.isHorizontal()) {
  619. return;
  620. }
  621. //Subtract paddings
  622. width = width - parseInt(s.container.css('padding-left'), 10) - parseInt(s.container.css('padding-right'), 10);
  623. height = height - parseInt(s.container.css('padding-top'), 10) - parseInt(s.container.css('padding-bottom'), 10);
  624. // Store values
  625. s.width = width;
  626. s.height = height;
  627. s.size = s.isHorizontal() ? s.width : s.height;
  628. };
  629. s.updateSlidesSize = function () {
  630. s.slides = s.wrapper.children('.' + s.params.slideClass);
  631. s.snapGrid = [];
  632. s.slidesGrid = [];
  633. s.slidesSizesGrid = [];
  634. var spaceBetween = s.params.spaceBetween,
  635. slidePosition = -s.params.slidesOffsetBefore,
  636. i,
  637. prevSlideSize = 0,
  638. index = 0;
  639. if (typeof s.size === 'undefined') return;
  640. if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) {
  641. spaceBetween = parseFloat(spaceBetween.replace('%', '')) / 100 * s.size;
  642. }
  643. s.virtualSize = -spaceBetween;
  644. // reset margins
  645. if (s.rtl) s.slides.css({marginLeft: '', marginTop: ''});
  646. else s.slides.css({marginRight: '', marginBottom: ''});
  647. var slidesNumberEvenToRows;
  648. if (s.params.slidesPerColumn > 1) {
  649. if (Math.floor(s.slides.length / s.params.slidesPerColumn) === s.slides.length / s.params.slidesPerColumn) {
  650. slidesNumberEvenToRows = s.slides.length;
  651. }
  652. else {
  653. slidesNumberEvenToRows = Math.ceil(s.slides.length / s.params.slidesPerColumn) * s.params.slidesPerColumn;
  654. }
  655. if (s.params.slidesPerView !== 'auto' && s.params.slidesPerColumnFill === 'row') {
  656. slidesNumberEvenToRows = Math.max(slidesNumberEvenToRows, s.params.slidesPerView * s.params.slidesPerColumn);
  657. }
  658. }
  659. // Calc slides
  660. var slideSize;
  661. var slidesPerColumn = s.params.slidesPerColumn;
  662. var slidesPerRow = slidesNumberEvenToRows / slidesPerColumn;
  663. var numFullColumns = slidesPerRow - (s.params.slidesPerColumn * slidesPerRow - s.slides.length);
  664. for (i = 0; i < s.slides.length; i++) {
  665. slideSize = 0;
  666. var slide = s.slides.eq(i);
  667. if (s.params.slidesPerColumn > 1) {
  668. // Set slides order
  669. var newSlideOrderIndex;
  670. var column, row;
  671. if (s.params.slidesPerColumnFill === 'column') {
  672. column = Math.floor(i / slidesPerColumn);
  673. row = i - column * slidesPerColumn;
  674. if (column > numFullColumns || (column === numFullColumns && row === slidesPerColumn-1)) {
  675. if (++row >= slidesPerColumn) {
  676. row = 0;
  677. column++;
  678. }
  679. }
  680. newSlideOrderIndex = column + row * slidesNumberEvenToRows / slidesPerColumn;
  681. slide
  682. .css({
  683. '-webkit-box-ordinal-group': newSlideOrderIndex,
  684. '-moz-box-ordinal-group': newSlideOrderIndex,
  685. '-ms-flex-order': newSlideOrderIndex,
  686. '-webkit-order': newSlideOrderIndex,
  687. 'order': newSlideOrderIndex
  688. });
  689. }
  690. else {
  691. row = Math.floor(i / slidesPerRow);
  692. column = i - row * slidesPerRow;
  693. }
  694. slide
  695. .css({
  696. 'margin-top': (row !== 0 && s.params.spaceBetween) && (s.params.spaceBetween + 'px')
  697. })
  698. .attr('data-swiper-column', column)
  699. .attr('data-swiper-row', row);
  700. }
  701. if (slide.css('display') === 'none') continue;
  702. if (s.params.slidesPerView === 'auto') {
  703. slideSize = s.isHorizontal() ? slide.outerWidth(true) : slide.outerHeight(true);
  704. if (s.params.roundLengths) slideSize = round(slideSize);
  705. }
  706. else {
  707. slideSize = (s.size - (s.params.slidesPerView - 1) * spaceBetween) / s.params.slidesPerView;
  708. if (s.params.roundLengths) slideSize = round(slideSize);
  709. if (s.isHorizontal()) {
  710. s.slides[i].style.width = slideSize + 'px';
  711. }
  712. else {
  713. s.slides[i].style.height = slideSize + 'px';
  714. }
  715. }
  716. s.slides[i].swiperSlideSize = slideSize;
  717. s.slidesSizesGrid.push(slideSize);
  718. if (s.params.centeredSlides) {
  719. slidePosition = slidePosition + slideSize / 2 + prevSlideSize / 2 + spaceBetween;
  720. if (i === 0) slidePosition = slidePosition - s.size / 2 - spaceBetween;
  721. if (Math.abs(slidePosition) < 1 / 1000) slidePosition = 0;
  722. if ((index) % s.params.slidesPerGroup === 0) s.snapGrid.push(slidePosition);
  723. s.slidesGrid.push(slidePosition);
  724. }
  725. else {
  726. if ((index) % s.params.slidesPerGroup === 0) s.snapGrid.push(slidePosition);
  727. s.slidesGrid.push(slidePosition);
  728. slidePosition = slidePosition + slideSize + spaceBetween;
  729. }
  730. s.virtualSize += slideSize + spaceBetween;
  731. prevSlideSize = slideSize;
  732. index ++;
  733. }
  734. s.virtualSize = Math.max(s.virtualSize, s.size) + s.params.slidesOffsetAfter;
  735. var newSlidesGrid;
  736. if (
  737. s.rtl && s.wrongRTL && (s.params.effect === 'slide' || s.params.effect === 'coverflow')) {
  738. s.wrapper.css({width: s.virtualSize + s.params.spaceBetween + 'px'});
  739. }
  740. if (!s.support.flexbox || s.params.setWrapperSize) {
  741. if (s.isHorizontal()) s.wrapper.css({width: s.virtualSize + s.params.spaceBetween + 'px'});
  742. else s.wrapper.css({height: s.virtualSize + s.params.spaceBetween + 'px'});
  743. }
  744. if (s.params.slidesPerColumn > 1) {
  745. s.virtualSize = (slideSize + s.params.spaceBetween) * slidesNumberEvenToRows;
  746. s.virtualSize = Math.ceil(s.virtualSize / s.params.slidesPerColumn) - s.params.spaceBetween;
  747. s.wrapper.css({width: s.virtualSize + s.params.spaceBetween + 'px'});
  748. if (s.params.centeredSlides) {
  749. newSlidesGrid = [];
  750. for (i = 0; i < s.snapGrid.length; i++) {
  751. if (s.snapGrid[i] < s.virtualSize + s.snapGrid[0]) newSlidesGrid.push(s.snapGrid[i]);
  752. }
  753. s.snapGrid = newSlidesGrid;
  754. }
  755. }
  756. // Remove last grid elements depending on width
  757. if (!s.params.centeredSlides) {
  758. newSlidesGrid = [];
  759. for (i = 0; i < s.snapGrid.length; i++) {
  760. if (s.snapGrid[i] <= s.virtualSize - s.size) {
  761. newSlidesGrid.push(s.snapGrid[i]);
  762. }
  763. }
  764. s.snapGrid = newSlidesGrid;
  765. if (Math.floor(s.virtualSize - s.size) - Math.floor(s.snapGrid[s.snapGrid.length - 1]) > 1) {
  766. s.snapGrid.push(s.virtualSize - s.size);
  767. }
  768. }
  769. if (s.snapGrid.length === 0) s.snapGrid = [0];
  770. if (s.params.spaceBetween !== 0) {
  771. if (s.isHorizontal()) {
  772. if (s.rtl) s.slides.css({marginLeft: spaceBetween + 'px'});
  773. else s.slides.css({marginRight: spaceBetween + 'px'});
  774. }
  775. else s.slides.css({marginBottom: spaceBetween + 'px'});
  776. }
  777. if (s.params.watchSlidesProgress) {
  778. s.updateSlidesOffset();
  779. }
  780. };
  781. s.updateSlidesOffset = function () {
  782. for (var i = 0; i < s.slides.length; i++) {
  783. s.slides[i].swiperSlideOffset = s.isHorizontal() ? s.slides[i].offsetLeft : s.slides[i].offsetTop;
  784. }
  785. };
  786. /*=========================
  787. Slider/slides progress
  788. ===========================*/
  789. s.updateSlidesProgress = function (translate) {
  790. if (typeof translate === 'undefined') {
  791. translate = s.translate || 0;
  792. }
  793. if (s.slides.length === 0) return;
  794. if (typeof s.slides[0].swiperSlideOffset === 'undefined') s.updateSlidesOffset();
  795. var offsetCenter = -translate;
  796. if (s.rtl) offsetCenter = translate;
  797. // Visible Slides
  798. s.slides.removeClass(s.params.slideVisibleClass);
  799. for (var i = 0; i < s.slides.length; i++) {
  800. var slide = s.slides[i];
  801. var slideProgress = (offsetCenter - slide.swiperSlideOffset) / (slide.swiperSlideSize + s.params.spaceBetween);
  802. if (s.params.watchSlidesVisibility) {
  803. var slideBefore = -(offsetCenter - slide.swiperSlideOffset);
  804. var slideAfter = slideBefore + s.slidesSizesGrid[i];
  805. var isVisible =
  806. (slideBefore >= 0 && slideBefore < s.size) ||
  807. (slideAfter > 0 && slideAfter <= s.size) ||
  808. (slideBefore <= 0 && slideAfter >= s.size);
  809. if (isVisible) {
  810. s.slides.eq(i).addClass(s.params.slideVisibleClass);
  811. }
  812. }
  813. slide.progress = s.rtl ? -slideProgress : slideProgress;
  814. }
  815. };
  816. s.updateProgress = function (translate) {
  817. if (typeof translate === 'undefined') {
  818. translate = s.translate || 0;
  819. }
  820. var translatesDiff = s.maxTranslate() - s.minTranslate();
  821. var wasBeginning = s.isBeginning;
  822. var wasEnd = s.isEnd;
  823. if (translatesDiff === 0) {
  824. s.progress = 0;
  825. s.isBeginning = s.isEnd = true;
  826. }
  827. else {
  828. s.progress = (translate - s.minTranslate()) / (translatesDiff);
  829. s.isBeginning = s.progress <= 0;
  830. s.isEnd = s.progress >= 1;
  831. }
  832. if (s.isBeginning && !wasBeginning) s.emit('onReachBeginning', s);
  833. if (s.isEnd && !wasEnd) s.emit('onReachEnd', s);
  834. if (s.params.watchSlidesProgress) s.updateSlidesProgress(translate);
  835. s.emit('onProgress', s, s.progress);
  836. };
  837. s.updateActiveIndex = function () {
  838. var translate = s.rtl ? s.translate : -s.translate;
  839. var newActiveIndex, i, snapIndex;
  840. for (i = 0; i < s.slidesGrid.length; i ++) {
  841. if (typeof s.slidesGrid[i + 1] !== 'undefined') {
  842. if (translate >= s.slidesGrid[i] && translate < s.slidesGrid[i + 1] - (s.slidesGrid[i + 1] - s.slidesGrid[i]) / 2) {
  843. newActiveIndex = i;
  844. }
  845. else if (translate >= s.slidesGrid[i] && translate < s.slidesGrid[i + 1]) {
  846. newActiveIndex = i + 1;
  847. }
  848. }
  849. else {
  850. if (translate >= s.slidesGrid[i]) {
  851. newActiveIndex = i;
  852. }
  853. }
  854. }
  855. // Normalize slideIndex
  856. if (newActiveIndex < 0 || typeof newActiveIndex === 'undefined') newActiveIndex = 0;
  857. // for (i = 0; i < s.slidesGrid.length; i++) {
  858. // if (- translate >= s.slidesGrid[i]) {
  859. // newActiveIndex = i;
  860. // }
  861. // }
  862. snapIndex = Math.floor(newActiveIndex / s.params.slidesPerGroup);
  863. if (snapIndex >= s.snapGrid.length) snapIndex = s.snapGrid.length - 1;
  864. if (newActiveIndex === s.activeIndex) {
  865. return;
  866. }
  867. s.snapIndex = snapIndex;
  868. s.previousIndex = s.activeIndex;
  869. s.activeIndex = newActiveIndex;
  870. s.updateClasses();
  871. };
  872. /*=========================
  873. Classes
  874. ===========================*/
  875. s.updateClasses = function () {
  876. s.slides.removeClass(s.params.slideActiveClass + ' ' + s.params.slideNextClass + ' ' + s.params.slidePrevClass);
  877. var activeSlide = s.slides.eq(s.activeIndex);
  878. // Active classes
  879. activeSlide.addClass(s.params.slideActiveClass);
  880. // Next Slide
  881. var nextSlide = activeSlide.next('.' + s.params.slideClass).addClass(s.params.slideNextClass);
  882. if (s.params.loop && nextSlide.length === 0) {
  883. s.slides.eq(0).addClass(s.params.slideNextClass);
  884. }
  885. // Prev Slide
  886. var prevSlide = activeSlide.prev('.' + s.params.slideClass).addClass(s.params.slidePrevClass);
  887. if (s.params.loop && prevSlide.length === 0) {
  888. s.slides.eq(-1).addClass(s.params.slidePrevClass);
  889. }
  890. // Pagination
  891. if (s.paginationContainer && s.paginationContainer.length > 0) {
  892. // Current/Total
  893. var current,
  894. total = s.params.loop ? Math.ceil((s.slides.length - s.loopedSlides * 2) / s.params.slidesPerGroup) : s.snapGrid.length;
  895. if (s.params.loop) {
  896. current = Math.ceil((s.activeIndex - s.loopedSlides)/s.params.slidesPerGroup);
  897. if (current > s.slides.length - 1 - s.loopedSlides * 2) {
  898. current = current - (s.slides.length - s.loopedSlides * 2);
  899. }
  900. if (current > total - 1) current = current - total;
  901. if (current < 0 && s.params.paginationType !== 'bullets') current = total + current;
  902. }
  903. else {
  904. if (typeof s.snapIndex !== 'undefined') {
  905. current = s.snapIndex;
  906. }
  907. else {
  908. current = s.activeIndex || 0;
  909. }
  910. }
  911. // Types
  912. if (s.params.paginationType === 'bullets' && s.bullets && s.bullets.length > 0) {
  913. s.bullets.removeClass(s.params.bulletActiveClass);
  914. if (s.paginationContainer.length > 1) {
  915. s.bullets.each(function () {
  916. if ($(this).index() === current) $(this).addClass(s.params.bulletActiveClass);
  917. });
  918. }
  919. else {
  920. s.bullets.eq(current).addClass(s.params.bulletActiveClass);
  921. }
  922. }
  923. if (s.params.paginationType === 'fraction') {
  924. s.paginationContainer.find('.' + s.params.paginationCurrentClass).text(current + 1);
  925. s.paginationContainer.find('.' + s.params.paginationTotalClass).text(total);
  926. }
  927. if (s.params.paginationType === 'progress') {
  928. var scale = (current + 1) / total,
  929. scaleX = scale,
  930. scaleY = 1;
  931. if (!s.isHorizontal()) {
  932. scaleY = scale;
  933. scaleX = 1;
  934. }
  935. s.paginationContainer.find('.' + s.params.paginationProgressbarClass).transform('translate3d(0,0,0) scaleX(' + scaleX + ') scaleY(' + scaleY + ')').transition(s.params.speed);
  936. }
  937. if (s.params.paginationType === 'custom' && s.params.paginationCustomRender) {
  938. s.paginationContainer.html(s.params.paginationCustomRender(s, current + 1, total));
  939. s.emit('onPaginationRendered', s, s.paginationContainer[0]);
  940. }
  941. }
  942. // Next/active buttons
  943. if (!s.params.loop) {
  944. if (s.params.prevButton && s.prevButton && s.prevButton.length > 0) {
  945. if (s.isBeginning) {
  946. s.prevButton.addClass(s.params.buttonDisabledClass);
  947. if (s.params.a11y && s.a11y) s.a11y.disable(s.prevButton);
  948. }
  949. else {
  950. s.prevButton.removeClass(s.params.buttonDisabledClass);
  951. if (s.params.a11y && s.a11y) s.a11y.enable(s.prevButton);
  952. }
  953. }
  954. if (s.params.nextButton && s.nextButton && s.nextButton.length > 0) {
  955. if (s.isEnd) {
  956. s.nextButton.addClass(s.params.buttonDisabledClass);
  957. if (s.params.a11y && s.a11y) s.a11y.disable(s.nextButton);
  958. }
  959. else {
  960. s.nextButton.removeClass(s.params.buttonDisabledClass);
  961. if (s.params.a11y && s.a11y) s.a11y.enable(s.nextButton);
  962. }
  963. }
  964. }
  965. };
  966. /*=========================
  967. Pagination
  968. ===========================*/
  969. s.updatePagination = function () {
  970. if (!s.params.pagination) return;
  971. if (s.paginationContainer && s.paginationContainer.length > 0) {
  972. var paginationHTML = '';
  973. if (s.params.paginationType === 'bullets') {
  974. var numberOfBullets = s.params.loop ? Math.ceil((s.slides.length - s.loopedSlides * 2) / s.params.slidesPerGroup) : s.snapGrid.length;
  975. for (var i = 0; i < numberOfBullets; i++) {
  976. if (s.params.paginationBulletRender) {
  977. paginationHTML += s.params.paginationBulletRender(i, s.params.bulletClass);
  978. }
  979. else {
  980. paginationHTML += '<' + s.params.paginationElement+' class="' + s.params.bulletClass + '"></' + s.params.paginationElement + '>';
  981. }
  982. }
  983. s.paginationContainer.html(paginationHTML);
  984. s.bullets = s.paginationContainer.find('.' + s.params.bulletClass);
  985. if (s.params.paginationClickable && s.params.a11y && s.a11y) {
  986. s.a11y.initPagination();
  987. }
  988. }
  989. if (s.params.paginationType === 'fraction') {
  990. if (s.params.paginationFractionRender) {
  991. paginationHTML = s.params.paginationFractionRender(s, s.params.paginationCurrentClass, s.params.paginationTotalClass);
  992. }
  993. else {
  994. paginationHTML =
  995. '<span class="' + s.params.paginationCurrentClass + '"></span>' +
  996. ' / ' +
  997. '<span class="' + s.params.paginationTotalClass+'"></span>';
  998. }
  999. s.paginationContainer.html(paginationHTML);
  1000. }
  1001. if (s.params.paginationType === 'progress') {
  1002. if (s.params.paginationProgressRender) {
  1003. paginationHTML = s.params.paginationProgressRender(s, s.params.paginationProgressbarClass);
  1004. }
  1005. else {
  1006. paginationHTML = '<span class="' + s.params.paginationProgressbarClass + '"></span>';
  1007. }
  1008. s.paginationContainer.html(paginationHTML);
  1009. }
  1010. if (s.params.paginationType !== 'custom') {
  1011. s.emit('onPaginationRendered', s, s.paginationContainer[0]);
  1012. }
  1013. }
  1014. };
  1015. /*=========================
  1016. Common update method
  1017. ===========================*/
  1018. s.update = function (updateTranslate) {
  1019. s.updateContainerSize();
  1020. s.updateSlidesSize();
  1021. s.updateProgress();
  1022. s.updatePagination();
  1023. s.updateClasses();
  1024. if (s.params.scrollbar && s.scrollbar) {
  1025. s.scrollbar.set();
  1026. }
  1027. function forceSetTranslate() {
  1028. newTranslate = Math.min(Math.max(s.translate, s.maxTranslate()), s.minTranslate());
  1029. s.setWrapperTranslate(newTranslate);
  1030. s.updateActiveIndex();
  1031. s.updateClasses();
  1032. }
  1033. if (updateTranslate) {
  1034. var translated, newTranslate;
  1035. if (s.controller && s.controller.spline) {
  1036. s.controller.spline = undefined;
  1037. }
  1038. if (s.params.freeMode) {
  1039. forceSetTranslate();
  1040. if (s.params.autoHeight) {
  1041. s.updateAutoHeight();
  1042. }
  1043. }
  1044. else {
  1045. if ((s.params.slidesPerView === 'auto' || s.params.slidesPerView > 1) && s.isEnd && !s.params.centeredSlides) {
  1046. translated = s.slideTo(s.slides.length - 1, 0, false, true);
  1047. }
  1048. else {
  1049. translated = s.slideTo(s.activeIndex, 0, false, true);
  1050. }
  1051. if (!translated) {
  1052. forceSetTranslate();
  1053. }
  1054. }
  1055. }
  1056. else if (s.params.autoHeight) {
  1057. s.updateAutoHeight();
  1058. }
  1059. };
  1060. /*=========================
  1061. Resize Handler
  1062. ===========================*/
  1063. s.onResize = function (forceUpdatePagination) {
  1064. //Breakpoints
  1065. if (s.params.breakpoints) {
  1066. s.setBreakpoint();
  1067. }
  1068. // Disable locks on resize
  1069. var allowSwipeToPrev = s.params.allowSwipeToPrev;
  1070. var allowSwipeToNext = s.params.allowSwipeToNext;
  1071. s.params.allowSwipeToPrev = s.params.allowSwipeToNext = true;
  1072. s.updateContainerSize();
  1073. s.updateSlidesSize();
  1074. if (s.params.slidesPerView === 'auto' || s.params.freeMode || forceUpdatePagination) s.updatePagination();
  1075. if (s.params.scrollbar && s.scrollbar) {
  1076. s.scrollbar.set();
  1077. }
  1078. if (s.controller && s.controller.spline) {
  1079. s.controller.spline = undefined;
  1080. }
  1081. var slideChangedBySlideTo = false;
  1082. if (s.params.freeMode) {
  1083. var newTranslate = Math.min(Math.max(s.translate, s.maxTranslate()), s.minTranslate());
  1084. s.setWrapperTranslate(newTranslate);
  1085. s.updateActiveIndex();
  1086. s.updateClasses();
  1087. if (s.params.autoHeight) {
  1088. s.updateAutoHeight();
  1089. }
  1090. }
  1091. else {
  1092. s.updateClasses();
  1093. if ((s.params.slidesPerView === 'auto' || s.params.slidesPerView > 1) && s.isEnd && !s.params.centeredSlides) {
  1094. slideChangedBySlideTo = s.slideTo(s.slides.length - 1, 0, false, true);
  1095. }
  1096. else {
  1097. slideChangedBySlideTo = s.slideTo(s.activeIndex, 0, false, true);
  1098. }
  1099. }
  1100. if (s.params.lazyLoading && !slideChangedBySlideTo && s.lazy) {
  1101. s.lazy.load();
  1102. }
  1103. // Return locks after resize
  1104. s.params.allowSwipeToPrev = allowSwipeToPrev;
  1105. s.params.allowSwipeToNext = allowSwipeToNext;
  1106. };
  1107. /*=========================
  1108. Events
  1109. ===========================*/
  1110. //Define Touch Events
  1111. var desktopEvents = ['mousedown', 'mousemove', 'mouseup'];
  1112. if (window.navigator.pointerEnabled) desktopEvents = ['pointerdown', 'pointermove', 'pointerup'];
  1113. else if (window.navigator.msPointerEnabled) desktopEvents = ['MSPointerDown', 'MSPointerMove', 'MSPointerUp'];
  1114. s.touchEvents = {
  1115. start : s.support.touch || !s.params.simulateTouch ? 'touchstart' : desktopEvents[0],
  1116. move : s.support.touch || !s.params.simulateTouch ? 'touchmove' : desktopEvents[1],
  1117. end : s.support.touch || !s.params.simulateTouch ? 'touchend' : desktopEvents[2]
  1118. };
  1119. // WP8 Touch Events Fix
  1120. if (window.navigator.pointerEnabled || window.navigator.msPointerEnabled) {
  1121. (s.params.touchEventsTarget === 'container' ? s.container : s.wrapper).addClass('swiper-wp8-' + s.params.direction);
  1122. }
  1123. // Attach/detach events
  1124. s.initEvents = function (detach) {
  1125. var actionDom = detach ? 'off' : 'on';
  1126. var action = detach ? 'removeEventListener' : 'addEventListener';
  1127. var touchEventsTarget = s.params.touchEventsTarget === 'container' ? s.container[0] : s.wrapper[0];
  1128. var target = s.support.touch ? touchEventsTarget : document;
  1129. var moveCapture = s.params.nested ? true : false;
  1130. //Touch Events
  1131. if (s.browser.ie) {
  1132. touchEventsTarget[action](s.touchEvents.start, s.onTouchStart, false);
  1133. target[action](s.touchEvents.move, s.onTouchMove, moveCapture);
  1134. target[action](s.touchEvents.end, s.onTouchEnd, false);
  1135. }
  1136. else {
  1137. if (s.support.touch) {
  1138. touchEventsTarget[action](s.touchEvents.start, s.onTouchStart, false);
  1139. touchEventsTarget[action](s.touchEvents.move, s.onTouchMove, moveCapture);
  1140. touchEventsTarget[action](s.touchEvents.end, s.onTouchEnd, false);
  1141. }
  1142. if (params.simulateTouch && !s.device.ios && !s.device.android) {
  1143. touchEventsTarget[action]('mousedown', s.onTouchStart, false);
  1144. document[action]('mousemove', s.onTouchMove, moveCapture);
  1145. document[action]('mouseup', s.onTouchEnd, false);
  1146. }
  1147. }
  1148. window[action]('resize', s.onResize);
  1149. // Next, Prev, Index
  1150. if (s.params.nextButton && s.nextButton && s.nextButton.length > 0) {
  1151. s.nextButton[actionDom]('click', s.onClickNext);
  1152. if (s.params.a11y && s.a11y) s.nextButton[actionDom]('keydown', s.a11y.onEnterKey);
  1153. }
  1154. if (s.params.prevButton && s.prevButton && s.prevButton.length > 0) {
  1155. s.prevButton[actionDom]('click', s.onClickPrev);
  1156. if (s.params.a11y && s.a11y) s.prevButton[actionDom]('keydown', s.a11y.onEnterKey);
  1157. }
  1158. if (s.params.pagination && s.params.paginationClickable) {
  1159. s.paginationContainer[actionDom]('click', '.' + s.params.bulletClass, s.onClickIndex);
  1160. if (s.params.a11y && s.a11y) s.paginationContainer[actionDom]('keydown', '.' + s.params.bulletClass, s.a11y.onEnterKey);
  1161. }
  1162. // Prevent Links Clicks
  1163. if (s.params.preventClicks || s.params.preventClicksPropagation) touchEventsTarget[action]('click', s.preventClicks, true);
  1164. };
  1165. s.attachEvents = function () {
  1166. s.initEvents();
  1167. };
  1168. s.detachEvents = function () {
  1169. s.initEvents(true);
  1170. };
  1171. /*=========================
  1172. Handle Clicks
  1173. ===========================*/
  1174. // Prevent Clicks
  1175. s.allowClick = true;
  1176. s.preventClicks = function (e) {
  1177. if (!s.allowClick) {
  1178. if (s.params.preventClicks) e.preventDefault();
  1179. if (s.params.preventClicksPropagation && s.animating) {
  1180. e.stopPropagation();
  1181. e.stopImmediatePropagation();
  1182. }
  1183. }
  1184. };
  1185. // Clicks
  1186. s.onClickNext = function (e) {
  1187. e.preventDefault();
  1188. if (s.isEnd && !s.params.loop) return;
  1189. s.slideNext();
  1190. };
  1191. s.onClickPrev = function (e) {
  1192. e.preventDefault();
  1193. if (s.isBeginning && !s.params.loop) return;
  1194. s.slidePrev();
  1195. };
  1196. s.onClickIndex = function (e) {
  1197. e.preventDefault();
  1198. var index = $(this).index() * s.params.slidesPerGroup;
  1199. if (s.params.loop) index = index + s.loopedSlides;
  1200. s.slideTo(index);
  1201. };
  1202. /*=========================
  1203. Handle Touches
  1204. ===========================*/
  1205. function findElementInEvent(e, selector) {
  1206. var el = $(e.target);
  1207. if (!el.is(selector)) {
  1208. if (typeof selector === 'string') {
  1209. el = el.parents(selector);
  1210. }
  1211. else if (selector.nodeType) {
  1212. var found;
  1213. el.parents().each(function (index, _el) {
  1214. if (_el === selector) found = selector;
  1215. });
  1216. if (!found) return undefined;
  1217. else return selector;
  1218. }
  1219. }
  1220. if (el.length === 0) {
  1221. return undefined;
  1222. }
  1223. return el[0];
  1224. }
  1225. s.updateClickedSlide = function (e) {
  1226. var slide = findElementInEvent(e, '.' + s.params.slideClass);
  1227. var slideFound = false;
  1228. if (slide) {
  1229. for (var i = 0; i < s.slides.length; i++) {
  1230. if (s.slides[i] === slide) slideFound = true;
  1231. }
  1232. }
  1233. if (slide && slideFound) {
  1234. s.clickedSlide = slide;
  1235. s.clickedIndex = $(slide).index();
  1236. }
  1237. else {
  1238. s.clickedSlide = undefined;
  1239. s.clickedIndex = undefined;
  1240. return;
  1241. }
  1242. if (s.params.slideToClickedSlide && s.clickedIndex !== undefined && s.clickedIndex !== s.activeIndex) {
  1243. var slideToIndex = s.clickedIndex,
  1244. realIndex,
  1245. duplicatedSlides;
  1246. if (s.params.loop) {
  1247. if (s.animating) return;
  1248. realIndex = $(s.clickedSlide).attr('data-swiper-slide-index');
  1249. if (s.params.centeredSlides) {
  1250. if ((slideToIndex < s.loopedSlides - s.params.slidesPerView/2) || (slideToIndex > s.slides.length - s.loopedSlides + s.params.slidesPerView/2)) {
  1251. s.fixLoop();
  1252. slideToIndex = s.wrapper.children('.' + s.params.slideClass + '[data-swiper-slide-index="' + realIndex + '"]:not(.swiper-slide-duplicate)').eq(0).index();
  1253. setTimeout(function () {
  1254. s.slideTo(slideToIndex);
  1255. }, 0);
  1256. }
  1257. else {
  1258. s.slideTo(slideToIndex);
  1259. }
  1260. }
  1261. else {
  1262. if (slideToIndex > s.slides.length - s.params.slidesPerView) {
  1263. s.fixLoop();
  1264. slideToIndex = s.wrapper.children('.' + s.params.slideClass + '[data-swiper-slide-index="' + realIndex + '"]:not(.swiper-slide-duplicate)').eq(0).index();
  1265. setTimeout(function () {
  1266. s.slideTo(slideToIndex);
  1267. }, 0);
  1268. }
  1269. else {
  1270. s.slideTo(slideToIndex);
  1271. }
  1272. }
  1273. }
  1274. else {
  1275. s.slideTo(slideToIndex);
  1276. }
  1277. }
  1278. };
  1279. var isTouched,
  1280. isMoved,
  1281. allowTouchCallbacks,
  1282. touchStartTime,
  1283. isScrolling,
  1284. currentTranslate,
  1285. startTranslate,
  1286. allowThresholdMove,
  1287. // Form elements to match
  1288. formElements = 'input, select, textarea, button',
  1289. // Last click time
  1290. lastClickTime = Date.now(), clickTimeout,
  1291. //Velocities
  1292. velocities = [],
  1293. allowMomentumBounce;
  1294. // Animating Flag
  1295. s.animating = false;
  1296. // Touches information
  1297. s.touches = {
  1298. startX: 0,
  1299. startY: 0,
  1300. currentX: 0,
  1301. currentY: 0,
  1302. diff: 0
  1303. };
  1304. // Touch handlers
  1305. var isTouchEvent, startMoving;
  1306. s.onTouchStart = function (e) {
  1307. if (e.originalEvent) e = e.originalEvent;
  1308. isTouchEvent = e.type === 'touchstart';
  1309. if (!isTouchEvent && 'which' in e && e.which === 3) return;
  1310. if (s.params.noSwiping && findElementInEvent(e, '.' + s.params.noSwipingClass)) {
  1311. s.allowClick = true;
  1312. return;
  1313. }
  1314. if (s.params.swipeHandler) {
  1315. if (!findElementInEvent(e, s.params.swipeHandler)) return;
  1316. }
  1317. var startX = s.touches.currentX = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX;
  1318. var startY = s.touches.currentY = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY;
  1319. // Do NOT start if iOS edge swipe is detected. Otherwise iOS app (UIWebView) cannot swipe-to-go-back anymore
  1320. if(s.device.ios && s.params.iOSEdgeSwipeDetection && startX <= s.params.iOSEdgeSwipeThreshold) {
  1321. return;
  1322. }
  1323. isTouched = true;
  1324. isMoved = false;
  1325. allowTouchCallbacks = true;
  1326. isScrolling = undefined;
  1327. startMoving = undefined;
  1328. s.touches.startX = startX;
  1329. s.touches.startY = startY;
  1330. touchStartTime = Date.now();
  1331. s.allowClick = true;
  1332. s.updateContainerSize();
  1333. s.swipeDirection = undefined;
  1334. if (s.params.threshold > 0) allowThresholdMove = false;
  1335. if (e.type !== 'touchstart') {
  1336. var preventDefault = true;
  1337. if ($(e.target).is(formElements)) preventDefault = false;
  1338. if (document.activeElement && $(document.activeElement).is(formElements)) {
  1339. document.activeElement.blur();
  1340. }
  1341. if (preventDefault) {
  1342. e.preventDefault();
  1343. }
  1344. }
  1345. s.emit('onTouchStart', s, e);
  1346. };
  1347. s.onTouchMove = function (e) {
  1348. if (e.originalEvent) e = e.originalEvent;
  1349. if (isTouchEvent && e.type === 'mousemove') return;
  1350. if (e.preventedByNestedSwiper) {
  1351. s.touches.startX = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX;
  1352. s.touches.startY = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY;
  1353. return;
  1354. }
  1355. if (s.params.onlyExternal) {
  1356. // isMoved = true;
  1357. s.allowClick = false;
  1358. if (isTouched) {
  1359. s.touches.startX = s.touches.currentX = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX;
  1360. s.touches.startY = s.touches.currentY = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY;
  1361. touchStartTime = Date.now();
  1362. }
  1363. return;
  1364. }
  1365. if (isTouchEvent && document.activeElement) {
  1366. if (e.target === document.activeElement && $(e.target).is(formElements)) {
  1367. isMoved = true;
  1368. s.allowClick = false;
  1369. return;
  1370. }
  1371. }
  1372. if (allowTouchCallbacks) {
  1373. s.emit('onTouchMove', s, e);
  1374. }
  1375. if (e.targetTouches && e.targetTouches.length > 1) return;
  1376. s.touches.currentX = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX;
  1377. s.touches.currentY = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY;
  1378. if (typeof isScrolling === 'undefined') {
  1379. var touchAngle = Math.atan2(Math.abs(s.touches.currentY - s.touches.startY), Math.abs(s.touches.currentX - s.touches.startX)) * 180 / Math.PI;
  1380. isScrolling = s.isHorizontal() ? touchAngle > s.params.touchAngle : (90 - touchAngle > s.params.touchAngle);
  1381. }
  1382. if (isScrolling) {
  1383. s.emit('onTouchMoveOpposite', s, e);
  1384. }
  1385. if (typeof startMoving === 'undefined' && s.browser.ieTouch) {
  1386. if (s.touches.currentX !== s.touches.startX || s.touches.currentY !== s.touches.startY) {
  1387. startMoving = true;
  1388. }
  1389. }
  1390. if (!isTouched) return;
  1391. if (isScrolling) {
  1392. isTouched = false;
  1393. return;
  1394. }
  1395. if (!startMoving && s.browser.ieTouch) {
  1396. return;
  1397. }
  1398. s.allowClick = false;
  1399. s.emit('onSliderMove', s, e);
  1400. e.preventDefault();
  1401. if (s.params.touchMoveStopPropagation && !s.params.nested) {
  1402. e.stopPropagation();
  1403. }
  1404. if (!isMoved) {
  1405. if (params.loop) {
  1406. s.fixLoop();
  1407. }
  1408. startTranslate = s.getWrapperTranslate();
  1409. s.setWrapperTransition(0);
  1410. if (s.animating) {
  1411. s.wrapper.trigger('webkitTransitionEnd transitionend oTransitionEnd MSTransitionEnd msTransitionEnd');
  1412. }
  1413. if (s.params.autoplay && s.autoplaying) {
  1414. if (s.params.autoplayDisableOnInteraction) {
  1415. s.stopAutoplay();
  1416. }
  1417. else {
  1418. s.pauseAutoplay();
  1419. }
  1420. }
  1421. allowMomentumBounce = false;
  1422. //Grab Cursor
  1423. if (s.params.grabCursor) {
  1424. s.container[0].style.cursor = 'move';
  1425. s.container[0].style.cursor = '-webkit-grabbing';
  1426. s.container[0].style.cursor = '-moz-grabbin';
  1427. s.container[0].style.cursor = 'grabbing';
  1428. }
  1429. }
  1430. isMoved = true;
  1431. var diff = s.touches.diff = s.isHorizontal() ? s.touches.currentX - s.touches.startX : s.touches.currentY - s.touches.startY;
  1432. diff = diff * s.params.touchRatio;
  1433. if (s.rtl) diff = -diff;
  1434. s.swipeDirection = diff > 0 ? 'prev' : 'next';
  1435. currentTranslate = diff + startTranslate;
  1436. var disableParentSwiper = true;
  1437. if ((diff > 0 && currentTranslate > s.minTranslate())) {
  1438. disableParentSwiper = false;
  1439. if (s.params.resistance) currentTranslate = s.minTranslate() - 1 + Math.pow(-s.minTranslate() + startTranslate + diff, s.params.resistanceRatio);
  1440. }
  1441. else if (diff < 0 && currentTranslate < s.maxTranslate()) {
  1442. disableParentSwiper = false;
  1443. if (s.params.resistance) currentTranslate = s.maxTranslate() + 1 - Math.pow(s.maxTranslate() - startTranslate - diff, s.params.resistanceRatio);
  1444. }
  1445. if (disableParentSwiper) {
  1446. e.preventedByNestedSwiper = true;
  1447. }
  1448. // Directions locks
  1449. if (!s.params.allowSwipeToNext && s.swipeDirection === 'next' && currentTranslate < startTranslate) {
  1450. currentTranslate = startTranslate;
  1451. }
  1452. if (!s.params.allowSwipeToPrev && s.swipeDirection === 'prev' && currentTranslate > startTranslate) {
  1453. currentTranslate = startTranslate;
  1454. }
  1455. if (!s.params.followFinger) return;
  1456. // Threshold
  1457. if (s.params.threshold > 0) {
  1458. if (Math.abs(diff) > s.params.threshold || allowThresholdMove) {
  1459. if (!allowThresholdMove) {
  1460. allowThresholdMove = true;
  1461. s.touches.startX = s.touches.currentX;
  1462. s.touches.startY = s.touches.currentY;
  1463. currentTranslate = startTranslate;
  1464. s.touches.diff = s.isHorizontal() ? s.touches.currentX - s.touches.startX : s.touches.currentY - s.touches.startY;
  1465. return;
  1466. }
  1467. }
  1468. else {
  1469. currentTranslate = startTranslate;
  1470. return;
  1471. }
  1472. }
  1473. // Update active index in free mode
  1474. if (s.params.freeMode || s.params.watchSlidesProgress) {
  1475. s.updateActiveIndex();
  1476. }
  1477. if (s.params.freeMode) {
  1478. //Velocity
  1479. if (velocities.length === 0) {
  1480. velocities.push({
  1481. position: s.touches[s.isHorizontal() ? 'startX' : 'startY'],
  1482. time: touchStartTime
  1483. });
  1484. }
  1485. velocities.push({
  1486. position: s.touches[s.isHorizontal() ? 'currentX' : 'currentY'],
  1487. time: (new window.Date()).getTime()
  1488. });
  1489. }
  1490. // Update progress
  1491. s.updateProgress(currentTranslate);
  1492. // Update translate
  1493. s.setWrapperTranslate(currentTranslate);
  1494. };
  1495. s.onTouchEnd = function (e) {
  1496. if (e.originalEvent) e = e.originalEvent;
  1497. if (allowTouchCallbacks) {
  1498. s.emit('onTouchEnd', s, e);
  1499. }
  1500. allowTouchCallbacks = false;
  1501. if (!isTouched) return;
  1502. //Return Grab Cursor
  1503. if (s.params.grabCursor && isMoved && isTouched) {
  1504. s.container[0].style.cursor = 'move';
  1505. s.container[0].style.cursor = '-webkit-grab';
  1506. s.container[0].style.cursor = '-moz-grab';
  1507. s.container[0].style.cursor = 'grab';
  1508. }
  1509. // Time diff
  1510. var touchEndTime = Date.now();
  1511. var timeDiff = touchEndTime - touchStartTime;
  1512. // Tap, doubleTap, Click
  1513. if (s.allowClick) {
  1514. s.updateClickedSlide(e);
  1515. s.emit('onTap', s, e);
  1516. if (timeDiff < 300 && (touchEndTime - lastClickTime) > 300) {
  1517. if (clickTimeout) clearTimeout(clickTimeout);
  1518. clickTimeout = setTimeout(function () {
  1519. if (!s) return;
  1520. if (s.params.paginationHide && s.paginationContainer.length > 0 && !$(e.target).hasClass(s.params.bulletClass)) {
  1521. s.paginationContainer.toggleClass(s.params.paginationHiddenClass);
  1522. }
  1523. s.emit('onClick', s, e);
  1524. }, 300);
  1525. }
  1526. if (timeDiff < 300 && (touchEndTime - lastClickTime) < 300) {
  1527. if (clickTimeout) clearTimeout(clickTimeout);
  1528. s.emit('onDoubleTap', s, e);
  1529. }
  1530. }
  1531. lastClickTime = Date.now();
  1532. setTimeout(function () {
  1533. if (s) s.allowClick = true;
  1534. }, 0);
  1535. if (!isTouched || !isMoved || !s.swipeDirection || s.touches.diff === 0 || currentTranslate === startTranslate) {
  1536. isTouched = isMoved = false;
  1537. return;
  1538. }
  1539. isTouched = isMoved = false;
  1540. var currentPos;
  1541. if (s.params.followFinger) {
  1542. currentPos = s.rtl ? s.translate : -s.translate;
  1543. }
  1544. else {
  1545. currentPos = -currentTranslate;
  1546. }
  1547. if (s.params.freeMode) {
  1548. if (currentPos < -s.minTranslate()) {
  1549. s.slideTo(s.activeIndex);
  1550. return;
  1551. }
  1552. else if (currentPos > -s.maxTranslate()) {
  1553. if (s.slides.length < s.snapGrid.length) {
  1554. s.slideTo(s.snapGrid.length - 1);
  1555. }
  1556. else {
  1557. s.slideTo(s.slides.length - 1);
  1558. }
  1559. return;
  1560. }
  1561. if (s.params.freeModeMomentum) {
  1562. if (velocities.length > 1) {
  1563. var lastMoveEvent = velocities.pop(), velocityEvent = velocities.pop();
  1564. var distance = lastMoveEvent.position - velocityEvent.position;
  1565. var time = lastMoveEvent.time - velocityEvent.time;
  1566. s.velocity = distance / time;
  1567. s.velocity = s.velocity / 2;
  1568. if (Math.abs(s.velocity) < s.params.freeModeMinimumVelocity) {
  1569. s.velocity = 0;
  1570. }
  1571. // this implies that the user stopped moving a finger then released.
  1572. // There would be no events with distance zero, so the last event is stale.
  1573. if (time > 150 || (new window.Date().getTime() - lastMoveEvent.time) > 300) {
  1574. s.velocity = 0;
  1575. }
  1576. } else {
  1577. s.velocity = 0;
  1578. }
  1579. velocities.length = 0;
  1580. var momentumDuration = 1000 * s.params.freeModeMomentumRatio;
  1581. var momentumDistance = s.velocity * momentumDuration;
  1582. var newPosition = s.translate + momentumDistance;
  1583. if (s.rtl) newPosition = - newPosition;
  1584. var doBounce = false;
  1585. var afterBouncePosition;
  1586. var bounceAmount = Math.abs(s.velocity) * 20 * s.params.freeModeMomentumBounceRatio;
  1587. if (newPosition < s.maxTranslate()) {
  1588. if (s.params.freeModeMomentumBounce) {
  1589. if (newPosition + s.maxTranslate() < -bounceAmount) {
  1590. newPosition = s.maxTranslate() - bounceAmount;
  1591. }
  1592. afterBouncePosition = s.maxTranslate();
  1593. doBounce = true;
  1594. allowMomentumBounce = true;
  1595. }
  1596. else {
  1597. newPosition = s.maxTranslate();
  1598. }
  1599. }
  1600. else if (newPosition > s.minTranslate()) {
  1601. if (s.params.freeModeMomentumBounce) {
  1602. if (newPosition - s.minTranslate() > bounceAmount) {
  1603. newPosition = s.minTranslate() + bounceAmount;
  1604. }
  1605. afterBouncePosition = s.minTranslate();
  1606. doBounce = true;
  1607. allowMomentumBounce = true;
  1608. }
  1609. else {
  1610. newPosition = s.minTranslate();
  1611. }
  1612. }
  1613. else if (s.params.freeModeSticky) {
  1614. var j = 0,
  1615. nextSlide;
  1616. for (j = 0; j < s.snapGrid.length; j += 1) {
  1617. if (s.snapGrid[j] > -newPosition) {
  1618. nextSlide = j;
  1619. break;
  1620. }
  1621. }
  1622. if (Math.abs(s.snapGrid[nextSlide] - newPosition) < Math.abs(s.snapGrid[nextSlide - 1] - newPosition) || s.swipeDirection === 'next') {
  1623. newPosition = s.snapGrid[nextSlide];
  1624. } else {
  1625. newPosition = s.snapGrid[nextSlide - 1];
  1626. }
  1627. if (!s.rtl) newPosition = - newPosition;
  1628. }
  1629. //Fix duration
  1630. if (s.velocity !== 0) {
  1631. if (s.rtl) {
  1632. momentumDuration = Math.abs((-newPosition - s.translate) / s.velocity);
  1633. }
  1634. else {
  1635. momentumDuration = Math.abs((newPosition - s.translate) / s.velocity);
  1636. }
  1637. }
  1638. else if (s.params.freeModeSticky) {
  1639. s.slideReset();
  1640. return;
  1641. }
  1642. if (s.params.freeModeMomentumBounce && doBounce) {
  1643. s.updateProgress(afterBouncePosition);
  1644. s.setWrapperTransition(momentumDuration);
  1645. s.setWrapperTranslate(newPosition);
  1646. s.onTransitionStart();
  1647. s.animating = true;
  1648. s.wrapper.transitionEnd(function () {
  1649. if (!s || !allowMomentumBounce) return;
  1650. s.emit('onMomentumBounce', s);
  1651. s.setWrapperTransition(s.params.speed);
  1652. s.setWrapperTranslate(afterBouncePosition);
  1653. s.wrapper.transitionEnd(function () {
  1654. if (!s) return;
  1655. s.onTransitionEnd();
  1656. });
  1657. });
  1658. } else if (s.velocity) {
  1659. s.updateProgress(newPosition);
  1660. s.setWrapperTransition(momentumDuration);
  1661. s.setWrapperTranslate(newPosition);
  1662. s.onTransitionStart();
  1663. if (!s.animating) {
  1664. s.animating = true;
  1665. s.wrapper.transitionEnd(function () {
  1666. if (!s) return;
  1667. s.onTransitionEnd();
  1668. });
  1669. }
  1670. } else {
  1671. s.updateProgress(newPosition);
  1672. }
  1673. s.updateActiveIndex();
  1674. }
  1675. if (!s.params.freeModeMomentum || timeDiff >= s.params.longSwipesMs) {
  1676. s.updateProgress();
  1677. s.updateActiveIndex();
  1678. }
  1679. return;
  1680. }
  1681. // Find current slide
  1682. var i, stopIndex = 0, groupSize = s.slidesSizesGrid[0];
  1683. for (i = 0; i < s.slidesGrid.length; i += s.params.slidesPerGroup) {
  1684. if (typeof s.slidesGrid[i + s.params.slidesPerGroup] !== 'undefined') {
  1685. if (currentPos >= s.slidesGrid[i] && currentPos < s.slidesGrid[i + s.params.slidesPerGroup]) {
  1686. stopIndex = i;
  1687. groupSize = s.slidesGrid[i + s.params.slidesPerGroup] - s.slidesGrid[i];
  1688. }
  1689. }
  1690. else {
  1691. if (currentPos >= s.slidesGrid[i]) {
  1692. stopIndex = i;
  1693. groupSize = s.slidesGrid[s.slidesGrid.length - 1] - s.slidesGrid[s.slidesGrid.length - 2];
  1694. }
  1695. }
  1696. }
  1697. // Find current slide size
  1698. var ratio = (currentPos - s.slidesGrid[stopIndex]) / groupSize;
  1699. if (timeDiff > s.params.longSwipesMs) {
  1700. // Long touches
  1701. if (!s.params.longSwipes) {
  1702. s.slideTo(s.activeIndex);
  1703. return;
  1704. }
  1705. if (s.swipeDirection === 'next') {
  1706. if (ratio >= s.params.longSwipesRatio) s.slideTo(stopIndex + s.params.slidesPerGroup);
  1707. else s.slideTo(stopIndex);
  1708. }
  1709. if (s.swipeDirection === 'prev') {
  1710. if (ratio > (1 - s.params.longSwipesRatio)) s.slideTo(stopIndex + s.params.slidesPerGroup);
  1711. else s.slideTo(stopIndex);
  1712. }
  1713. }
  1714. else {
  1715. // Short swipes
  1716. if (!s.params.shortSwipes) {
  1717. s.slideTo(s.activeIndex);
  1718. return;
  1719. }
  1720. if (s.swipeDirection === 'next') {
  1721. s.slideTo(stopIndex + s.params.slidesPerGroup);
  1722. }
  1723. if (s.swipeDirection === 'prev') {
  1724. s.slideTo(stopIndex);
  1725. }
  1726. }
  1727. };
  1728. /*=========================
  1729. Transitions
  1730. ===========================*/
  1731. s._slideTo = function (slideIndex, speed) {
  1732. return s.slideTo(slideIndex, speed, true, true);
  1733. };
  1734. s.slideTo = function (slideIndex, speed, runCallbacks, internal) {
  1735. if (typeof runCallbacks === 'undefined') runCallbacks = true;
  1736. if (typeof slideIndex === 'undefined') slideIndex = 0;
  1737. if (slideIndex < 0) slideIndex = 0;
  1738. s.snapIndex = Math.floor(slideIndex / s.params.slidesPerGroup);
  1739. if (s.snapIndex >= s.snapGrid.length) s.snapIndex = s.snapGrid.length - 1;
  1740. var translate = - s.snapGrid[s.snapIndex];
  1741. // Stop autoplay
  1742. if (s.params.autoplay && s.autoplaying) {
  1743. if (internal || !s.params.autoplayDisableOnInteraction) {
  1744. s.pauseAutoplay(speed);
  1745. }
  1746. else {
  1747. s.stopAutoplay();
  1748. }
  1749. }
  1750. // Update progress
  1751. s.updateProgress(translate);
  1752. // Normalize slideIndex
  1753. for (var i = 0; i < s.slidesGrid.length; i++) {
  1754. if (- Math.floor(translate * 100) >= Math.floor(s.slidesGrid[i] * 100)) {
  1755. slideIndex = i;
  1756. }
  1757. }
  1758. // Directions locks
  1759. if (!s.params.allowSwipeToNext && translate < s.translate && translate < s.minTranslate()) {
  1760. return false;
  1761. }
  1762. if (!s.params.allowSwipeToPrev && translate > s.translate && translate > s.maxTranslate()) {
  1763. if ((s.activeIndex || 0) !== slideIndex ) return false;
  1764. }
  1765. // Update Index
  1766. if (typeof speed === 'undefined') speed = s.params.speed;
  1767. s.previousIndex = s.activeIndex || 0;
  1768. s.activeIndex = slideIndex;
  1769. if ((s.rtl && -translate === s.translate) || (!s.rtl && translate === s.translate)) {
  1770. // Update Height
  1771. if (s.params.autoHeight) {
  1772. s.updateAutoHeight();
  1773. }
  1774. s.updateClasses();
  1775. if (s.params.effect !== 'slide') {
  1776. s.setWrapperTranslate(translate);
  1777. }
  1778. return false;
  1779. }
  1780. s.updateClasses();
  1781. s.onTransitionStart(runCallbacks);
  1782. if (speed === 0) {
  1783. s.setWrapperTranslate(translate);
  1784. s.setWrapperTransition(0);
  1785. s.onTransitionEnd(runCallbacks);
  1786. }
  1787. else {
  1788. s.setWrapperTranslate(translate);
  1789. s.setWrapperTransition(speed);
  1790. if (!s.animating) {
  1791. s.animating = true;
  1792. s.wrapper.transitionEnd(function () {
  1793. if (!s) return;
  1794. s.onTransitionEnd(runCallbacks);
  1795. });
  1796. }
  1797. }
  1798. return true;
  1799. };
  1800. s.onTransitionStart = function (runCallbacks) {
  1801. if (typeof runCallbacks === 'undefined') runCallbacks = true;
  1802. if (s.params.autoHeight) {
  1803. s.updateAutoHeight();
  1804. }
  1805. if (s.lazy) s.lazy.onTransitionStart();
  1806. if (runCallbacks) {
  1807. s.emit('onTransitionStart', s);
  1808. if (s.activeIndex !== s.previousIndex) {
  1809. s.emit('onSlideChangeStart', s);
  1810. if (s.activeIndex > s.previousIndex) {
  1811. s.emit('onSlideNextStart', s);
  1812. }
  1813. else {
  1814. s.emit('onSlidePrevStart', s);
  1815. }
  1816. }
  1817. }
  1818. };
  1819. s.onTransitionEnd = function (runCallbacks) {
  1820. s.animating = false;
  1821. s.setWrapperTransition(0);
  1822. if (typeof runCallbacks === 'undefined') runCallbacks = true;
  1823. if (s.lazy) s.lazy.onTransitionEnd();
  1824. if (runCallbacks) {
  1825. s.emit('onTransitionEnd', s);
  1826. if (s.activeIndex !== s.previousIndex) {
  1827. s.emit('onSlideChangeEnd', s);
  1828. if (s.activeIndex > s.previousIndex) {
  1829. s.emit('onSlideNextEnd', s);
  1830. }
  1831. else {
  1832. s.emit('onSlidePrevEnd', s);
  1833. }
  1834. }
  1835. }
  1836. if (s.params.hashnav && s.hashnav) {
  1837. s.hashnav.setHash();
  1838. }
  1839. };
  1840. s.slideNext = function (runCallbacks, speed, internal) {
  1841. if (s.params.loop) {
  1842. if (s.animating) return false;
  1843. s.fixLoop();
  1844. var clientLeft = s.container[0].clientLeft;
  1845. return s.slideTo(s.activeIndex + s.params.slidesPerGroup, speed, runCallbacks, internal);
  1846. }
  1847. else return s.slideTo(s.activeIndex + s.params.slidesPerGroup, speed, runCallbacks, internal);
  1848. };
  1849. s._slideNext = function (speed) {
  1850. return s.slideNext(true, speed, true);
  1851. };
  1852. s.slidePrev = function (runCallbacks, speed, internal) {
  1853. if (s.params.loop) {
  1854. if (s.animating) return false;
  1855. s.fixLoop();
  1856. var clientLeft = s.container[0].clientLeft;
  1857. return s.slideTo(s.activeIndex - 1, speed, runCallbacks, internal);
  1858. }
  1859. else return s.slideTo(s.activeIndex - 1, speed, runCallbacks, internal);
  1860. };
  1861. s._slidePrev = function (speed) {
  1862. return s.slidePrev(true, speed, true);
  1863. };
  1864. s.slideReset = function (runCallbacks, speed, internal) {
  1865. return s.slideTo(s.activeIndex, speed, runCallbacks);
  1866. };
  1867. /*=========================
  1868. Translate/transition helpers
  1869. ===========================*/
  1870. s.setWrapperTransition = function (duration, byController) {
  1871. s.wrapper.transition(duration);
  1872. if (s.params.effect !== 'slide' && s.effects[s.params.effect]) {
  1873. s.effects[s.params.effect].setTransition(duration);
  1874. }
  1875. if (s.params.parallax && s.parallax) {
  1876. s.parallax.setTransition(duration);
  1877. }
  1878. if (s.params.scrollbar && s.scrollbar) {
  1879. s.scrollbar.setTransition(duration);
  1880. }
  1881. if (s.params.control && s.controller) {
  1882. s.controller.setTransition(duration, byController);
  1883. }
  1884. s.emit('onSetTransition', s, duration);
  1885. };
  1886. s.setWrapperTranslate = function (translate, updateActiveIndex, byController) {
  1887. var x = 0, y = 0, z = 0;
  1888. if (s.isHorizontal()) {
  1889. x = s.rtl ? -translate : translate;
  1890. }
  1891. else {
  1892. y = translate;
  1893. }
  1894. if (s.params.roundLengths) {
  1895. x = round(x);
  1896. y = round(y);
  1897. }
  1898. if (!s.params.virtualTranslate) {
  1899. if (s.support.transforms3d) s.wrapper.transform('translate3d(' + x + 'px, ' + y + 'px, ' + z + 'px)');
  1900. else s.wrapper.transform('translate(' + x + 'px, ' + y + 'px)');
  1901. }
  1902. s.translate = s.isHorizontal() ? x : y;
  1903. // Check if we need to update progress
  1904. var progress;
  1905. var translatesDiff = s.maxTranslate() - s.minTranslate();
  1906. if (translatesDiff === 0) {
  1907. progress = 0;
  1908. }
  1909. else {
  1910. progress = (translate - s.minTranslate()) / (translatesDiff);
  1911. }
  1912. if (progress !== s.progress) {
  1913. s.updateProgress(translate);
  1914. }
  1915. if (updateActiveIndex) s.updateActiveIndex();
  1916. if (s.params.effect !== 'slide' && s.effects[s.params.effect]) {
  1917. s.effects[s.params.effect].setTranslate(s.translate);
  1918. }
  1919. if (s.params.parallax && s.parallax) {
  1920. s.parallax.setTranslate(s.translate);
  1921. }
  1922. if (s.params.scrollbar && s.scrollbar) {
  1923. s.scrollbar.setTranslate(s.translate);
  1924. }
  1925. if (s.params.control && s.controller) {
  1926. s.controller.setTranslate(s.translate, byController);
  1927. }
  1928. s.emit('onSetTranslate', s, s.translate);
  1929. };
  1930. s.getTranslate = function (el, axis) {
  1931. var matrix, curTransform, curStyle, transformMatrix;
  1932. // automatic axis detection
  1933. if (typeof axis === 'undefined') {
  1934. axis = 'x';
  1935. }
  1936. if (s.params.virtualTranslate) {
  1937. return s.rtl ? -s.translate : s.translate;
  1938. }
  1939. curStyle = window.getComputedStyle(el, null);
  1940. if (window.WebKitCSSMatrix) {
  1941. curTransform = curStyle.transform || curStyle.webkitTransform;
  1942. if (curTransform.split(',').length > 6) {
  1943. curTransform = curTransform.split(', ').map(function(a){
  1944. return a.replace(',','.');
  1945. }).join(', ');
  1946. }
  1947. // Some old versions of Webkit choke when 'none' is passed; pass
  1948. // empty string instead in this case
  1949. transformMatrix = new window.WebKitCSSMatrix(curTransform === 'none' ? '' : curTransform);
  1950. }
  1951. else {
  1952. transformMatrix = curStyle.MozTransform || curStyle.OTransform || curStyle.MsTransform || curStyle.msTransform || curStyle.transform || curStyle.getPropertyValue('transform').replace('translate(', 'matrix(1, 0, 0, 1,');
  1953. matrix = transformMatrix.toString().split(',');
  1954. }
  1955. if (axis === 'x') {
  1956. //Latest Chrome and webkits Fix
  1957. if (window.WebKitCSSMatrix)
  1958. curTransform = transformMatrix.m41;
  1959. //Crazy IE10 Matrix
  1960. else if (matrix.length === 16)
  1961. curTransform = parseFloat(matrix[12]);
  1962. //Normal Browsers
  1963. else
  1964. curTransform = parseFloat(matrix[4]);
  1965. }
  1966. if (axis === 'y') {
  1967. //Latest Chrome and webkits Fix
  1968. if (window.WebKitCSSMatrix)
  1969. curTransform = transformMatrix.m42;
  1970. //Crazy IE10 Matrix
  1971. else if (matrix.length === 16)
  1972. curTransform = parseFloat(matrix[13]);
  1973. //Normal Browsers
  1974. else
  1975. curTransform = parseFloat(matrix[5]);
  1976. }
  1977. if (s.rtl && curTransform) curTransform = -curTransform;
  1978. return curTransform || 0;
  1979. };
  1980. s.getWrapperTranslate = function (axis) {
  1981. if (typeof axis === 'undefined') {
  1982. axis = s.isHorizontal() ? 'x' : 'y';
  1983. }
  1984. return s.getTranslate(s.wrapper[0], axis);
  1985. };
  1986. /*=========================
  1987. Observer
  1988. ===========================*/
  1989. s.observers = [];
  1990. function initObserver(target, options) {
  1991. options = options || {};
  1992. // create an observer instance
  1993. var ObserverFunc = window.MutationObserver || window.WebkitMutationObserver;
  1994. var observer = new ObserverFunc(function (mutations) {
  1995. mutations.forEach(function (mutation) {
  1996. s.onResize(true);
  1997. s.emit('onObserverUpdate', s, mutation);
  1998. });
  1999. });
  2000. observer.observe(target, {
  2001. attributes: typeof options.attributes === 'undefined' ? true : options.attributes,
  2002. childList: typeof options.childList === 'undefined' ? true : options.childList,
  2003. characterData: typeof options.characterData === 'undefined' ? true : options.characterData
  2004. });
  2005. s.observers.push(observer);
  2006. }
  2007. s.initObservers = function () {
  2008. if (s.params.observeParents) {
  2009. var containerParents = s.container.parents();
  2010. for (var i = 0; i < containerParents.length; i++) {
  2011. initObserver(containerParents[i]);
  2012. }
  2013. }
  2014. // Observe container
  2015. initObserver(s.container[0], {childList: false});
  2016. // Observe wrapper
  2017. initObserver(s.wrapper[0], {attributes: false});
  2018. };
  2019. s.disconnectObservers = function () {
  2020. for (var i = 0; i < s.observers.length; i++) {
  2021. s.observers[i].disconnect();
  2022. }
  2023. s.observers = [];
  2024. };
  2025. /*=========================
  2026. Loop
  2027. ===========================*/
  2028. // Create looped slides
  2029. s.createLoop = function () {
  2030. // Remove duplicated slides
  2031. s.wrapper.children('.' + s.params.slideClass + '.' + s.params.slideDuplicateClass).remove();
  2032. var slides = s.wrapper.children('.' + s.params.slideClass);
  2033. if(s.params.slidesPerView === 'auto' && !s.params.loopedSlides) s.params.loopedSlides = slides.length;
  2034. s.loopedSlides = parseInt(s.params.loopedSlides || s.params.slidesPerView, 10);
  2035. s.loopedSlides = s.loopedSlides + s.params.loopAdditionalSlides;
  2036. if (s.loopedSlides > slides.length) {
  2037. s.loopedSlides = slides.length;
  2038. }
  2039. var prependSlides = [], appendSlides = [], i;
  2040. slides.each(function (index, el) {
  2041. var slide = $(this);
  2042. if (index < s.loopedSlides) appendSlides.push(el);
  2043. if (index < slides.length && index >= slides.length - s.loopedSlides) prependSlides.push(el);
  2044. slide.attr('data-swiper-slide-index', index);
  2045. });
  2046. for (i = 0; i < appendSlides.length; i++) {
  2047. s.wrapper.append($(appendSlides[i].cloneNode(true)).addClass(s.params.slideDuplicateClass));
  2048. }
  2049. for (i = prependSlides.length - 1; i >= 0; i--) {
  2050. s.wrapper.prepend($(prependSlides[i].cloneNode(true)).addClass(s.params.slideDuplicateClass));
  2051. }
  2052. };
  2053. s.destroyLoop = function () {
  2054. s.wrapper.children('.' + s.params.slideClass + '.' + s.params.slideDuplicateClass).remove();
  2055. s.slides.removeAttr('data-swiper-slide-index');
  2056. };
  2057. s.reLoop = function (updatePosition) {
  2058. var oldIndex = s.activeIndex - s.loopedSlides;
  2059. s.destroyLoop();
  2060. s.createLoop();
  2061. s.updateSlidesSize();
  2062. if (updatePosition) {
  2063. s.slideTo(oldIndex + s.loopedSlides, 0, false);
  2064. }
  2065. };
  2066. s.fixLoop = function () {
  2067. var newIndex;
  2068. //Fix For Negative Oversliding
  2069. if (s.activeIndex < s.loopedSlides) {
  2070. newIndex = s.slides.length - s.loopedSlides * 3 + s.activeIndex;
  2071. newIndex = newIndex + s.loopedSlides;
  2072. s.slideTo(newIndex, 0, false, true);
  2073. }
  2074. //Fix For Positive Oversliding
  2075. else if ((s.params.slidesPerView === 'auto' && s.activeIndex >= s.loopedSlides * 2) || (s.activeIndex > s.slides.length - s.params.slidesPerView * 2)) {
  2076. newIndex = -s.slides.length + s.activeIndex + s.loopedSlides;
  2077. newIndex = newIndex + s.loopedSlides;
  2078. s.slideTo(newIndex, 0, false, true);
  2079. }
  2080. };
  2081. /*=========================
  2082. Append/Prepend/Remove Slides
  2083. ===========================*/
  2084. s.appendSlide = function (slides) {
  2085. if (s.params.loop) {
  2086. s.destroyLoop();
  2087. }
  2088. if (typeof slides === 'object' && slides.length) {
  2089. for (var i = 0; i < slides.length; i++) {
  2090. if (slides[i]) s.wrapper.append(slides[i]);
  2091. }
  2092. }
  2093. else {
  2094. s.wrapper.append(slides);
  2095. }
  2096. if (s.params.loop) {
  2097. s.createLoop();
  2098. }
  2099. if (!(s.params.observer && s.support.observer)) {
  2100. s.update(true);
  2101. }
  2102. };
  2103. s.prependSlide = function (slides) {
  2104. if (s.params.loop) {
  2105. s.destroyLoop();
  2106. }
  2107. var newActiveIndex = s.activeIndex + 1;
  2108. if (typeof slides === 'object' && slides.length) {
  2109. for (var i = 0; i < slides.length; i++) {
  2110. if (slides[i]) s.wrapper.prepend(slides[i]);
  2111. }
  2112. newActiveIndex = s.activeIndex + slides.length;
  2113. }
  2114. else {
  2115. s.wrapper.prepend(slides);
  2116. }
  2117. if (s.params.loop) {
  2118. s.createLoop();
  2119. }
  2120. if (!(s.params.observer && s.support.observer)) {
  2121. s.update(true);
  2122. }
  2123. s.slideTo(newActiveIndex, 0, false);
  2124. };
  2125. s.removeSlide = function (slidesIndexes) {
  2126. if (s.params.loop) {
  2127. s.destroyLoop();
  2128. s.slides = s.wrapper.children('.' + s.params.slideClass);
  2129. }
  2130. var newActiveIndex = s.activeIndex,
  2131. indexToRemove;
  2132. if (typeof slidesIndexes === 'object' && slidesIndexes.length) {
  2133. for (var i = 0; i < slidesIndexes.length; i++) {
  2134. indexToRemove = slidesIndexes[i];
  2135. if (s.slides[indexToRemove]) s.slides.eq(indexToRemove).remove();
  2136. if (indexToRemove < newActiveIndex) newActiveIndex--;
  2137. }
  2138. newActiveIndex = Math.max(newActiveIndex, 0);
  2139. }
  2140. else {
  2141. indexToRemove = slidesIndexes;
  2142. if (s.slides[indexToRemove]) s.slides.eq(indexToRemove).remove();
  2143. if (indexToRemove < newActiveIndex) newActiveIndex--;
  2144. newActiveIndex = Math.max(newActiveIndex, 0);
  2145. }
  2146. if (s.params.loop) {
  2147. s.createLoop();
  2148. }
  2149. if (!(s.params.observer && s.support.observer)) {
  2150. s.update(true);
  2151. }
  2152. if (s.params.loop) {
  2153. s.slideTo(newActiveIndex + s.loopedSlides, 0, false);
  2154. }
  2155. else {
  2156. s.slideTo(newActiveIndex, 0, false);
  2157. }
  2158. };
  2159. s.removeAllSlides = function () {
  2160. var slidesIndexes = [];
  2161. for (var i = 0; i < s.slides.length; i++) {
  2162. slidesIndexes.push(i);
  2163. }
  2164. s.removeSlide(slidesIndexes);
  2165. };
  2166. /*=========================
  2167. Effects
  2168. ===========================*/
  2169. s.effects = {
  2170. fade: {
  2171. setTranslate: function () {
  2172. for (var i = 0; i < s.slides.length; i++) {
  2173. var slide = s.slides.eq(i);
  2174. var offset = slide[0].swiperSlideOffset;
  2175. var tx = -offset;
  2176. if (!s.params.virtualTranslate) tx = tx - s.translate;
  2177. var ty = 0;
  2178. if (!s.isHorizontal()) {
  2179. ty = tx;
  2180. tx = 0;
  2181. }
  2182. var slideOpacity = s.params.fade.crossFade ?
  2183. Math.max(1 - Math.abs(slide[0].progress), 0) :
  2184. 1 + Math.min(Math.max(slide[0].progress, -1), 0);
  2185. slide
  2186. .css({
  2187. opacity: slideOpacity
  2188. })
  2189. .transform('translate3d(' + tx + 'px, ' + ty + 'px, 0px)');
  2190. }
  2191. },
  2192. setTransition: function (duration) {
  2193. s.slides.transition(duration);
  2194. if (s.params.virtualTranslate && duration !== 0) {
  2195. var eventTriggered = false;
  2196. s.slides.transitionEnd(function () {
  2197. if (eventTriggered) return;
  2198. if (!s) return;
  2199. eventTriggered = true;
  2200. s.animating = false;
  2201. var triggerEvents = ['webkitTransitionEnd', 'transitionend', 'oTransitionEnd', 'MSTransitionEnd', 'msTransitionEnd'];
  2202. for (var i = 0; i < triggerEvents.length; i++) {
  2203. s.wrapper.trigger(triggerEvents[i]);
  2204. }
  2205. });
  2206. }
  2207. }
  2208. },
  2209. flip: {
  2210. setTranslate: function () {
  2211. for (var i = 0; i < s.slides.length; i++) {
  2212. var slide = s.slides.eq(i);
  2213. var progress = slide[0].progress;
  2214. if (s.params.flip.limitRotation) {
  2215. progress = Math.max(Math.min(slide[0].progress, 1), -1);
  2216. }
  2217. var offset = slide[0].swiperSlideOffset;
  2218. var rotate = -180 * progress,
  2219. rotateY = rotate,
  2220. rotateX = 0,
  2221. tx = -offset,
  2222. ty = 0;
  2223. if (!s.isHorizontal()) {
  2224. ty = tx;
  2225. tx = 0;
  2226. rotateX = -rotateY;
  2227. rotateY = 0;
  2228. }
  2229. else if (s.rtl) {
  2230. rotateY = -rotateY;
  2231. }
  2232. slide[0].style.zIndex = -Math.abs(Math.round(progress)) + s.slides.length;
  2233. if (s.params.flip.slideShadows) {
  2234. //Set shadows
  2235. var shadowBefore = s.isHorizontal() ? slide.find('.swiper-slide-shadow-left') : slide.find('.swiper-slide-shadow-top');
  2236. var shadowAfter = s.isHorizontal() ? slide.find('.swiper-slide-shadow-right') : slide.find('.swiper-slide-shadow-bottom');
  2237. if (shadowBefore.length === 0) {
  2238. shadowBefore = $('<div class="swiper-slide-shadow-' + (s.isHorizontal() ? 'left' : 'top') + '"></div>');
  2239. slide.append(shadowBefore);
  2240. }
  2241. if (shadowAfter.length === 0) {
  2242. shadowAfter = $('<div class="swiper-slide-shadow-' + (s.isHorizontal() ? 'right' : 'bottom') + '"></div>');
  2243. slide.append(shadowAfter);
  2244. }
  2245. if (shadowBefore.length) shadowBefore[0].style.opacity = Math.max(-progress, 0);
  2246. if (shadowAfter.length) shadowAfter[0].style.opacity = Math.max(progress, 0);
  2247. }
  2248. slide
  2249. .transform('translate3d(' + tx + 'px, ' + ty + 'px, 0px) rotateX(' + rotateX + 'deg) rotateY(' + rotateY + 'deg)');
  2250. }
  2251. },
  2252. setTransition: function (duration) {
  2253. s.slides.transition(duration).find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').transition(duration);
  2254. if (s.params.virtualTranslate && duration !== 0) {
  2255. var eventTriggered = false;
  2256. s.slides.eq(s.activeIndex).transitionEnd(function () {
  2257. if (eventTriggered) return;
  2258. if (!s) return;
  2259. if (!$(this).hasClass(s.params.slideActiveClass)) return;
  2260. eventTriggered = true;
  2261. s.animating = false;
  2262. var triggerEvents = ['webkitTransitionEnd', 'transitionend', 'oTransitionEnd', 'MSTransitionEnd', 'msTransitionEnd'];
  2263. for (var i = 0; i < triggerEvents.length; i++) {
  2264. s.wrapper.trigger(triggerEvents[i]);
  2265. }
  2266. });
  2267. }
  2268. }
  2269. },
  2270. cube: {
  2271. setTranslate: function () {
  2272. var wrapperRotate = 0, cubeShadow;
  2273. if (s.params.cube.shadow) {
  2274. if (s.isHorizontal()) {
  2275. cubeShadow = s.wrapper.find('.swiper-cube-shadow');
  2276. if (cubeShadow.length === 0) {
  2277. cubeShadow = $('<div class="swiper-cube-shadow"></div>');
  2278. s.wrapper.append(cubeShadow);
  2279. }
  2280. cubeShadow.css({height: s.width + 'px'});
  2281. }
  2282. else {
  2283. cubeShadow = s.container.find('.swiper-cube-shadow');
  2284. if (cubeShadow.length === 0) {
  2285. cubeShadow = $('<div class="swiper-cube-shadow"></div>');
  2286. s.container.append(cubeShadow);
  2287. }
  2288. }
  2289. }
  2290. for (var i = 0; i < s.slides.length; i++) {
  2291. var slide = s.slides.eq(i);
  2292. var slideAngle = i * 90;
  2293. var round = Math.floor(slideAngle / 360);
  2294. if (s.rtl) {
  2295. slideAngle = -slideAngle;
  2296. round = Math.floor(-slideAngle / 360);
  2297. }
  2298. var progress = Math.max(Math.min(slide[0].progress, 1), -1);
  2299. var tx = 0, ty = 0, tz = 0;
  2300. if (i % 4 === 0) {
  2301. tx = - round * 4 * s.size;
  2302. tz = 0;
  2303. }
  2304. else if ((i - 1) % 4 === 0) {
  2305. tx = 0;
  2306. tz = - round * 4 * s.size;
  2307. }
  2308. else if ((i - 2) % 4 === 0) {
  2309. tx = s.size + round * 4 * s.size;
  2310. tz = s.size;
  2311. }
  2312. else if ((i - 3) % 4 === 0) {
  2313. tx = - s.size;
  2314. tz = 3 * s.size + s.size * 4 * round;
  2315. }
  2316. if (s.rtl) {
  2317. tx = -tx;
  2318. }
  2319. if (!s.isHorizontal()) {
  2320. ty = tx;
  2321. tx = 0;
  2322. }
  2323. var transform = 'rotateX(' + (s.isHorizontal() ? 0 : -slideAngle) + 'deg) rotateY(' + (s.isHorizontal() ? slideAngle : 0) + 'deg) translate3d(' + tx + 'px, ' + ty + 'px, ' + tz + 'px)';
  2324. if (progress <= 1 && progress > -1) {
  2325. wrapperRotate = i * 90 + progress * 90;
  2326. if (s.rtl) wrapperRotate = -i * 90 - progress * 90;
  2327. }
  2328. slide.transform(transform);
  2329. if (s.params.cube.slideShadows) {
  2330. //Set shadows
  2331. var shadowBefore = s.isHorizontal() ? slide.find('.swiper-slide-shadow-left') : slide.find('.swiper-slide-shadow-top');
  2332. var shadowAfter = s.isHorizontal() ? slide.find('.swiper-slide-shadow-right') : slide.find('.swiper-slide-shadow-bottom');
  2333. if (shadowBefore.length === 0) {
  2334. shadowBefore = $('<div class="swiper-slide-shadow-' + (s.isHorizontal() ? 'left' : 'top') + '"></div>');
  2335. slide.append(shadowBefore);
  2336. }
  2337. if (shadowAfter.length === 0) {
  2338. shadowAfter = $('<div class="swiper-slide-shadow-' + (s.isHorizontal() ? 'right' : 'bottom') + '"></div>');
  2339. slide.append(shadowAfter);
  2340. }
  2341. if (shadowBefore.length) shadowBefore[0].style.opacity = Math.max(-progress, 0);
  2342. if (shadowAfter.length) shadowAfter[0].style.opacity = Math.max(progress, 0);
  2343. }
  2344. }
  2345. s.wrapper.css({
  2346. '-webkit-transform-origin': '50% 50% -' + (s.size / 2) + 'px',
  2347. '-moz-transform-origin': '50% 50% -' + (s.size / 2) + 'px',
  2348. '-ms-transform-origin': '50% 50% -' + (s.size / 2) + 'px',
  2349. 'transform-origin': '50% 50% -' + (s.size / 2) + 'px'
  2350. });
  2351. if (s.params.cube.shadow) {
  2352. if (s.isHorizontal()) {
  2353. cubeShadow.transform('translate3d(0px, ' + (s.width / 2 + s.params.cube.shadowOffset) + 'px, ' + (-s.width / 2) + 'px) rotateX(90deg) rotateZ(0deg) scale(' + (s.params.cube.shadowScale) + ')');
  2354. }
  2355. else {
  2356. var shadowAngle = Math.abs(wrapperRotate) - Math.floor(Math.abs(wrapperRotate) / 90) * 90;
  2357. var multiplier = 1.5 - (Math.sin(shadowAngle * 2 * Math.PI / 360) / 2 + Math.cos(shadowAngle * 2 * Math.PI / 360) / 2);
  2358. var scale1 = s.params.cube.shadowScale,
  2359. scale2 = s.params.cube.shadowScale / multiplier,
  2360. offset = s.params.cube.shadowOffset;
  2361. cubeShadow.transform('scale3d(' + scale1 + ', 1, ' + scale2 + ') translate3d(0px, ' + (s.height / 2 + offset) + 'px, ' + (-s.height / 2 / scale2) + 'px) rotateX(-90deg)');
  2362. }
  2363. }
  2364. var zFactor = (s.isSafari || s.isUiWebView) ? (-s.size / 2) : 0;
  2365. s.wrapper.transform('translate3d(0px,0,' + zFactor + 'px) rotateX(' + (s.isHorizontal() ? 0 : wrapperRotate) + 'deg) rotateY(' + (s.isHorizontal() ? -wrapperRotate : 0) + 'deg)');
  2366. },
  2367. setTransition: function (duration) {
  2368. s.slides.transition(duration).find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').transition(duration);
  2369. if (s.params.cube.shadow && !s.isHorizontal()) {
  2370. s.container.find('.swiper-cube-shadow').transition(duration);
  2371. }
  2372. }
  2373. },
  2374. coverflow: {
  2375. setTranslate: function () {
  2376. var transform = s.translate;
  2377. var center = s.isHorizontal() ? -transform + s.width / 2 : -transform + s.height / 2;
  2378. var rotate = s.isHorizontal() ? s.params.coverflow.rotate: -s.params.coverflow.rotate;
  2379. var translate = s.params.coverflow.depth;
  2380. //Each slide offset from center
  2381. for (var i = 0, length = s.slides.length; i < length; i++) {
  2382. var slide = s.slides.eq(i);
  2383. var slideSize = s.slidesSizesGrid[i];
  2384. var slideOffset = slide[0].swiperSlideOffset;
  2385. var offsetMultiplier = (center - slideOffset - slideSize / 2) / slideSize * s.params.coverflow.modifier;
  2386. var rotateY = s.isHorizontal() ? rotate * offsetMultiplier : 0;
  2387. var rotateX = s.isHorizontal() ? 0 : rotate * offsetMultiplier;
  2388. // var rotateZ = 0
  2389. var translateZ = -translate * Math.abs(offsetMultiplier);
  2390. var translateY = s.isHorizontal() ? 0 : s.params.coverflow.stretch * (offsetMultiplier);
  2391. var translateX = s.isHorizontal() ? s.params.coverflow.stretch * (offsetMultiplier) : 0;
  2392. //Fix for ultra small values
  2393. if (Math.abs(translateX) < 0.001) translateX = 0;
  2394. if (Math.abs(translateY) < 0.001) translateY = 0;
  2395. if (Math.abs(translateZ) < 0.001) translateZ = 0;
  2396. if (Math.abs(rotateY) < 0.001) rotateY = 0;
  2397. if (Math.abs(rotateX) < 0.001) rotateX = 0;
  2398. var slideTransform = 'translate3d(' + translateX + 'px,' + translateY + 'px,' + translateZ + 'px) rotateX(' + rotateX + 'deg) rotateY(' + rotateY + 'deg)';
  2399. slide.transform(slideTransform);
  2400. slide[0].style.zIndex = -Math.abs(Math.round(offsetMultiplier)) + 1;
  2401. if (s.params.coverflow.slideShadows) {
  2402. //Set shadows
  2403. var shadowBefore = s.isHorizontal() ? slide.find('.swiper-slide-shadow-left') : slide.find('.swiper-slide-shadow-top');
  2404. var shadowAfter = s.isHorizontal() ? slide.find('.swiper-slide-shadow-right') : slide.find('.swiper-slide-shadow-bottom');
  2405. if (shadowBefore.length === 0) {
  2406. shadowBefore = $('<div class="swiper-slide-shadow-' + (s.isHorizontal() ? 'left' : 'top') + '"></div>');
  2407. slide.append(shadowBefore);
  2408. }
  2409. if (shadowAfter.length === 0) {
  2410. shadowAfter = $('<div class="swiper-slide-shadow-' + (s.isHorizontal() ? 'right' : 'bottom') + '"></div>');
  2411. slide.append(shadowAfter);
  2412. }
  2413. if (shadowBefore.length) shadowBefore[0].style.opacity = offsetMultiplier > 0 ? offsetMultiplier : 0;
  2414. if (shadowAfter.length) shadowAfter[0].style.opacity = (-offsetMultiplier) > 0 ? -offsetMultiplier : 0;
  2415. }
  2416. }
  2417. //Set correct perspective for IE10
  2418. if (s.browser.ie) {
  2419. var ws = s.wrapper[0].style;
  2420. ws.perspectiveOrigin = center + 'px 50%';
  2421. }
  2422. },
  2423. setTransition: function (duration) {
  2424. s.slides.transition(duration).find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').transition(duration);
  2425. }
  2426. }
  2427. };
  2428. /*=========================
  2429. Images Lazy Loading
  2430. ===========================*/
  2431. s.lazy = {
  2432. initialImageLoaded: false,
  2433. loadImageInSlide: function (index, loadInDuplicate) {
  2434. if (typeof index === 'undefined') return;
  2435. if (typeof loadInDuplicate === 'undefined') loadInDuplicate = true;
  2436. if (s.slides.length === 0) return;
  2437. var slide = s.slides.eq(index);
  2438. var img = slide.find('.swiper-lazy:not(.swiper-lazy-loaded):not(.swiper-lazy-loading)');
  2439. if (slide.hasClass('swiper-lazy') && !slide.hasClass('swiper-lazy-loaded') && !slide.hasClass('swiper-lazy-loading')) {
  2440. img = img.add(slide[0]);
  2441. }
  2442. if (img.length === 0) return;
  2443. img.each(function () {
  2444. var _img = $(this);
  2445. _img.addClass('swiper-lazy-loading');
  2446. var background = _img.attr('data-background');
  2447. var src = _img.attr('data-src'),
  2448. srcset = _img.attr('data-srcset');
  2449. s.loadImage(_img[0], (src || background), srcset, false, function () {
  2450. if (background) {
  2451. _img.css('background-image', 'url("' + background + '")');
  2452. _img.removeAttr('data-background');
  2453. }
  2454. else {
  2455. if (srcset) {
  2456. _img.attr('srcset', srcset);
  2457. _img.removeAttr('data-srcset');
  2458. }
  2459. if (src) {
  2460. _img.attr('src', src);
  2461. _img.removeAttr('data-src');
  2462. }
  2463. }
  2464. _img.addClass('swiper-lazy-loaded').removeClass('swiper-lazy-loading');
  2465. slide.find('.swiper-lazy-preloader, .preloader').remove();
  2466. if (s.params.loop && loadInDuplicate) {
  2467. var slideOriginalIndex = slide.attr('data-swiper-slide-index');
  2468. if (slide.hasClass(s.params.slideDuplicateClass)) {
  2469. var originalSlide = s.wrapper.children('[data-swiper-slide-index="' + slideOriginalIndex + '"]:not(.' + s.params.slideDuplicateClass + ')');
  2470. s.lazy.loadImageInSlide(originalSlide.index(), false);
  2471. }
  2472. else {
  2473. var duplicatedSlide = s.wrapper.children('.' + s.params.slideDuplicateClass + '[data-swiper-slide-index="' + slideOriginalIndex + '"]');
  2474. s.lazy.loadImageInSlide(duplicatedSlide.index(), false);
  2475. }
  2476. }
  2477. s.emit('onLazyImageReady', s, slide[0], _img[0]);
  2478. });
  2479. s.emit('onLazyImageLoad', s, slide[0], _img[0]);
  2480. });
  2481. },
  2482. load: function () {
  2483. var i;
  2484. if (s.params.watchSlidesVisibility) {
  2485. s.wrapper.children('.' + s.params.slideVisibleClass).each(function () {
  2486. s.lazy.loadImageInSlide($(this).index());
  2487. });
  2488. }
  2489. else {
  2490. if (s.params.slidesPerView > 1) {
  2491. for (i = s.activeIndex; i < s.activeIndex + s.params.slidesPerView ; i++) {
  2492. if (s.slides[i]) s.lazy.loadImageInSlide(i);
  2493. }
  2494. }
  2495. else {
  2496. s.lazy.loadImageInSlide(s.activeIndex);
  2497. }
  2498. }
  2499. if (s.params.lazyLoadingInPrevNext) {
  2500. if (s.params.slidesPerView > 1 || (s.params.lazyLoadingInPrevNextAmount && s.params.lazyLoadingInPrevNextAmount > 1)) {
  2501. var amount = s.params.lazyLoadingInPrevNextAmount;
  2502. var spv = s.params.slidesPerView;
  2503. var maxIndex = Math.min(s.activeIndex + spv + Math.max(amount, spv), s.slides.length);
  2504. var minIndex = Math.max(s.activeIndex - Math.max(spv, amount), 0);
  2505. // Next Slides
  2506. for (i = s.activeIndex + s.params.slidesPerView; i < maxIndex; i++) {
  2507. if (s.slides[i]) s.lazy.loadImageInSlide(i);
  2508. }
  2509. // Prev Slides
  2510. for (i = minIndex; i < s.activeIndex ; i++) {
  2511. if (s.slides[i]) s.lazy.loadImageInSlide(i);
  2512. }
  2513. }
  2514. else {
  2515. var nextSlide = s.wrapper.children('.' + s.params.slideNextClass);
  2516. if (nextSlide.length > 0) s.lazy.loadImageInSlide(nextSlide.index());
  2517. var prevSlide = s.wrapper.children('.' + s.params.slidePrevClass);
  2518. if (prevSlide.length > 0) s.lazy.loadImageInSlide(prevSlide.index());
  2519. }
  2520. }
  2521. },
  2522. onTransitionStart: function () {
  2523. if (s.params.lazyLoading) {
  2524. if (s.params.lazyLoadingOnTransitionStart || (!s.params.lazyLoadingOnTransitionStart && !s.lazy.initialImageLoaded)) {
  2525. s.lazy.load();
  2526. }
  2527. }
  2528. },
  2529. onTransitionEnd: function () {
  2530. if (s.params.lazyLoading && !s.params.lazyLoadingOnTransitionStart) {
  2531. s.lazy.load();
  2532. }
  2533. }
  2534. };
  2535. /*=========================
  2536. Scrollbar
  2537. ===========================*/
  2538. s.scrollbar = {
  2539. isTouched: false,
  2540. setDragPosition: function (e) {
  2541. var sb = s.scrollbar;
  2542. var x = 0, y = 0;
  2543. var translate;
  2544. var pointerPosition = s.isHorizontal() ?
  2545. ((e.type === 'touchstart' || e.type === 'touchmove') ? e.targetTouches[0].pageX : e.pageX || e.clientX) :
  2546. ((e.type === 'touchstart' || e.type === 'touchmove') ? e.targetTouches[0].pageY : e.pageY || e.clientY) ;
  2547. var position = (pointerPosition) - sb.track.offset()[s.isHorizontal() ? 'left' : 'top'] - sb.dragSize / 2;
  2548. var positionMin = -s.minTranslate() * sb.moveDivider;
  2549. var positionMax = -s.maxTranslate() * sb.moveDivider;
  2550. if (position < positionMin) {
  2551. position = positionMin;
  2552. }
  2553. else if (position > positionMax) {
  2554. position = positionMax;
  2555. }
  2556. position = -position / sb.moveDivider;
  2557. s.updateProgress(position);
  2558. s.setWrapperTranslate(position, true);
  2559. },
  2560. dragStart: function (e) {
  2561. var sb = s.scrollbar;
  2562. sb.isTouched = true;
  2563. e.preventDefault();
  2564. e.stopPropagation();
  2565. sb.setDragPosition(e);
  2566. clearTimeout(sb.dragTimeout);
  2567. sb.track.transition(0);
  2568. if (s.params.scrollbarHide) {
  2569. sb.track.css('opacity', 1);
  2570. }
  2571. s.wrapper.transition(100);
  2572. sb.drag.transition(100);
  2573. s.emit('onScrollbarDragStart', s);
  2574. },
  2575. dragMove: function (e) {
  2576. var sb = s.scrollbar;
  2577. if (!sb.isTouched) return;
  2578. if (e.preventDefault) e.preventDefault();
  2579. else e.returnValue = false;
  2580. sb.setDragPosition(e);
  2581. s.wrapper.transition(0);
  2582. sb.track.transition(0);
  2583. sb.drag.transition(0);
  2584. s.emit('onScrollbarDragMove', s);
  2585. },
  2586. dragEnd: function (e) {
  2587. var sb = s.scrollbar;
  2588. if (!sb.isTouched) return;
  2589. sb.isTouched = false;
  2590. if (s.params.scrollbarHide) {
  2591. clearTimeout(sb.dragTimeout);
  2592. sb.dragTimeout = setTimeout(function () {
  2593. sb.track.css('opacity', 0);
  2594. sb.track.transition(400);
  2595. }, 1000);
  2596. }
  2597. s.emit('onScrollbarDragEnd', s);
  2598. if (s.params.scrollbarSnapOnRelease) {
  2599. s.slideReset();
  2600. }
  2601. },
  2602. enableDraggable: function () {
  2603. var sb = s.scrollbar;
  2604. var target = s.support.touch ? sb.track : document;
  2605. $(sb.track).on(s.touchEvents.start, sb.dragStart);
  2606. $(target).on(s.touchEvents.move, sb.dragMove);
  2607. $(target).on(s.touchEvents.end, sb.dragEnd);
  2608. },
  2609. disableDraggable: function () {
  2610. var sb = s.scrollbar;
  2611. var target = s.support.touch ? sb.track : document;
  2612. $(sb.track).off(s.touchEvents.start, sb.dragStart);
  2613. $(target).off(s.touchEvents.move, sb.dragMove);
  2614. $(target).off(s.touchEvents.end, sb.dragEnd);
  2615. },
  2616. set: function () {
  2617. if (!s.params.scrollbar) return;
  2618. var sb = s.scrollbar;
  2619. sb.track = $(s.params.scrollbar);
  2620. if (s.params.uniqueNavElements && typeof s.params.scrollbar === 'string' && sb.track.length > 1 && s.container.find(s.params.scrollbar).length === 1) {
  2621. sb.track = s.container.find(s.params.scrollbar);
  2622. }
  2623. sb.drag = sb.track.find('.swiper-scrollbar-drag');
  2624. if (sb.drag.length === 0) {
  2625. sb.drag = $('<div class="swiper-scrollbar-drag"></div>');
  2626. sb.track.append(sb.drag);
  2627. }
  2628. sb.drag[0].style.width = '';
  2629. sb.drag[0].style.height = '';
  2630. sb.trackSize = s.isHorizontal() ? sb.track[0].offsetWidth : sb.track[0].offsetHeight;
  2631. sb.divider = s.size / s.virtualSize;
  2632. sb.moveDivider = sb.divider * (sb.trackSize / s.size);
  2633. sb.dragSize = sb.trackSize * sb.divider;
  2634. if (s.isHorizontal()) {
  2635. sb.drag[0].style.width = sb.dragSize + 'px';
  2636. }
  2637. else {
  2638. sb.drag[0].style.height = sb.dragSize + 'px';
  2639. }
  2640. if (sb.divider >= 1) {
  2641. sb.track[0].style.display = 'none';
  2642. }
  2643. else {
  2644. sb.track[0].style.display = '';
  2645. }
  2646. if (s.params.scrollbarHide) {
  2647. sb.track[0].style.opacity = 0;
  2648. }
  2649. },
  2650. setTranslate: function () {
  2651. if (!s.params.scrollbar) return;
  2652. var diff;
  2653. var sb = s.scrollbar;
  2654. var translate = s.translate || 0;
  2655. var newPos;
  2656. var newSize = sb.dragSize;
  2657. newPos = (sb.trackSize - sb.dragSize) * s.progress;
  2658. if (s.rtl && s.isHorizontal()) {
  2659. newPos = -newPos;
  2660. if (newPos > 0) {
  2661. newSize = sb.dragSize - newPos;
  2662. newPos = 0;
  2663. }
  2664. else if (-newPos + sb.dragSize > sb.trackSize) {
  2665. newSize = sb.trackSize + newPos;
  2666. }
  2667. }
  2668. else {
  2669. if (newPos < 0) {
  2670. newSize = sb.dragSize + newPos;
  2671. newPos = 0;
  2672. }
  2673. else if (newPos + sb.dragSize > sb.trackSize) {
  2674. newSize = sb.trackSize - newPos;
  2675. }
  2676. }
  2677. if (s.isHorizontal()) {
  2678. if (s.support.transforms3d) {
  2679. sb.drag.transform('translate3d(' + (newPos) + 'px, 0, 0)');
  2680. }
  2681. else {
  2682. sb.drag.transform('translateX(' + (newPos) + 'px)');
  2683. }
  2684. sb.drag[0].style.width = newSize + 'px';
  2685. }
  2686. else {
  2687. if (s.support.transforms3d) {
  2688. sb.drag.transform('translate3d(0px, ' + (newPos) + 'px, 0)');
  2689. }
  2690. else {
  2691. sb.drag.transform('translateY(' + (newPos) + 'px)');
  2692. }
  2693. sb.drag[0].style.height = newSize + 'px';
  2694. }
  2695. if (s.params.scrollbarHide) {
  2696. clearTimeout(sb.timeout);
  2697. sb.track[0].style.opacity = 1;
  2698. sb.timeout = setTimeout(function () {
  2699. sb.track[0].style.opacity = 0;
  2700. sb.track.transition(400);
  2701. }, 1000);
  2702. }
  2703. },
  2704. setTransition: function (duration) {
  2705. if (!s.params.scrollbar) return;
  2706. s.scrollbar.drag.transition(duration);
  2707. }
  2708. };
  2709. /*=========================
  2710. Controller
  2711. ===========================*/
  2712. s.controller = {
  2713. LinearSpline: function (x, y) {
  2714. this.x = x;
  2715. this.y = y;
  2716. this.lastIndex = x.length - 1;
  2717. // Given an x value (x2), return the expected y2 value:
  2718. // (x1,y1) is the known point before given value,
  2719. // (x3,y3) is the known point after given value.
  2720. var i1, i3;
  2721. var l = this.x.length;
  2722. this.interpolate = function (x2) {
  2723. if (!x2) return 0;
  2724. // Get the indexes of x1 and x3 (the array indexes before and after given x2):
  2725. i3 = binarySearch(this.x, x2);
  2726. i1 = i3 - 1;
  2727. // We have our indexes i1 & i3, so we can calculate already:
  2728. // y2 := ((x2−x1) × (y3−y1)) ÷ (x3−x1) + y1
  2729. return ((x2 - this.x[i1]) * (this.y[i3] - this.y[i1])) / (this.x[i3] - this.x[i1]) + this.y[i1];
  2730. };
  2731. var binarySearch = (function() {
  2732. var maxIndex, minIndex, guess;
  2733. return function(array, val) {
  2734. minIndex = -1;
  2735. maxIndex = array.length;
  2736. while (maxIndex - minIndex > 1)
  2737. if (array[guess = maxIndex + minIndex >> 1] <= val) {
  2738. minIndex = guess;
  2739. } else {
  2740. maxIndex = guess;
  2741. }
  2742. return maxIndex;
  2743. };
  2744. })();
  2745. },
  2746. //xxx: for now i will just save one spline function to to
  2747. getInterpolateFunction: function(c){
  2748. if(!s.controller.spline) s.controller.spline = s.params.loop ?
  2749. new s.controller.LinearSpline(s.slidesGrid, c.slidesGrid) :
  2750. new s.controller.LinearSpline(s.snapGrid, c.snapGrid);
  2751. },
  2752. setTranslate: function (translate, byController) {
  2753. var controlled = s.params.control;
  2754. var multiplier, controlledTranslate;
  2755. function setControlledTranslate(c) {
  2756. // this will create an Interpolate function based on the snapGrids
  2757. // x is the Grid of the scrolled scroller and y will be the controlled scroller
  2758. // it makes sense to create this only once and recall it for the interpolation
  2759. // the function does a lot of value caching for performance
  2760. translate = c.rtl && c.params.direction === 'horizontal' ? -s.translate : s.translate;
  2761. if (s.params.controlBy === 'slide') {
  2762. s.controller.getInterpolateFunction(c);
  2763. // i am not sure why the values have to be multiplicated this way, tried to invert the snapGrid
  2764. // but it did not work out
  2765. controlledTranslate = -s.controller.spline.interpolate(-translate);
  2766. }
  2767. if(!controlledTranslate || s.params.controlBy === 'container'){
  2768. multiplier = (c.maxTranslate() - c.minTranslate()) / (s.maxTranslate() - s.minTranslate());
  2769. controlledTranslate = (translate - s.minTranslate()) * multiplier + c.minTranslate();
  2770. }
  2771. if (s.params.controlInverse) {
  2772. controlledTranslate = c.maxTranslate() - controlledTranslate;
  2773. }
  2774. c.updateProgress(controlledTranslate);
  2775. c.setWrapperTranslate(controlledTranslate, false, s);
  2776. c.updateActiveIndex();
  2777. }
  2778. if (s.isArray(controlled)) {
  2779. for (var i = 0; i < controlled.length; i++) {
  2780. if (controlled[i] !== byController && controlled[i] instanceof Swiper) {
  2781. setControlledTranslate(controlled[i]);
  2782. }
  2783. }
  2784. }
  2785. else if (controlled instanceof Swiper && byController !== controlled) {
  2786. setControlledTranslate(controlled);
  2787. }
  2788. },
  2789. setTransition: function (duration, byController) {
  2790. var controlled = s.params.control;
  2791. var i;
  2792. function setControlledTransition(c) {
  2793. c.setWrapperTransition(duration, s);
  2794. if (duration !== 0) {
  2795. c.onTransitionStart();
  2796. c.wrapper.transitionEnd(function(){
  2797. if (!controlled) return;
  2798. if (c.params.loop && s.params.controlBy === 'slide') {
  2799. c.fixLoop();
  2800. }
  2801. c.onTransitionEnd();
  2802. });
  2803. }
  2804. }
  2805. if (s.isArray(controlled)) {
  2806. for (i = 0; i < controlled.length; i++) {
  2807. if (controlled[i] !== byController && controlled[i] instanceof Swiper) {
  2808. setControlledTransition(controlled[i]);
  2809. }
  2810. }
  2811. }
  2812. else if (controlled instanceof Swiper && byController !== controlled) {
  2813. setControlledTransition(controlled);
  2814. }
  2815. }
  2816. };
  2817. /*=========================
  2818. Hash Navigation
  2819. ===========================*/
  2820. s.hashnav = {
  2821. init: function () {
  2822. if (!s.params.hashnav) return;
  2823. s.hashnav.initialized = true;
  2824. var hash = document.location.hash.replace('#', '');
  2825. if (!hash) return;
  2826. var speed = 0;
  2827. for (var i = 0, length = s.slides.length; i < length; i++) {
  2828. var slide = s.slides.eq(i);
  2829. var slideHash = slide.attr('data-hash');
  2830. if (slideHash === hash && !slide.hasClass(s.params.slideDuplicateClass)) {
  2831. var index = slide.index();
  2832. s.slideTo(index, speed, s.params.runCallbacksOnInit, true);
  2833. }
  2834. }
  2835. },
  2836. setHash: function () {
  2837. if (!s.hashnav.initialized || !s.params.hashnav) return;
  2838. document.location.hash = s.slides.eq(s.activeIndex).attr('data-hash') || '';
  2839. }
  2840. };
  2841. /*=========================
  2842. Keyboard Control
  2843. ===========================*/
  2844. function handleKeyboard(e) {
  2845. if (e.originalEvent) e = e.originalEvent; //jquery fix
  2846. var kc = e.keyCode || e.charCode;
  2847. // Directions locks
  2848. if (!s.params.allowSwipeToNext && (s.isHorizontal() && kc === 39 || !s.isHorizontal() && kc === 40)) {
  2849. return false;
  2850. }
  2851. if (!s.params.allowSwipeToPrev && (s.isHorizontal() && kc === 37 || !s.isHorizontal() && kc === 38)) {
  2852. return false;
  2853. }
  2854. if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey) {
  2855. return;
  2856. }
  2857. if (document.activeElement && document.activeElement.nodeName && (document.activeElement.nodeName.toLowerCase() === 'input' || document.activeElement.nodeName.toLowerCase() === 'textarea')) {
  2858. return;
  2859. }
  2860. if (kc === 37 || kc === 39 || kc === 38 || kc === 40) {
  2861. var inView = false;
  2862. //Check that swiper should be inside of visible area of window
  2863. if (s.container.parents('.swiper-slide').length > 0 && s.container.parents('.swiper-slide-active').length === 0) {
  2864. return;
  2865. }
  2866. var windowScroll = {
  2867. left: window.pageXOffset,
  2868. top: window.pageYOffset
  2869. };
  2870. var windowWidth = window.innerWidth;
  2871. var windowHeight = window.innerHeight;
  2872. var swiperOffset = s.container.offset();
  2873. if (s.rtl) swiperOffset.left = swiperOffset.left - s.container[0].scrollLeft;
  2874. var swiperCoord = [
  2875. [swiperOffset.left, swiperOffset.top],
  2876. [swiperOffset.left + s.width, swiperOffset.top],
  2877. [swiperOffset.left, swiperOffset.top + s.height],
  2878. [swiperOffset.left + s.width, swiperOffset.top + s.height]
  2879. ];
  2880. for (var i = 0; i < swiperCoord.length; i++) {
  2881. var point = swiperCoord[i];
  2882. if (
  2883. point[0] >= windowScroll.left && point[0] <= windowScroll.left + windowWidth &&
  2884. point[1] >= windowScroll.top && point[1] <= windowScroll.top + windowHeight
  2885. ) {
  2886. inView = true;
  2887. }
  2888. }
  2889. if (!inView) return;
  2890. }
  2891. if (s.isHorizontal()) {
  2892. if (kc === 37 || kc === 39) {
  2893. if (e.preventDefault) e.preventDefault();
  2894. else e.returnValue = false;
  2895. }
  2896. if ((kc === 39 && !s.rtl) || (kc === 37 && s.rtl)) s.slideNext();
  2897. if ((kc === 37 && !s.rtl) || (kc === 39 && s.rtl)) s.slidePrev();
  2898. }
  2899. else {
  2900. if (kc === 38 || kc === 40) {
  2901. if (e.preventDefault) e.preventDefault();
  2902. else e.returnValue = false;
  2903. }
  2904. if (kc === 40) s.slideNext();
  2905. if (kc === 38) s.slidePrev();
  2906. }
  2907. }
  2908. s.disableKeyboardControl = function () {
  2909. s.params.keyboardControl = false;
  2910. $(document).off('keydown', handleKeyboard);
  2911. };
  2912. s.enableKeyboardControl = function () {
  2913. s.params.keyboardControl = true;
  2914. $(document).on('keydown', handleKeyboard);
  2915. };
  2916. /*=========================
  2917. Mousewheel Control
  2918. ===========================*/
  2919. s.mousewheel = {
  2920. event: false,
  2921. lastScrollTime: (new window.Date()).getTime()
  2922. };
  2923. if (s.params.mousewheelControl) {
  2924. try {
  2925. new window.WheelEvent('wheel');
  2926. s.mousewheel.event = 'wheel';
  2927. } catch (e) {
  2928. if (window.WheelEvent || (s.container[0] && 'wheel' in s.container[0])) {
  2929. s.mousewheel.event = 'wheel';
  2930. }
  2931. }
  2932. if (!s.mousewheel.event && window.WheelEvent) {
  2933. }
  2934. if (!s.mousewheel.event && document.onmousewheel !== undefined) {
  2935. s.mousewheel.event = 'mousewheel';
  2936. }
  2937. if (!s.mousewheel.event) {
  2938. s.mousewheel.event = 'DOMMouseScroll';
  2939. }
  2940. }
  2941. function handleMousewheel(e) {
  2942. if (e.originalEvent) e = e.originalEvent; //jquery fix
  2943. var we = s.mousewheel.event;
  2944. var delta = 0;
  2945. var rtlFactor = s.rtl ? -1 : 1;
  2946. //WebKits
  2947. if (we === 'mousewheel') {
  2948. if (s.params.mousewheelForceToAxis) {
  2949. if (s.isHorizontal()) {
  2950. if (Math.abs(e.wheelDeltaX) > Math.abs(e.wheelDeltaY)) delta = e.wheelDeltaX * rtlFactor;
  2951. else return;
  2952. }
  2953. else {
  2954. if (Math.abs(e.wheelDeltaY) > Math.abs(e.wheelDeltaX)) delta = e.wheelDeltaY;
  2955. else return;
  2956. }
  2957. }
  2958. else {
  2959. delta = Math.abs(e.wheelDeltaX) > Math.abs(e.wheelDeltaY) ? - e.wheelDeltaX * rtlFactor : - e.wheelDeltaY;
  2960. }
  2961. }
  2962. //Old FireFox
  2963. else if (we === 'DOMMouseScroll') delta = -e.detail;
  2964. //New FireFox
  2965. else if (we === 'wheel') {
  2966. if (s.params.mousewheelForceToAxis) {
  2967. if (s.isHorizontal()) {
  2968. if (Math.abs(e.deltaX) > Math.abs(e.deltaY)) delta = -e.deltaX * rtlFactor;
  2969. else return;
  2970. }
  2971. else {
  2972. if (Math.abs(e.deltaY) > Math.abs(e.deltaX)) delta = -e.deltaY;
  2973. else return;
  2974. }
  2975. }
  2976. else {
  2977. delta = Math.abs(e.deltaX) > Math.abs(e.deltaY) ? - e.deltaX * rtlFactor : - e.deltaY;
  2978. }
  2979. }
  2980. if (delta === 0) return;
  2981. if (s.params.mousewheelInvert) delta = -delta;
  2982. if (!s.params.freeMode) {
  2983. if ((new window.Date()).getTime() - s.mousewheel.lastScrollTime > 60) {
  2984. if (delta < 0) {
  2985. if ((!s.isEnd || s.params.loop) && !s.animating) s.slideNext();
  2986. else if (s.params.mousewheelReleaseOnEdges) return true;
  2987. }
  2988. else {
  2989. if ((!s.isBeginning || s.params.loop) && !s.animating) s.slidePrev();
  2990. else if (s.params.mousewheelReleaseOnEdges) return true;
  2991. }
  2992. }
  2993. s.mousewheel.lastScrollTime = (new window.Date()).getTime();
  2994. }
  2995. else {
  2996. //Freemode or scrollContainer:
  2997. var position = s.getWrapperTranslate() + delta * s.params.mousewheelSensitivity;
  2998. var wasBeginning = s.isBeginning,
  2999. wasEnd = s.isEnd;
  3000. if (position >= s.minTranslate()) position = s.minTranslate();
  3001. if (position <= s.maxTranslate()) position = s.maxTranslate();
  3002. s.setWrapperTransition(0);
  3003. s.setWrapperTranslate(position);
  3004. s.updateProgress();
  3005. s.updateActiveIndex();
  3006. if (!wasBeginning && s.isBeginning || !wasEnd && s.isEnd) {
  3007. s.updateClasses();
  3008. }
  3009. if (s.params.freeModeSticky) {
  3010. clearTimeout(s.mousewheel.timeout);
  3011. s.mousewheel.timeout = setTimeout(function () {
  3012. s.slideReset();
  3013. }, 300);
  3014. }
  3015. else {
  3016. if (s.params.lazyLoading && s.lazy) {
  3017. s.lazy.load();
  3018. }
  3019. }
  3020. // Return page scroll on edge positions
  3021. if (position === 0 || position === s.maxTranslate()) return;
  3022. }
  3023. if (s.params.autoplay) s.stopAutoplay();
  3024. if (e.preventDefault) e.preventDefault();
  3025. else e.returnValue = false;
  3026. return false;
  3027. }
  3028. s.disableMousewheelControl = function () {
  3029. if (!s.mousewheel.event) return false;
  3030. s.container.off(s.mousewheel.event, handleMousewheel);
  3031. return true;
  3032. };
  3033. s.enableMousewheelControl = function () {
  3034. if (!s.mousewheel.event) return false;
  3035. s.container.on(s.mousewheel.event, handleMousewheel);
  3036. return true;
  3037. };
  3038. /*=========================
  3039. Parallax
  3040. ===========================*/
  3041. function setParallaxTransform(el, progress) {
  3042. el = $(el);
  3043. var p, pX, pY;
  3044. var rtlFactor = s.rtl ? -1 : 1;
  3045. p = el.attr('data-swiper-parallax') || '0';
  3046. pX = el.attr('data-swiper-parallax-x');
  3047. pY = el.attr('data-swiper-parallax-y');
  3048. if (pX || pY) {
  3049. pX = pX || '0';
  3050. pY = pY || '0';
  3051. }
  3052. else {
  3053. if (s.isHorizontal()) {
  3054. pX = p;
  3055. pY = '0';
  3056. }
  3057. else {
  3058. pY = p;
  3059. pX = '0';
  3060. }
  3061. }
  3062. if ((pX).indexOf('%') >= 0) {
  3063. pX = parseInt(pX, 10) * progress * rtlFactor + '%';
  3064. }
  3065. else {
  3066. pX = pX * progress * rtlFactor + 'px' ;
  3067. }
  3068. if ((pY).indexOf('%') >= 0) {
  3069. pY = parseInt(pY, 10) * progress + '%';
  3070. }
  3071. else {
  3072. pY = pY * progress + 'px' ;
  3073. }
  3074. el.transform('translate3d(' + pX + ', ' + pY + ',0px)');
  3075. }
  3076. s.parallax = {
  3077. setTranslate: function () {
  3078. s.container.children('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y]').each(function(){
  3079. setParallaxTransform(this, s.progress);
  3080. });
  3081. s.slides.each(function () {
  3082. var slide = $(this);
  3083. slide.find('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y]').each(function () {
  3084. var progress = Math.min(Math.max(slide[0].progress, -1), 1);
  3085. setParallaxTransform(this, progress);
  3086. });
  3087. });
  3088. },
  3089. setTransition: function (duration) {
  3090. if (typeof duration === 'undefined') duration = s.params.speed;
  3091. s.container.find('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y]').each(function(){
  3092. var el = $(this);
  3093. var parallaxDuration = parseInt(el.attr('data-swiper-parallax-duration'), 10) || duration;
  3094. if (duration === 0) parallaxDuration = 0;
  3095. el.transition(parallaxDuration);
  3096. });
  3097. }
  3098. };
  3099. /*=========================
  3100. Plugins API. Collect all and init all plugins
  3101. ===========================*/
  3102. s._plugins = [];
  3103. for (var plugin in s.plugins) {
  3104. var p = s.plugins[plugin](s, s.params[plugin]);
  3105. if (p) s._plugins.push(p);
  3106. }
  3107. // Method to call all plugins event/method
  3108. s.callPlugins = function (eventName) {
  3109. for (var i = 0; i < s._plugins.length; i++) {
  3110. if (eventName in s._plugins[i]) {
  3111. s._plugins[i][eventName](arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]);
  3112. }
  3113. }
  3114. };
  3115. /*=========================
  3116. Events/Callbacks/Plugins Emitter
  3117. ===========================*/
  3118. function normalizeEventName (eventName) {
  3119. if (eventName.indexOf('on') !== 0) {
  3120. if (eventName[0] !== eventName[0].toUpperCase()) {
  3121. eventName = 'on' + eventName[0].toUpperCase() + eventName.substring(1);
  3122. }
  3123. else {
  3124. eventName = 'on' + eventName;
  3125. }
  3126. }
  3127. return eventName;
  3128. }
  3129. s.emitterEventListeners = {
  3130. };
  3131. s.emit = function (eventName) {
  3132. // Trigger callbacks
  3133. if (s.params[eventName]) {
  3134. s.params[eventName](arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]);
  3135. }
  3136. var i;
  3137. // Trigger events
  3138. if (s.emitterEventListeners[eventName]) {
  3139. for (i = 0; i < s.emitterEventListeners[eventName].length; i++) {
  3140. s.emitterEventListeners[eventName][i](arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]);
  3141. }
  3142. }
  3143. // Trigger plugins
  3144. if (s.callPlugins) s.callPlugins(eventName, arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]);
  3145. };
  3146. s.on = function (eventName, handler) {
  3147. eventName = normalizeEventName(eventName);
  3148. if (!s.emitterEventListeners[eventName]) s.emitterEventListeners[eventName] = [];
  3149. s.emitterEventListeners[eventName].push(handler);
  3150. return s;
  3151. };
  3152. s.off = function (eventName, handler) {
  3153. var i;
  3154. eventName = normalizeEventName(eventName);
  3155. if (typeof handler === 'undefined') {
  3156. // Remove all handlers for such event
  3157. s.emitterEventListeners[eventName] = [];
  3158. return s;
  3159. }
  3160. if (!s.emitterEventListeners[eventName] || s.emitterEventListeners[eventName].length === 0) return;
  3161. for (i = 0; i < s.emitterEventListeners[eventName].length; i++) {
  3162. if(s.emitterEventListeners[eventName][i] === handler) s.emitterEventListeners[eventName].splice(i, 1);
  3163. }
  3164. return s;
  3165. };
  3166. s.once = function (eventName, handler) {
  3167. eventName = normalizeEventName(eventName);
  3168. var _handler = function () {
  3169. handler(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]);
  3170. s.off(eventName, _handler);
  3171. };
  3172. s.on(eventName, _handler);
  3173. return s;
  3174. };
  3175. // Accessibility tools
  3176. s.a11y = {
  3177. makeFocusable: function ($el) {
  3178. $el.attr('tabIndex', '0');
  3179. return $el;
  3180. },
  3181. addRole: function ($el, role) {
  3182. $el.attr('role', role);
  3183. return $el;
  3184. },
  3185. addLabel: function ($el, label) {
  3186. $el.attr('aria-label', label);
  3187. return $el;
  3188. },
  3189. disable: function ($el) {
  3190. $el.attr('aria-disabled', true);
  3191. return $el;
  3192. },
  3193. enable: function ($el) {
  3194. $el.attr('aria-disabled', false);
  3195. return $el;
  3196. },
  3197. onEnterKey: function (event) {
  3198. if (event.keyCode !== 13) return;
  3199. if ($(event.target).is(s.params.nextButton)) {
  3200. s.onClickNext(event);
  3201. if (s.isEnd) {
  3202. s.a11y.notify(s.params.lastSlideMessage);
  3203. }
  3204. else {
  3205. s.a11y.notify(s.params.nextSlideMessage);
  3206. }
  3207. }
  3208. else if ($(event.target).is(s.params.prevButton)) {
  3209. s.onClickPrev(event);
  3210. if (s.isBeginning) {
  3211. s.a11y.notify(s.params.firstSlideMessage);
  3212. }
  3213. else {
  3214. s.a11y.notify(s.params.prevSlideMessage);
  3215. }
  3216. }
  3217. if ($(event.target).is('.' + s.params.bulletClass)) {
  3218. $(event.target)[0].click();
  3219. }
  3220. },
  3221. liveRegion: $('<span class="swiper-notification" aria-live="assertive" aria-atomic="true"></span>'),
  3222. notify: function (message) {
  3223. var notification = s.a11y.liveRegion;
  3224. if (notification.length === 0) return;
  3225. notification.html('');
  3226. notification.html(message);
  3227. },
  3228. init: function () {
  3229. // Setup accessibility
  3230. if (s.params.nextButton && s.nextButton && s.nextButton.length > 0) {
  3231. s.a11y.makeFocusable(s.nextButton);
  3232. s.a11y.addRole(s.nextButton, 'button');
  3233. s.a11y.addLabel(s.nextButton, s.params.nextSlideMessage);
  3234. }
  3235. if (s.params.prevButton && s.prevButton && s.prevButton.length > 0) {
  3236. s.a11y.makeFocusable(s.prevButton);
  3237. s.a11y.addRole(s.prevButton, 'button');
  3238. s.a11y.addLabel(s.prevButton, s.params.prevSlideMessage);
  3239. }
  3240. $(s.container).append(s.a11y.liveRegion);
  3241. },
  3242. initPagination: function () {
  3243. if (s.params.pagination && s.params.paginationClickable && s.bullets && s.bullets.length) {
  3244. s.bullets.each(function () {
  3245. var bullet = $(this);
  3246. s.a11y.makeFocusable(bullet);
  3247. s.a11y.addRole(bullet, 'button');
  3248. s.a11y.addLabel(bullet, s.params.paginationBulletMessage.replace(/{{index}}/, bullet.index() + 1));
  3249. });
  3250. }
  3251. },
  3252. destroy: function () {
  3253. if (s.a11y.liveRegion && s.a11y.liveRegion.length > 0) s.a11y.liveRegion.remove();
  3254. }
  3255. };
  3256. /*=========================
  3257. Init/Destroy
  3258. ===========================*/
  3259. s.init = function () {
  3260. if (s.params.loop) s.createLoop();
  3261. s.updateContainerSize();
  3262. s.updateSlidesSize();
  3263. s.updatePagination();
  3264. if (s.params.scrollbar && s.scrollbar) {
  3265. s.scrollbar.set();
  3266. if (s.params.scrollbarDraggable) {
  3267. s.scrollbar.enableDraggable();
  3268. }
  3269. }
  3270. if (s.params.effect !== 'slide' && s.effects[s.params.effect]) {
  3271. if (!s.params.loop) s.updateProgress();
  3272. s.effects[s.params.effect].setTranslate();
  3273. }
  3274. if (s.params.loop) {
  3275. s.slideTo(s.params.initialSlide + s.loopedSlides, 0, s.params.runCallbacksOnInit);
  3276. }
  3277. else {
  3278. s.slideTo(s.params.initialSlide, 0, s.params.runCallbacksOnInit);
  3279. if (s.params.initialSlide === 0) {
  3280. if (s.parallax && s.params.parallax) s.parallax.setTranslate();
  3281. if (s.lazy && s.params.lazyLoading) {
  3282. s.lazy.load();
  3283. s.lazy.initialImageLoaded = true;
  3284. }
  3285. }
  3286. }
  3287. s.attachEvents();
  3288. if (s.params.observer && s.support.observer) {
  3289. s.initObservers();
  3290. }
  3291. if (s.params.preloadImages && !s.params.lazyLoading) {
  3292. s.preloadImages();
  3293. }
  3294. if (s.params.autoplay) {
  3295. s.startAutoplay();
  3296. }
  3297. if (s.params.keyboardControl) {
  3298. if (s.enableKeyboardControl) s.enableKeyboardControl();
  3299. }
  3300. if (s.params.mousewheelControl) {
  3301. if (s.enableMousewheelControl) s.enableMousewheelControl();
  3302. }
  3303. if (s.params.hashnav) {
  3304. if (s.hashnav) s.hashnav.init();
  3305. }
  3306. if (s.params.a11y && s.a11y) s.a11y.init();
  3307. s.emit('onInit', s);
  3308. };
  3309. // Cleanup dynamic styles
  3310. s.cleanupStyles = function () {
  3311. // Container
  3312. s.container.removeClass(s.classNames.join(' ')).removeAttr('style');
  3313. // Wrapper
  3314. s.wrapper.removeAttr('style');
  3315. // Slides
  3316. if (s.slides && s.slides.length) {
  3317. s.slides
  3318. .removeClass([
  3319. s.params.slideVisibleClass,
  3320. s.params.slideActiveClass,
  3321. s.params.slideNextClass,
  3322. s.params.slidePrevClass
  3323. ].join(' '))
  3324. .removeAttr('style')
  3325. .removeAttr('data-swiper-column')
  3326. .removeAttr('data-swiper-row');
  3327. }
  3328. // Pagination/Bullets
  3329. if (s.paginationContainer && s.paginationContainer.length) {
  3330. s.paginationContainer.removeClass(s.params.paginationHiddenClass);
  3331. }
  3332. if (s.bullets && s.bullets.length) {
  3333. s.bullets.removeClass(s.params.bulletActiveClass);
  3334. }
  3335. // Buttons
  3336. if (s.params.prevButton) $(s.params.prevButton).removeClass(s.params.buttonDisabledClass);
  3337. if (s.params.nextButton) $(s.params.nextButton).removeClass(s.params.buttonDisabledClass);
  3338. // Scrollbar
  3339. if (s.params.scrollbar && s.scrollbar) {
  3340. if (s.scrollbar.track && s.scrollbar.track.length) s.scrollbar.track.removeAttr('style');
  3341. if (s.scrollbar.drag && s.scrollbar.drag.length) s.scrollbar.drag.removeAttr('style');
  3342. }
  3343. };
  3344. // Destroy
  3345. s.destroy = function (deleteInstance, cleanupStyles) {
  3346. // Detach evebts
  3347. s.detachEvents();
  3348. // Stop autoplay
  3349. s.stopAutoplay();
  3350. // Disable draggable
  3351. if (s.params.scrollbar && s.scrollbar) {
  3352. if (s.params.scrollbarDraggable) {
  3353. s.scrollbar.disableDraggable();
  3354. }
  3355. }
  3356. // Destroy loop
  3357. if (s.params.loop) {
  3358. s.destroyLoop();
  3359. }
  3360. // Cleanup styles
  3361. if (cleanupStyles) {
  3362. s.cleanupStyles();
  3363. }
  3364. // Disconnect observer
  3365. s.disconnectObservers();
  3366. // Disable keyboard/mousewheel
  3367. if (s.params.keyboardControl) {
  3368. if (s.disableKeyboardControl) s.disableKeyboardControl();
  3369. }
  3370. if (s.params.mousewheelControl) {
  3371. if (s.disableMousewheelControl) s.disableMousewheelControl();
  3372. }
  3373. // Disable a11y
  3374. if (s.params.a11y && s.a11y) s.a11y.destroy();
  3375. // Destroy callback
  3376. s.emit('onDestroy');
  3377. // Delete instance
  3378. if (deleteInstance !== false) s = null;
  3379. };
  3380. s.init();
  3381. // Return swiper instance
  3382. return s;
  3383. };
  3384. /*==================================================
  3385. Prototype
  3386. ====================================================*/
  3387. Swiper.prototype = {
  3388. isSafari: (function () {
  3389. var ua = navigator.userAgent.toLowerCase();
  3390. return (ua.indexOf('safari') >= 0 && ua.indexOf('chrome') < 0 && ua.indexOf('android') < 0);
  3391. })(),
  3392. isUiWebView: /(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(navigator.userAgent),
  3393. isArray: function (arr) {
  3394. return Object.prototype.toString.apply(arr) === '[object Array]';
  3395. },
  3396. /*==================================================
  3397. Browser
  3398. ====================================================*/
  3399. browser: {
  3400. ie: window.navigator.pointerEnabled || window.navigator.msPointerEnabled,
  3401. ieTouch: (window.navigator.msPointerEnabled && window.navigator.msMaxTouchPoints > 1) || (window.navigator.pointerEnabled && window.navigator.maxTouchPoints > 1)
  3402. },
  3403. /*==================================================
  3404. Devices
  3405. ====================================================*/
  3406. device: (function () {
  3407. var ua = navigator.userAgent;
  3408. var android = ua.match(/(Android);?[\s\/]+([\d.]+)?/);
  3409. var ipad = ua.match(/(iPad).*OS\s([\d_]+)/);
  3410. var ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/);
  3411. var iphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/);
  3412. return {
  3413. ios: ipad || iphone || ipod,
  3414. android: android
  3415. };
  3416. })(),
  3417. /*==================================================
  3418. Feature Detection
  3419. ====================================================*/
  3420. support: {
  3421. touch : (window.Modernizr && Modernizr.touch === true) || (function () {
  3422. return !!(('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch);
  3423. })(),
  3424. transforms3d : (window.Modernizr && Modernizr.csstransforms3d === true) || (function () {
  3425. var div = document.createElement('div').style;
  3426. return ('webkitPerspective' in div || 'MozPerspective' in div || 'OPerspective' in div || 'MsPerspective' in div || 'perspective' in div);
  3427. })(),
  3428. flexbox: (function () {
  3429. var div = document.createElement('div').style;
  3430. var styles = ('alignItems webkitAlignItems webkitBoxAlign msFlexAlign mozBoxAlign webkitFlexDirection msFlexDirection mozBoxDirection mozBoxOrient webkitBoxDirection webkitBoxOrient').split(' ');
  3431. for (var i = 0; i < styles.length; i++) {
  3432. if (styles[i] in div) return true;
  3433. }
  3434. })(),
  3435. observer: (function () {
  3436. return ('MutationObserver' in window || 'WebkitMutationObserver' in window);
  3437. })()
  3438. },
  3439. /*==================================================
  3440. Plugins
  3441. ====================================================*/
  3442. plugins: {}
  3443. };
  3444. /*===========================
  3445. Get Dom libraries
  3446. ===========================*/
  3447. var swiperDomPlugins = ['jQuery', 'Zepto', 'Dom7'];
  3448. for (var i = 0; i < swiperDomPlugins.length; i++) {
  3449. if (window[swiperDomPlugins[i]]) {
  3450. addLibraryPlugin(window[swiperDomPlugins[i]]);
  3451. }
  3452. }
  3453. // Required DOM Plugins
  3454. var domLib;
  3455. if (typeof Dom7 === 'undefined') {
  3456. domLib = window.Dom7 || window.Zepto || window.jQuery;
  3457. }
  3458. else {
  3459. domLib = Dom7;
  3460. }
  3461. /*===========================
  3462. Add .swiper plugin from Dom libraries
  3463. ===========================*/
  3464. function addLibraryPlugin(lib) {
  3465. lib.fn.swiper = function (params) {
  3466. var firstInstance;
  3467. lib(this).each(function () {
  3468. var s = new Swiper(this, params);
  3469. if (!firstInstance) firstInstance = s;
  3470. });
  3471. return firstInstance;
  3472. };
  3473. }
  3474. if (domLib) {
  3475. if (!('transitionEnd' in domLib.fn)) {
  3476. domLib.fn.transitionEnd = function (callback) {
  3477. var events = ['webkitTransitionEnd', 'transitionend', 'oTransitionEnd', 'MSTransitionEnd', 'msTransitionEnd'],
  3478. i, j, dom = this;
  3479. function fireCallBack(e) {
  3480. /*jshint validthis:true */
  3481. if (e.target !== this) return;
  3482. callback.call(this, e);
  3483. for (i = 0; i < events.length; i++) {
  3484. dom.off(events[i], fireCallBack);
  3485. }
  3486. }
  3487. if (callback) {
  3488. for (i = 0; i < events.length; i++) {
  3489. dom.on(events[i], fireCallBack);
  3490. }
  3491. }
  3492. return this;
  3493. };
  3494. }
  3495. if (!('transform' in domLib.fn)) {
  3496. domLib.fn.transform = function (transform) {
  3497. for (var i = 0; i < this.length; i++) {
  3498. var elStyle = this[i].style;
  3499. elStyle.webkitTransform = elStyle.MsTransform = elStyle.msTransform = elStyle.MozTransform = elStyle.OTransform = elStyle.transform = transform;
  3500. }
  3501. return this;
  3502. };
  3503. }
  3504. if (!('transition' in domLib.fn)) {
  3505. domLib.fn.transition = function (duration) {
  3506. if (typeof duration !== 'string') {
  3507. duration = duration + 'ms';
  3508. }
  3509. for (var i = 0; i < this.length; i++) {
  3510. var elStyle = this[i].style;
  3511. elStyle.webkitTransitionDuration = elStyle.MsTransitionDuration = elStyle.msTransitionDuration = elStyle.MozTransitionDuration = elStyle.OTransitionDuration = elStyle.transitionDuration = duration;
  3512. }
  3513. return this;
  3514. };
  3515. }
  3516. }
  3517. window.Swiper = Swiper;
  3518. })();
  3519. /*===========================
  3520. Swiper AMD Export
  3521. ===========================*/
  3522. if (typeof(module) !== 'undefined')
  3523. {
  3524. module.exports = window.Swiper;
  3525. }
  3526. else if (typeof define === 'function' && define.amd) {
  3527. define([], function () {
  3528. 'use strict';
  3529. return window.Swiper;
  3530. });
  3531. }
  3532. //# sourceMappingURL=maps/swiper.jquery.js.map