swiper.min.js 232 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375
  1. /**
  2. * Swiper 3.4.2
  3. * Most modern mobile touch slider and framework with hardware accelerated transitions
  4. *
  5. * http://www.idangero.us/swiper/
  6. *
  7. * Copyright 2017, Vladimir Kharlampidi
  8. * The iDangero.us
  9. * http://www.idangero.us/
  10. *
  11. * Licensed under MIT
  12. *
  13. * Released on: March 10, 2017
  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. freeModeMomentumVelocityRatio: 1,
  42. freeModeSticky: false,
  43. freeModeMinimumVelocity: 0.02,
  44. // Autoheight
  45. autoHeight: false,
  46. // Set wrapper width
  47. setWrapperSize: false,
  48. // Virtual Translate
  49. virtualTranslate: false,
  50. // Effects
  51. effect: 'slide', // 'slide' or 'fade' or 'cube' or 'coverflow' or 'flip'
  52. coverflow: {
  53. rotate: 50,
  54. stretch: 0,
  55. depth: 100,
  56. modifier: 1,
  57. slideShadows : true
  58. },
  59. flip: {
  60. slideShadows : true,
  61. limitRotation: true
  62. },
  63. cube: {
  64. slideShadows: true,
  65. shadow: true,
  66. shadowOffset: 20,
  67. shadowScale: 0.94
  68. },
  69. fade: {
  70. crossFade: false
  71. },
  72. // Parallax
  73. parallax: false,
  74. // Zoom
  75. zoom: false,
  76. zoomMax: 3,
  77. zoomMin: 1,
  78. zoomToggle: true,
  79. // Scrollbar
  80. scrollbar: null,
  81. scrollbarHide: true,
  82. scrollbarDraggable: false,
  83. scrollbarSnapOnRelease: false,
  84. // Keyboard Mousewheel
  85. keyboardControl: false,
  86. mousewheelControl: false,
  87. mousewheelReleaseOnEdges: false,
  88. mousewheelInvert: false,
  89. mousewheelForceToAxis: false,
  90. mousewheelSensitivity: 1,
  91. mousewheelEventsTarged: 'container',
  92. // Hash Navigation
  93. hashnav: false,
  94. hashnavWatchState: false,
  95. // History
  96. history: false,
  97. // Commong Nav State
  98. replaceState: false,
  99. // Breakpoints
  100. breakpoints: undefined,
  101. // Slides grid
  102. spaceBetween: 0,
  103. slidesPerView: 1,
  104. slidesPerColumn: 1,
  105. slidesPerColumnFill: 'column',
  106. slidesPerGroup: 1,
  107. centeredSlides: false,
  108. slidesOffsetBefore: 0, // in px
  109. slidesOffsetAfter: 0, // in px
  110. // Round length
  111. roundLengths: false,
  112. // Touches
  113. touchRatio: 1,
  114. touchAngle: 45,
  115. simulateTouch: true,
  116. shortSwipes: true,
  117. longSwipes: true,
  118. longSwipesRatio: 0.5,
  119. longSwipesMs: 300,
  120. followFinger: true,
  121. onlyExternal: false,
  122. threshold: 0,
  123. touchMoveStopPropagation: true,
  124. touchReleaseOnEdges: false,
  125. // Unique Navigation Elements
  126. uniqueNavElements: true,
  127. // Pagination
  128. pagination: null,
  129. paginationElement: 'span',
  130. paginationClickable: false,
  131. paginationHide: false,
  132. paginationBulletRender: null,
  133. paginationProgressRender: null,
  134. paginationFractionRender: null,
  135. paginationCustomRender: null,
  136. paginationType: 'bullets', // 'bullets' or 'progress' or 'fraction' or 'custom'
  137. // Resistance
  138. resistance: true,
  139. resistanceRatio: 0.85,
  140. // Next/prev buttons
  141. nextButton: null,
  142. prevButton: null,
  143. // Progress
  144. watchSlidesProgress: false,
  145. watchSlidesVisibility: false,
  146. // Cursor
  147. grabCursor: false,
  148. // Clicks
  149. preventClicks: true,
  150. preventClicksPropagation: true,
  151. slideToClickedSlide: false,
  152. // Lazy Loading
  153. lazyLoading: false,
  154. lazyLoadingInPrevNext: false,
  155. lazyLoadingInPrevNextAmount: 1,
  156. lazyLoadingOnTransitionStart: false,
  157. // Images
  158. preloadImages: true,
  159. updateOnImagesReady: true,
  160. // loop
  161. loop: false,
  162. loopAdditionalSlides: 0,
  163. loopedSlides: null,
  164. // Control
  165. control: undefined,
  166. controlInverse: false,
  167. controlBy: 'slide', //or 'container'
  168. normalizeSlideIndex: true,
  169. // Swiping/no swiping
  170. allowSwipeToPrev: true,
  171. allowSwipeToNext: true,
  172. swipeHandler: null, //'.swipe-handler',
  173. noSwiping: true,
  174. noSwipingClass: 'swiper-no-swiping',
  175. // Passive Listeners
  176. passiveListeners: true,
  177. // NS
  178. containerModifierClass: 'swiper-container-', // NEW
  179. slideClass: 'swiper-slide',
  180. slideActiveClass: 'swiper-slide-active',
  181. slideDuplicateActiveClass: 'swiper-slide-duplicate-active',
  182. slideVisibleClass: 'swiper-slide-visible',
  183. slideDuplicateClass: 'swiper-slide-duplicate',
  184. slideNextClass: 'swiper-slide-next',
  185. slideDuplicateNextClass: 'swiper-slide-duplicate-next',
  186. slidePrevClass: 'swiper-slide-prev',
  187. slideDuplicatePrevClass: 'swiper-slide-duplicate-prev',
  188. wrapperClass: 'swiper-wrapper',
  189. bulletClass: 'swiper-pagination-bullet',
  190. bulletActiveClass: 'swiper-pagination-bullet-active',
  191. buttonDisabledClass: 'swiper-button-disabled',
  192. paginationCurrentClass: 'swiper-pagination-current',
  193. paginationTotalClass: 'swiper-pagination-total',
  194. paginationHiddenClass: 'swiper-pagination-hidden',
  195. paginationProgressbarClass: 'swiper-pagination-progressbar',
  196. paginationClickableClass: 'swiper-pagination-clickable', // NEW
  197. paginationModifierClass: 'swiper-pagination-', // NEW
  198. lazyLoadingClass: 'swiper-lazy',
  199. lazyStatusLoadingClass: 'swiper-lazy-loading',
  200. lazyStatusLoadedClass: 'swiper-lazy-loaded',
  201. lazyPreloaderClass: 'swiper-lazy-preloader',
  202. notificationClass: 'swiper-notification',
  203. preloaderClass: 'preloader',
  204. zoomContainerClass: 'swiper-zoom-container',
  205. // Observer
  206. observer: false,
  207. observeParents: false,
  208. // Accessibility
  209. a11y: false,
  210. prevSlideMessage: 'Previous slide',
  211. nextSlideMessage: 'Next slide',
  212. firstSlideMessage: 'This is the first slide',
  213. lastSlideMessage: 'This is the last slide',
  214. paginationBulletMessage: 'Go to slide {{index}}',
  215. // Callbacks
  216. runCallbacksOnInit: true
  217. /*
  218. Callbacks:
  219. onInit: function (swiper)
  220. onDestroy: function (swiper)
  221. onBeforeResize: function (swiper)
  222. onAfterResize: function (swiper)
  223. onClick: function (swiper, e)
  224. onTap: function (swiper, e)
  225. onDoubleTap: function (swiper, e)
  226. onSliderMove: function (swiper, e)
  227. onSlideChangeStart: function (swiper)
  228. onSlideChangeEnd: function (swiper)
  229. onTransitionStart: function (swiper)
  230. onTransitionEnd: function (swiper)
  231. onImagesReady: function (swiper)
  232. onProgress: function (swiper, progress)
  233. onTouchStart: function (swiper, e)
  234. onTouchMove: function (swiper, e)
  235. onTouchMoveOpposite: function (swiper, e)
  236. onTouchEnd: function (swiper, e)
  237. onReachBeginning: function (swiper)
  238. onReachEnd: function (swiper)
  239. onSetTransition: function (swiper, duration)
  240. onSetTranslate: function (swiper, translate)
  241. onAutoplayStart: function (swiper)
  242. onAutoplayStop: function (swiper),
  243. onLazyImageLoad: function (swiper, slide, image)
  244. onLazyImageReady: function (swiper, slide, image)
  245. onKeyPress: function (swiper, keyCode)
  246. */
  247. };
  248. var initialVirtualTranslate = params && params.virtualTranslate;
  249. params = params || {};
  250. var originalParams = {};
  251. for (var param in params) {
  252. 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))) {
  253. originalParams[param] = {};
  254. for (var deepParam in params[param]) {
  255. originalParams[param][deepParam] = params[param][deepParam];
  256. }
  257. }
  258. else {
  259. originalParams[param] = params[param];
  260. }
  261. }
  262. for (var def in defaults) {
  263. if (typeof params[def] === 'undefined') {
  264. params[def] = defaults[def];
  265. }
  266. else if (typeof params[def] === 'object') {
  267. for (var deepDef in defaults[def]) {
  268. if (typeof params[def][deepDef] === 'undefined') {
  269. params[def][deepDef] = defaults[def][deepDef];
  270. }
  271. }
  272. }
  273. }
  274. // Swiper
  275. var s = this;
  276. // Params
  277. s.params = params;
  278. s.originalParams = originalParams;
  279. // Classname
  280. s.classNames = [];
  281. /*=========================
  282. Dom Library and plugins
  283. ===========================*/
  284. if (typeof $ !== 'undefined' && typeof Dom7 !== 'undefined'){
  285. $ = Dom7;
  286. }
  287. if (typeof $ === 'undefined') {
  288. if (typeof Dom7 === 'undefined') {
  289. $ = window.Dom7 || window.Zepto || window.jQuery;
  290. }
  291. else {
  292. $ = Dom7;
  293. }
  294. if (!$) return;
  295. }
  296. // Export it to Swiper instance
  297. s.$ = $;
  298. /*=========================
  299. Breakpoints
  300. ===========================*/
  301. s.currentBreakpoint = undefined;
  302. s.getActiveBreakpoint = function () {
  303. //Get breakpoint for window width
  304. if (!s.params.breakpoints) return false;
  305. var breakpoint = false;
  306. var points = [], point;
  307. for ( point in s.params.breakpoints ) {
  308. if (s.params.breakpoints.hasOwnProperty(point)) {
  309. points.push(point);
  310. }
  311. }
  312. points.sort(function (a, b) {
  313. return parseInt(a, 10) > parseInt(b, 10);
  314. });
  315. for (var i = 0; i < points.length; i++) {
  316. point = points[i];
  317. if (point >= window.innerWidth && !breakpoint) {
  318. breakpoint = point;
  319. }
  320. }
  321. return breakpoint || 'max';
  322. };
  323. s.setBreakpoint = function () {
  324. //Set breakpoint for window width and update parameters
  325. var breakpoint = s.getActiveBreakpoint();
  326. if (breakpoint && s.currentBreakpoint !== breakpoint) {
  327. var breakPointsParams = breakpoint in s.params.breakpoints ? s.params.breakpoints[breakpoint] : s.originalParams;
  328. var needsReLoop = s.params.loop && (breakPointsParams.slidesPerView !== s.params.slidesPerView);
  329. for ( var param in breakPointsParams ) {
  330. s.params[param] = breakPointsParams[param];
  331. }
  332. s.currentBreakpoint = breakpoint;
  333. if(needsReLoop && s.destroyLoop) {
  334. s.reLoop(true);
  335. }
  336. }
  337. };
  338. // Set breakpoint on load
  339. if (s.params.breakpoints) {
  340. s.setBreakpoint();
  341. }
  342. /*=========================
  343. Preparation - Define Container, Wrapper and Pagination
  344. ===========================*/
  345. s.container = $(container);
  346. if (s.container.length === 0) return;
  347. if (s.container.length > 1) {
  348. var swipers = [];
  349. s.container.each(function () {
  350. var container = this;
  351. swipers.push(new Swiper(this, params));
  352. });
  353. return swipers;
  354. }
  355. // Save instance in container HTML Element and in data
  356. s.container[0].swiper = s;
  357. s.container.data('swiper', s);
  358. s.classNames.push(s.params.containerModifierClass + s.params.direction);
  359. if (s.params.freeMode) {
  360. s.classNames.push(s.params.containerModifierClass + 'free-mode');
  361. }
  362. if (!s.support.flexbox) {
  363. s.classNames.push(s.params.containerModifierClass + 'no-flexbox');
  364. s.params.slidesPerColumn = 1;
  365. }
  366. if (s.params.autoHeight) {
  367. s.classNames.push(s.params.containerModifierClass + 'autoheight');
  368. }
  369. // Enable slides progress when required
  370. if (s.params.parallax || s.params.watchSlidesVisibility) {
  371. s.params.watchSlidesProgress = true;
  372. }
  373. // Max resistance when touchReleaseOnEdges
  374. if (s.params.touchReleaseOnEdges) {
  375. s.params.resistanceRatio = 0;
  376. }
  377. // Coverflow / 3D
  378. if (['cube', 'coverflow', 'flip'].indexOf(s.params.effect) >= 0) {
  379. if (s.support.transforms3d) {
  380. s.params.watchSlidesProgress = true;
  381. s.classNames.push(s.params.containerModifierClass + '3d');
  382. }
  383. else {
  384. s.params.effect = 'slide';
  385. }
  386. }
  387. if (s.params.effect !== 'slide') {
  388. s.classNames.push(s.params.containerModifierClass + s.params.effect);
  389. }
  390. if (s.params.effect === 'cube') {
  391. s.params.resistanceRatio = 0;
  392. s.params.slidesPerView = 1;
  393. s.params.slidesPerColumn = 1;
  394. s.params.slidesPerGroup = 1;
  395. s.params.centeredSlides = false;
  396. s.params.spaceBetween = 0;
  397. s.params.virtualTranslate = true;
  398. }
  399. if (s.params.effect === 'fade' || s.params.effect === 'flip') {
  400. s.params.slidesPerView = 1;
  401. s.params.slidesPerColumn = 1;
  402. s.params.slidesPerGroup = 1;
  403. s.params.watchSlidesProgress = true;
  404. s.params.spaceBetween = 0;
  405. if (typeof initialVirtualTranslate === 'undefined') {
  406. s.params.virtualTranslate = true;
  407. }
  408. }
  409. // Grab Cursor
  410. if (s.params.grabCursor && s.support.touch) {
  411. s.params.grabCursor = false;
  412. }
  413. // Wrapper
  414. s.wrapper = s.container.children('.' + s.params.wrapperClass);
  415. // Pagination
  416. if (s.params.pagination) {
  417. s.paginationContainer = $(s.params.pagination);
  418. if (s.params.uniqueNavElements && typeof s.params.pagination === 'string' && s.paginationContainer.length > 1 && s.container.find(s.params.pagination).length === 1) {
  419. s.paginationContainer = s.container.find(s.params.pagination);
  420. }
  421. if (s.params.paginationType === 'bullets' && s.params.paginationClickable) {
  422. s.paginationContainer.addClass(s.params.paginationModifierClass + 'clickable');
  423. }
  424. else {
  425. s.params.paginationClickable = false;
  426. }
  427. s.paginationContainer.addClass(s.params.paginationModifierClass + s.params.paginationType);
  428. }
  429. // Next/Prev Buttons
  430. if (s.params.nextButton || s.params.prevButton) {
  431. if (s.params.nextButton) {
  432. s.nextButton = $(s.params.nextButton);
  433. if (s.params.uniqueNavElements && typeof s.params.nextButton === 'string' && s.nextButton.length > 1 && s.container.find(s.params.nextButton).length === 1) {
  434. s.nextButton = s.container.find(s.params.nextButton);
  435. }
  436. }
  437. if (s.params.prevButton) {
  438. s.prevButton = $(s.params.prevButton);
  439. if (s.params.uniqueNavElements && typeof s.params.prevButton === 'string' && s.prevButton.length > 1 && s.container.find(s.params.prevButton).length === 1) {
  440. s.prevButton = s.container.find(s.params.prevButton);
  441. }
  442. }
  443. }
  444. // Is Horizontal
  445. s.isHorizontal = function () {
  446. return s.params.direction === 'horizontal';
  447. };
  448. // s.isH = isH;
  449. // RTL
  450. s.rtl = s.isHorizontal() && (s.container[0].dir.toLowerCase() === 'rtl' || s.container.css('direction') === 'rtl');
  451. if (s.rtl) {
  452. s.classNames.push(s.params.containerModifierClass + 'rtl');
  453. }
  454. // Wrong RTL support
  455. if (s.rtl) {
  456. s.wrongRTL = s.wrapper.css('display') === '-webkit-box';
  457. }
  458. // Columns
  459. if (s.params.slidesPerColumn > 1) {
  460. s.classNames.push(s.params.containerModifierClass + 'multirow');
  461. }
  462. // Check for Android
  463. if (s.device.android) {
  464. s.classNames.push(s.params.containerModifierClass + 'android');
  465. }
  466. // Add classes
  467. s.container.addClass(s.classNames.join(' '));
  468. // Translate
  469. s.translate = 0;
  470. // Progress
  471. s.progress = 0;
  472. // Velocity
  473. s.velocity = 0;
  474. /*=========================
  475. Locks, unlocks
  476. ===========================*/
  477. s.lockSwipeToNext = function () {
  478. s.params.allowSwipeToNext = false;
  479. if (s.params.allowSwipeToPrev === false && s.params.grabCursor) {
  480. s.unsetGrabCursor();
  481. }
  482. };
  483. s.lockSwipeToPrev = function () {
  484. s.params.allowSwipeToPrev = false;
  485. if (s.params.allowSwipeToNext === false && s.params.grabCursor) {
  486. s.unsetGrabCursor();
  487. }
  488. };
  489. s.lockSwipes = function () {
  490. s.params.allowSwipeToNext = s.params.allowSwipeToPrev = false;
  491. if (s.params.grabCursor) s.unsetGrabCursor();
  492. };
  493. s.unlockSwipeToNext = function () {
  494. s.params.allowSwipeToNext = true;
  495. if (s.params.allowSwipeToPrev === true && s.params.grabCursor) {
  496. s.setGrabCursor();
  497. }
  498. };
  499. s.unlockSwipeToPrev = function () {
  500. s.params.allowSwipeToPrev = true;
  501. if (s.params.allowSwipeToNext === true && s.params.grabCursor) {
  502. s.setGrabCursor();
  503. }
  504. };
  505. s.unlockSwipes = function () {
  506. s.params.allowSwipeToNext = s.params.allowSwipeToPrev = true;
  507. if (s.params.grabCursor) s.setGrabCursor();
  508. };
  509. /*=========================
  510. Round helper
  511. ===========================*/
  512. function round(a) {
  513. return Math.floor(a);
  514. }
  515. /*=========================
  516. Set grab cursor
  517. ===========================*/
  518. s.setGrabCursor = function(moving) {
  519. s.container[0].style.cursor = 'move';
  520. s.container[0].style.cursor = moving ? '-webkit-grabbing' : '-webkit-grab';
  521. s.container[0].style.cursor = moving ? '-moz-grabbin' : '-moz-grab';
  522. s.container[0].style.cursor = moving ? 'grabbing': 'grab';
  523. };
  524. s.unsetGrabCursor = function () {
  525. s.container[0].style.cursor = '';
  526. };
  527. if (s.params.grabCursor) {
  528. s.setGrabCursor();
  529. }
  530. /*=========================
  531. Update on Images Ready
  532. ===========================*/
  533. s.imagesToLoad = [];
  534. s.imagesLoaded = 0;
  535. s.loadImage = function (imgElement, src, srcset, sizes, checkForComplete, callback) {
  536. var image;
  537. function onReady () {
  538. if (callback) callback();
  539. }
  540. if (!imgElement.complete || !checkForComplete) {
  541. if (src) {
  542. image = new window.Image();
  543. image.onload = onReady;
  544. image.onerror = onReady;
  545. if (sizes) {
  546. image.sizes = sizes;
  547. }
  548. if (srcset) {
  549. image.srcset = srcset;
  550. }
  551. if (src) {
  552. image.src = src;
  553. }
  554. } else {
  555. onReady();
  556. }
  557. } else {//image already loaded...
  558. onReady();
  559. }
  560. };
  561. s.preloadImages = function () {
  562. s.imagesToLoad = s.container.find('img');
  563. function _onReady() {
  564. if (typeof s === 'undefined' || s === null || !s) return;
  565. if (s.imagesLoaded !== undefined) s.imagesLoaded++;
  566. if (s.imagesLoaded === s.imagesToLoad.length) {
  567. if (s.params.updateOnImagesReady) s.update();
  568. s.emit('onImagesReady', s);
  569. }
  570. }
  571. for (var i = 0; i < s.imagesToLoad.length; i++) {
  572. s.loadImage(s.imagesToLoad[i], (s.imagesToLoad[i].currentSrc || s.imagesToLoad[i].getAttribute('src')), (s.imagesToLoad[i].srcset || s.imagesToLoad[i].getAttribute('srcset')), s.imagesToLoad[i].sizes || s.imagesToLoad[i].getAttribute('sizes'), true, _onReady);
  573. }
  574. };
  575. /*=========================
  576. Autoplay
  577. ===========================*/
  578. s.autoplayTimeoutId = undefined;
  579. s.autoplaying = false;
  580. s.autoplayPaused = false;
  581. function autoplay() {
  582. var autoplayDelay = s.params.autoplay;
  583. var activeSlide = s.slides.eq(s.activeIndex);
  584. if (activeSlide.attr('data-swiper-autoplay')) {
  585. autoplayDelay = activeSlide.attr('data-swiper-autoplay') || s.params.autoplay;
  586. }
  587. s.autoplayTimeoutId = setTimeout(function () {
  588. if (s.params.loop) {
  589. s.fixLoop();
  590. s._slideNext();
  591. s.emit('onAutoplay', s);
  592. }
  593. else {
  594. if (!s.isEnd) {
  595. s._slideNext();
  596. s.emit('onAutoplay', s);
  597. }
  598. else {
  599. if (!params.autoplayStopOnLast) {
  600. s._slideTo(0);
  601. s.emit('onAutoplay', s);
  602. }
  603. else {
  604. s.stopAutoplay();
  605. }
  606. }
  607. }
  608. }, autoplayDelay);
  609. }
  610. s.startAutoplay = function () {
  611. if (typeof s.autoplayTimeoutId !== 'undefined') return false;
  612. if (!s.params.autoplay) return false;
  613. if (s.autoplaying) return false;
  614. s.autoplaying = true;
  615. s.emit('onAutoplayStart', s);
  616. autoplay();
  617. };
  618. s.stopAutoplay = function (internal) {
  619. if (!s.autoplayTimeoutId) return;
  620. if (s.autoplayTimeoutId) clearTimeout(s.autoplayTimeoutId);
  621. s.autoplaying = false;
  622. s.autoplayTimeoutId = undefined;
  623. s.emit('onAutoplayStop', s);
  624. };
  625. s.pauseAutoplay = function (speed) {
  626. if (s.autoplayPaused) return;
  627. if (s.autoplayTimeoutId) clearTimeout(s.autoplayTimeoutId);
  628. s.autoplayPaused = true;
  629. if (speed === 0) {
  630. s.autoplayPaused = false;
  631. autoplay();
  632. }
  633. else {
  634. s.wrapper.transitionEnd(function () {
  635. if (!s) return;
  636. s.autoplayPaused = false;
  637. if (!s.autoplaying) {
  638. s.stopAutoplay();
  639. }
  640. else {
  641. autoplay();
  642. }
  643. });
  644. }
  645. };
  646. /*=========================
  647. Min/Max Translate
  648. ===========================*/
  649. s.minTranslate = function () {
  650. return (-s.snapGrid[0]);
  651. };
  652. s.maxTranslate = function () {
  653. return (-s.snapGrid[s.snapGrid.length - 1]);
  654. };
  655. /*=========================
  656. Slider/slides sizes
  657. ===========================*/
  658. s.updateAutoHeight = function () {
  659. var activeSlides = [];
  660. var newHeight = 0;
  661. var i;
  662. // Find slides currently in view
  663. if(s.params.slidesPerView !== 'auto' && s.params.slidesPerView > 1) {
  664. for (i = 0; i < Math.ceil(s.params.slidesPerView); i++) {
  665. var index = s.activeIndex + i;
  666. if(index > s.slides.length) break;
  667. activeSlides.push(s.slides.eq(index)[0]);
  668. }
  669. } else {
  670. activeSlides.push(s.slides.eq(s.activeIndex)[0]);
  671. }
  672. // Find new height from heighest slide in view
  673. for (i = 0; i < activeSlides.length; i++) {
  674. if (typeof activeSlides[i] !== 'undefined') {
  675. var height = activeSlides[i].offsetHeight;
  676. newHeight = height > newHeight ? height : newHeight;
  677. }
  678. }
  679. // Update Height
  680. if (newHeight) s.wrapper.css('height', newHeight + 'px');
  681. };
  682. s.updateContainerSize = function () {
  683. var width, height;
  684. if (typeof s.params.width !== 'undefined') {
  685. width = s.params.width;
  686. }
  687. else {
  688. width = s.container[0].clientWidth;
  689. }
  690. if (typeof s.params.height !== 'undefined') {
  691. height = s.params.height;
  692. }
  693. else {
  694. height = s.container[0].clientHeight;
  695. }
  696. if (width === 0 && s.isHorizontal() || height === 0 && !s.isHorizontal()) {
  697. return;
  698. }
  699. //Subtract paddings
  700. width = width - parseInt(s.container.css('padding-left'), 10) - parseInt(s.container.css('padding-right'), 10);
  701. height = height - parseInt(s.container.css('padding-top'), 10) - parseInt(s.container.css('padding-bottom'), 10);
  702. // Store values
  703. s.width = width;
  704. s.height = height;
  705. s.size = s.isHorizontal() ? s.width : s.height;
  706. };
  707. s.updateSlidesSize = function () {
  708. s.slides = s.wrapper.children('.' + s.params.slideClass);
  709. s.snapGrid = [];
  710. s.slidesGrid = [];
  711. s.slidesSizesGrid = [];
  712. var spaceBetween = s.params.spaceBetween,
  713. slidePosition = -s.params.slidesOffsetBefore,
  714. i,
  715. prevSlideSize = 0,
  716. index = 0;
  717. if (typeof s.size === 'undefined') return;
  718. if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) {
  719. spaceBetween = parseFloat(spaceBetween.replace('%', '')) / 100 * s.size;
  720. }
  721. s.virtualSize = -spaceBetween;
  722. // reset margins
  723. if (s.rtl) s.slides.css({marginLeft: '', marginTop: ''});
  724. else s.slides.css({marginRight: '', marginBottom: ''});
  725. var slidesNumberEvenToRows;
  726. if (s.params.slidesPerColumn > 1) {
  727. if (Math.floor(s.slides.length / s.params.slidesPerColumn) === s.slides.length / s.params.slidesPerColumn) {
  728. slidesNumberEvenToRows = s.slides.length;
  729. }
  730. else {
  731. slidesNumberEvenToRows = Math.ceil(s.slides.length / s.params.slidesPerColumn) * s.params.slidesPerColumn;
  732. }
  733. if (s.params.slidesPerView !== 'auto' && s.params.slidesPerColumnFill === 'row') {
  734. slidesNumberEvenToRows = Math.max(slidesNumberEvenToRows, s.params.slidesPerView * s.params.slidesPerColumn);
  735. }
  736. }
  737. // Calc slides
  738. var slideSize;
  739. var slidesPerColumn = s.params.slidesPerColumn;
  740. var slidesPerRow = slidesNumberEvenToRows / slidesPerColumn;
  741. var numFullColumns = slidesPerRow - (s.params.slidesPerColumn * slidesPerRow - s.slides.length);
  742. for (i = 0; i < s.slides.length; i++) {
  743. slideSize = 0;
  744. var slide = s.slides.eq(i);
  745. if (s.params.slidesPerColumn > 1) {
  746. // Set slides order
  747. var newSlideOrderIndex;
  748. var column, row;
  749. if (s.params.slidesPerColumnFill === 'column') {
  750. column = Math.floor(i / slidesPerColumn);
  751. row = i - column * slidesPerColumn;
  752. if (column > numFullColumns || (column === numFullColumns && row === slidesPerColumn-1)) {
  753. if (++row >= slidesPerColumn) {
  754. row = 0;
  755. column++;
  756. }
  757. }
  758. newSlideOrderIndex = column + row * slidesNumberEvenToRows / slidesPerColumn;
  759. slide
  760. .css({
  761. '-webkit-box-ordinal-group': newSlideOrderIndex,
  762. '-moz-box-ordinal-group': newSlideOrderIndex,
  763. '-ms-flex-order': newSlideOrderIndex,
  764. '-webkit-order': newSlideOrderIndex,
  765. 'order': newSlideOrderIndex
  766. });
  767. }
  768. else {
  769. row = Math.floor(i / slidesPerRow);
  770. column = i - row * slidesPerRow;
  771. }
  772. slide
  773. .css(
  774. 'margin-' + (s.isHorizontal() ? 'top' : 'left'),
  775. (row !== 0 && s.params.spaceBetween) && (s.params.spaceBetween + 'px')
  776. )
  777. .attr('data-swiper-column', column)
  778. .attr('data-swiper-row', row);
  779. }
  780. if (slide.css('display') === 'none') continue;
  781. if (s.params.slidesPerView === 'auto') {
  782. slideSize = s.isHorizontal() ? slide.outerWidth(true) : slide.outerHeight(true);
  783. if (s.params.roundLengths) slideSize = round(slideSize);
  784. }
  785. else {
  786. slideSize = (s.size - (s.params.slidesPerView - 1) * spaceBetween) / s.params.slidesPerView;
  787. if (s.params.roundLengths) slideSize = round(slideSize);
  788. if (s.isHorizontal()) {
  789. s.slides[i].style.width = slideSize + 'px';
  790. }
  791. else {
  792. s.slides[i].style.height = slideSize + 'px';
  793. }
  794. }
  795. s.slides[i].swiperSlideSize = slideSize;
  796. s.slidesSizesGrid.push(slideSize);
  797. if (s.params.centeredSlides) {
  798. slidePosition = slidePosition + slideSize / 2 + prevSlideSize / 2 + spaceBetween;
  799. if(prevSlideSize === 0 && i !== 0) slidePosition = slidePosition - s.size / 2 - spaceBetween;
  800. if (i === 0) slidePosition = slidePosition - s.size / 2 - spaceBetween;
  801. if (Math.abs(slidePosition) < 1 / 1000) slidePosition = 0;
  802. if ((index) % s.params.slidesPerGroup === 0) s.snapGrid.push(slidePosition);
  803. s.slidesGrid.push(slidePosition);
  804. }
  805. else {
  806. if ((index) % s.params.slidesPerGroup === 0) s.snapGrid.push(slidePosition);
  807. s.slidesGrid.push(slidePosition);
  808. slidePosition = slidePosition + slideSize + spaceBetween;
  809. }
  810. s.virtualSize += slideSize + spaceBetween;
  811. prevSlideSize = slideSize;
  812. index ++;
  813. }
  814. s.virtualSize = Math.max(s.virtualSize, s.size) + s.params.slidesOffsetAfter;
  815. var newSlidesGrid;
  816. if (
  817. s.rtl && s.wrongRTL && (s.params.effect === 'slide' || s.params.effect === 'coverflow')) {
  818. s.wrapper.css({width: s.virtualSize + s.params.spaceBetween + 'px'});
  819. }
  820. if (!s.support.flexbox || s.params.setWrapperSize) {
  821. if (s.isHorizontal()) s.wrapper.css({width: s.virtualSize + s.params.spaceBetween + 'px'});
  822. else s.wrapper.css({height: s.virtualSize + s.params.spaceBetween + 'px'});
  823. }
  824. if (s.params.slidesPerColumn > 1) {
  825. s.virtualSize = (slideSize + s.params.spaceBetween) * slidesNumberEvenToRows;
  826. s.virtualSize = Math.ceil(s.virtualSize / s.params.slidesPerColumn) - s.params.spaceBetween;
  827. if (s.isHorizontal()) s.wrapper.css({width: s.virtualSize + s.params.spaceBetween + 'px'});
  828. else s.wrapper.css({height: s.virtualSize + s.params.spaceBetween + 'px'});
  829. if (s.params.centeredSlides) {
  830. newSlidesGrid = [];
  831. for (i = 0; i < s.snapGrid.length; i++) {
  832. if (s.snapGrid[i] < s.virtualSize + s.snapGrid[0]) newSlidesGrid.push(s.snapGrid[i]);
  833. }
  834. s.snapGrid = newSlidesGrid;
  835. }
  836. }
  837. // Remove last grid elements depending on width
  838. if (!s.params.centeredSlides) {
  839. newSlidesGrid = [];
  840. for (i = 0; i < s.snapGrid.length; i++) {
  841. if (s.snapGrid[i] <= s.virtualSize - s.size) {
  842. newSlidesGrid.push(s.snapGrid[i]);
  843. }
  844. }
  845. s.snapGrid = newSlidesGrid;
  846. if (Math.floor(s.virtualSize - s.size) - Math.floor(s.snapGrid[s.snapGrid.length - 1]) > 1) {
  847. s.snapGrid.push(s.virtualSize - s.size);
  848. }
  849. }
  850. if (s.snapGrid.length === 0) s.snapGrid = [0];
  851. if (s.params.spaceBetween !== 0) {
  852. if (s.isHorizontal()) {
  853. if (s.rtl) s.slides.css({marginLeft: spaceBetween + 'px'});
  854. else s.slides.css({marginRight: spaceBetween + 'px'});
  855. }
  856. else s.slides.css({marginBottom: spaceBetween + 'px'});
  857. }
  858. if (s.params.watchSlidesProgress) {
  859. s.updateSlidesOffset();
  860. }
  861. };
  862. s.updateSlidesOffset = function () {
  863. for (var i = 0; i < s.slides.length; i++) {
  864. s.slides[i].swiperSlideOffset = s.isHorizontal() ? s.slides[i].offsetLeft : s.slides[i].offsetTop;
  865. }
  866. };
  867. /*=========================
  868. Dynamic Slides Per View
  869. ===========================*/
  870. s.currentSlidesPerView = function () {
  871. var spv = 1, i, j;
  872. if (s.params.centeredSlides) {
  873. var size = s.slides[s.activeIndex].swiperSlideSize;
  874. var breakLoop;
  875. for (i = s.activeIndex + 1; i < s.slides.length; i++) {
  876. if (s.slides[i] && !breakLoop) {
  877. size += s.slides[i].swiperSlideSize;
  878. spv ++;
  879. if (size > s.size) breakLoop = true;
  880. }
  881. }
  882. for (j = s.activeIndex - 1; j >= 0; j--) {
  883. if (s.slides[j] && !breakLoop) {
  884. size += s.slides[j].swiperSlideSize;
  885. spv ++;
  886. if (size > s.size) breakLoop = true;
  887. }
  888. }
  889. }
  890. else {
  891. for (i = s.activeIndex + 1; i < s.slides.length; i++) {
  892. if (s.slidesGrid[i] - s.slidesGrid[s.activeIndex] < s.size) {
  893. spv++;
  894. }
  895. }
  896. }
  897. return spv;
  898. };
  899. /*=========================
  900. Slider/slides progress
  901. ===========================*/
  902. s.updateSlidesProgress = function (translate) {
  903. if (typeof translate === 'undefined') {
  904. translate = s.translate || 0;
  905. }
  906. if (s.slides.length === 0) return;
  907. if (typeof s.slides[0].swiperSlideOffset === 'undefined') s.updateSlidesOffset();
  908. var offsetCenter = -translate;
  909. if (s.rtl) offsetCenter = translate;
  910. // Visible Slides
  911. s.slides.removeClass(s.params.slideVisibleClass);
  912. for (var i = 0; i < s.slides.length; i++) {
  913. var slide = s.slides[i];
  914. var slideProgress = (offsetCenter + (s.params.centeredSlides ? s.minTranslate() : 0) - slide.swiperSlideOffset) / (slide.swiperSlideSize + s.params.spaceBetween);
  915. if (s.params.watchSlidesVisibility) {
  916. var slideBefore = -(offsetCenter - slide.swiperSlideOffset);
  917. var slideAfter = slideBefore + s.slidesSizesGrid[i];
  918. var isVisible =
  919. (slideBefore >= 0 && slideBefore < s.size) ||
  920. (slideAfter > 0 && slideAfter <= s.size) ||
  921. (slideBefore <= 0 && slideAfter >= s.size);
  922. if (isVisible) {
  923. s.slides.eq(i).addClass(s.params.slideVisibleClass);
  924. }
  925. }
  926. slide.progress = s.rtl ? -slideProgress : slideProgress;
  927. }
  928. };
  929. s.updateProgress = function (translate) {
  930. if (typeof translate === 'undefined') {
  931. translate = s.translate || 0;
  932. }
  933. var translatesDiff = s.maxTranslate() - s.minTranslate();
  934. var wasBeginning = s.isBeginning;
  935. var wasEnd = s.isEnd;
  936. if (translatesDiff === 0) {
  937. s.progress = 0;
  938. s.isBeginning = s.isEnd = true;
  939. }
  940. else {
  941. s.progress = (translate - s.minTranslate()) / (translatesDiff);
  942. s.isBeginning = s.progress <= 0;
  943. s.isEnd = s.progress >= 1;
  944. }
  945. if (s.isBeginning && !wasBeginning) s.emit('onReachBeginning', s);
  946. if (s.isEnd && !wasEnd) s.emit('onReachEnd', s);
  947. if (s.params.watchSlidesProgress) s.updateSlidesProgress(translate);
  948. s.emit('onProgress', s, s.progress);
  949. };
  950. s.updateActiveIndex = function () {
  951. var translate = s.rtl ? s.translate : -s.translate;
  952. var newActiveIndex, i, snapIndex;
  953. for (i = 0; i < s.slidesGrid.length; i ++) {
  954. if (typeof s.slidesGrid[i + 1] !== 'undefined') {
  955. if (translate >= s.slidesGrid[i] && translate < s.slidesGrid[i + 1] - (s.slidesGrid[i + 1] - s.slidesGrid[i]) / 2) {
  956. newActiveIndex = i;
  957. }
  958. else if (translate >= s.slidesGrid[i] && translate < s.slidesGrid[i + 1]) {
  959. newActiveIndex = i + 1;
  960. }
  961. }
  962. else {
  963. if (translate >= s.slidesGrid[i]) {
  964. newActiveIndex = i;
  965. }
  966. }
  967. }
  968. // Normalize slideIndex
  969. if(s.params.normalizeSlideIndex){
  970. if (newActiveIndex < 0 || typeof newActiveIndex === 'undefined') newActiveIndex = 0;
  971. }
  972. // for (i = 0; i < s.slidesGrid.length; i++) {
  973. // if (- translate >= s.slidesGrid[i]) {
  974. // newActiveIndex = i;
  975. // }
  976. // }
  977. snapIndex = Math.floor(newActiveIndex / s.params.slidesPerGroup);
  978. if (snapIndex >= s.snapGrid.length) snapIndex = s.snapGrid.length - 1;
  979. if (newActiveIndex === s.activeIndex) {
  980. return;
  981. }
  982. s.snapIndex = snapIndex;
  983. s.previousIndex = s.activeIndex;
  984. s.activeIndex = newActiveIndex;
  985. s.updateClasses();
  986. s.updateRealIndex();
  987. };
  988. s.updateRealIndex = function(){
  989. s.realIndex = parseInt(s.slides.eq(s.activeIndex).attr('data-swiper-slide-index') || s.activeIndex, 10);
  990. };
  991. /*=========================
  992. Classes
  993. ===========================*/
  994. s.updateClasses = function () {
  995. s.slides.removeClass(s.params.slideActiveClass + ' ' + s.params.slideNextClass + ' ' + s.params.slidePrevClass + ' ' + s.params.slideDuplicateActiveClass + ' ' + s.params.slideDuplicateNextClass + ' ' + s.params.slideDuplicatePrevClass);
  996. var activeSlide = s.slides.eq(s.activeIndex);
  997. // Active classes
  998. activeSlide.addClass(s.params.slideActiveClass);
  999. if (params.loop) {
  1000. // Duplicate to all looped slides
  1001. if (activeSlide.hasClass(s.params.slideDuplicateClass)) {
  1002. s.wrapper.children('.' + s.params.slideClass + ':not(.' + s.params.slideDuplicateClass + ')[data-swiper-slide-index="' + s.realIndex + '"]').addClass(s.params.slideDuplicateActiveClass);
  1003. }
  1004. else {
  1005. s.wrapper.children('.' + s.params.slideClass + '.' + s.params.slideDuplicateClass + '[data-swiper-slide-index="' + s.realIndex + '"]').addClass(s.params.slideDuplicateActiveClass);
  1006. }
  1007. }
  1008. // Next Slide
  1009. var nextSlide = activeSlide.next('.' + s.params.slideClass).addClass(s.params.slideNextClass);
  1010. if (s.params.loop && nextSlide.length === 0) {
  1011. nextSlide = s.slides.eq(0);
  1012. nextSlide.addClass(s.params.slideNextClass);
  1013. }
  1014. // Prev Slide
  1015. var prevSlide = activeSlide.prev('.' + s.params.slideClass).addClass(s.params.slidePrevClass);
  1016. if (s.params.loop && prevSlide.length === 0) {
  1017. prevSlide = s.slides.eq(-1);
  1018. prevSlide.addClass(s.params.slidePrevClass);
  1019. }
  1020. if (params.loop) {
  1021. // Duplicate to all looped slides
  1022. if (nextSlide.hasClass(s.params.slideDuplicateClass)) {
  1023. s.wrapper.children('.' + s.params.slideClass + ':not(.' + s.params.slideDuplicateClass + ')[data-swiper-slide-index="' + nextSlide.attr('data-swiper-slide-index') + '"]').addClass(s.params.slideDuplicateNextClass);
  1024. }
  1025. else {
  1026. s.wrapper.children('.' + s.params.slideClass + '.' + s.params.slideDuplicateClass + '[data-swiper-slide-index="' + nextSlide.attr('data-swiper-slide-index') + '"]').addClass(s.params.slideDuplicateNextClass);
  1027. }
  1028. if (prevSlide.hasClass(s.params.slideDuplicateClass)) {
  1029. s.wrapper.children('.' + s.params.slideClass + ':not(.' + s.params.slideDuplicateClass + ')[data-swiper-slide-index="' + prevSlide.attr('data-swiper-slide-index') + '"]').addClass(s.params.slideDuplicatePrevClass);
  1030. }
  1031. else {
  1032. s.wrapper.children('.' + s.params.slideClass + '.' + s.params.slideDuplicateClass + '[data-swiper-slide-index="' + prevSlide.attr('data-swiper-slide-index') + '"]').addClass(s.params.slideDuplicatePrevClass);
  1033. }
  1034. }
  1035. // Pagination
  1036. if (s.paginationContainer && s.paginationContainer.length > 0) {
  1037. // Current/Total
  1038. var current,
  1039. total = s.params.loop ? Math.ceil((s.slides.length - s.loopedSlides * 2) / s.params.slidesPerGroup) : s.snapGrid.length;
  1040. if (s.params.loop) {
  1041. current = Math.ceil((s.activeIndex - s.loopedSlides)/s.params.slidesPerGroup);
  1042. if (current > s.slides.length - 1 - s.loopedSlides * 2) {
  1043. current = current - (s.slides.length - s.loopedSlides * 2);
  1044. }
  1045. if (current > total - 1) current = current - total;
  1046. if (current < 0 && s.params.paginationType !== 'bullets') current = total + current;
  1047. }
  1048. else {
  1049. if (typeof s.snapIndex !== 'undefined') {
  1050. current = s.snapIndex;
  1051. }
  1052. else {
  1053. current = s.activeIndex || 0;
  1054. }
  1055. }
  1056. // Types
  1057. if (s.params.paginationType === 'bullets' && s.bullets && s.bullets.length > 0) {
  1058. s.bullets.removeClass(s.params.bulletActiveClass);
  1059. if (s.paginationContainer.length > 1) {
  1060. s.bullets.each(function () {
  1061. if ($(this).index() === current) $(this).addClass(s.params.bulletActiveClass);
  1062. });
  1063. }
  1064. else {
  1065. s.bullets.eq(current).addClass(s.params.bulletActiveClass);
  1066. }
  1067. }
  1068. if (s.params.paginationType === 'fraction') {
  1069. s.paginationContainer.find('.' + s.params.paginationCurrentClass).text(current + 1);
  1070. s.paginationContainer.find('.' + s.params.paginationTotalClass).text(total);
  1071. }
  1072. if (s.params.paginationType === 'progress') {
  1073. var scale = (current + 1) / total,
  1074. scaleX = scale,
  1075. scaleY = 1;
  1076. if (!s.isHorizontal()) {
  1077. scaleY = scale;
  1078. scaleX = 1;
  1079. }
  1080. s.paginationContainer.find('.' + s.params.paginationProgressbarClass).transform('translate3d(0,0,0) scaleX(' + scaleX + ') scaleY(' + scaleY + ')').transition(s.params.speed);
  1081. }
  1082. if (s.params.paginationType === 'custom' && s.params.paginationCustomRender) {
  1083. s.paginationContainer.html(s.params.paginationCustomRender(s, current + 1, total));
  1084. s.emit('onPaginationRendered', s, s.paginationContainer[0]);
  1085. }
  1086. }
  1087. // Next/active buttons
  1088. if (!s.params.loop) {
  1089. if (s.params.prevButton && s.prevButton && s.prevButton.length > 0) {
  1090. if (s.isBeginning) {
  1091. s.prevButton.addClass(s.params.buttonDisabledClass);
  1092. if (s.params.a11y && s.a11y) s.a11y.disable(s.prevButton);
  1093. }
  1094. else {
  1095. s.prevButton.removeClass(s.params.buttonDisabledClass);
  1096. if (s.params.a11y && s.a11y) s.a11y.enable(s.prevButton);
  1097. }
  1098. }
  1099. if (s.params.nextButton && s.nextButton && s.nextButton.length > 0) {
  1100. if (s.isEnd) {
  1101. s.nextButton.addClass(s.params.buttonDisabledClass);
  1102. if (s.params.a11y && s.a11y) s.a11y.disable(s.nextButton);
  1103. }
  1104. else {
  1105. s.nextButton.removeClass(s.params.buttonDisabledClass);
  1106. if (s.params.a11y && s.a11y) s.a11y.enable(s.nextButton);
  1107. }
  1108. }
  1109. }
  1110. };
  1111. /*=========================
  1112. Pagination
  1113. ===========================*/
  1114. s.updatePagination = function () {
  1115. if (!s.params.pagination) return;
  1116. if (s.paginationContainer && s.paginationContainer.length > 0) {
  1117. var paginationHTML = '';
  1118. if (s.params.paginationType === 'bullets') {
  1119. var numberOfBullets = s.params.loop ? Math.ceil((s.slides.length - s.loopedSlides * 2) / s.params.slidesPerGroup) : s.snapGrid.length;
  1120. for (var i = 0; i < numberOfBullets; i++) {
  1121. if (s.params.paginationBulletRender) {
  1122. paginationHTML += s.params.paginationBulletRender(s, i, s.params.bulletClass);
  1123. }
  1124. else {
  1125. paginationHTML += '<' + s.params.paginationElement+' class="' + s.params.bulletClass + '"></' + s.params.paginationElement + '>';
  1126. }
  1127. }
  1128. s.paginationContainer.html(paginationHTML);
  1129. s.bullets = s.paginationContainer.find('.' + s.params.bulletClass);
  1130. if (s.params.paginationClickable && s.params.a11y && s.a11y) {
  1131. s.a11y.initPagination();
  1132. }
  1133. }
  1134. if (s.params.paginationType === 'fraction') {
  1135. if (s.params.paginationFractionRender) {
  1136. paginationHTML = s.params.paginationFractionRender(s, s.params.paginationCurrentClass, s.params.paginationTotalClass);
  1137. }
  1138. else {
  1139. paginationHTML =
  1140. '<span class="' + s.params.paginationCurrentClass + '"></span>' +
  1141. ' / ' +
  1142. '<span class="' + s.params.paginationTotalClass+'"></span>';
  1143. }
  1144. s.paginationContainer.html(paginationHTML);
  1145. }
  1146. if (s.params.paginationType === 'progress') {
  1147. if (s.params.paginationProgressRender) {
  1148. paginationHTML = s.params.paginationProgressRender(s, s.params.paginationProgressbarClass);
  1149. }
  1150. else {
  1151. paginationHTML = '<span class="' + s.params.paginationProgressbarClass + '"></span>';
  1152. }
  1153. s.paginationContainer.html(paginationHTML);
  1154. }
  1155. if (s.params.paginationType !== 'custom') {
  1156. s.emit('onPaginationRendered', s, s.paginationContainer[0]);
  1157. }
  1158. }
  1159. };
  1160. /*=========================
  1161. Common update method
  1162. ===========================*/
  1163. s.update = function (updateTranslate) {
  1164. if (!s) return;
  1165. s.updateContainerSize();
  1166. s.updateSlidesSize();
  1167. s.updateProgress();
  1168. s.updatePagination();
  1169. s.updateClasses();
  1170. if (s.params.scrollbar && s.scrollbar) {
  1171. s.scrollbar.set();
  1172. }
  1173. var newTranslate;
  1174. function forceSetTranslate() {
  1175. var translate = s.rtl ? -s.translate : s.translate;
  1176. newTranslate = Math.min(Math.max(s.translate, s.maxTranslate()), s.minTranslate());
  1177. s.setWrapperTranslate(newTranslate);
  1178. s.updateActiveIndex();
  1179. s.updateClasses();
  1180. }
  1181. if (updateTranslate) {
  1182. var translated;
  1183. if (s.controller && s.controller.spline) {
  1184. s.controller.spline = undefined;
  1185. }
  1186. if (s.params.freeMode) {
  1187. forceSetTranslate();
  1188. if (s.params.autoHeight) {
  1189. s.updateAutoHeight();
  1190. }
  1191. }
  1192. else {
  1193. if ((s.params.slidesPerView === 'auto' || s.params.slidesPerView > 1) && s.isEnd && !s.params.centeredSlides) {
  1194. translated = s.slideTo(s.slides.length - 1, 0, false, true);
  1195. }
  1196. else {
  1197. translated = s.slideTo(s.activeIndex, 0, false, true);
  1198. }
  1199. if (!translated) {
  1200. forceSetTranslate();
  1201. }
  1202. }
  1203. }
  1204. else if (s.params.autoHeight) {
  1205. s.updateAutoHeight();
  1206. }
  1207. };
  1208. /*=========================
  1209. Resize Handler
  1210. ===========================*/
  1211. s.onResize = function (forceUpdatePagination) {
  1212. if (s.params.onBeforeResize) s.params.onBeforeResize(s);
  1213. //Breakpoints
  1214. if (s.params.breakpoints) {
  1215. s.setBreakpoint();
  1216. }
  1217. // Disable locks on resize
  1218. var allowSwipeToPrev = s.params.allowSwipeToPrev;
  1219. var allowSwipeToNext = s.params.allowSwipeToNext;
  1220. s.params.allowSwipeToPrev = s.params.allowSwipeToNext = true;
  1221. s.updateContainerSize();
  1222. s.updateSlidesSize();
  1223. if (s.params.slidesPerView === 'auto' || s.params.freeMode || forceUpdatePagination) s.updatePagination();
  1224. if (s.params.scrollbar && s.scrollbar) {
  1225. s.scrollbar.set();
  1226. }
  1227. if (s.controller && s.controller.spline) {
  1228. s.controller.spline = undefined;
  1229. }
  1230. var slideChangedBySlideTo = false;
  1231. if (s.params.freeMode) {
  1232. var newTranslate = Math.min(Math.max(s.translate, s.maxTranslate()), s.minTranslate());
  1233. s.setWrapperTranslate(newTranslate);
  1234. s.updateActiveIndex();
  1235. s.updateClasses();
  1236. if (s.params.autoHeight) {
  1237. s.updateAutoHeight();
  1238. }
  1239. }
  1240. else {
  1241. s.updateClasses();
  1242. if ((s.params.slidesPerView === 'auto' || s.params.slidesPerView > 1) && s.isEnd && !s.params.centeredSlides) {
  1243. slideChangedBySlideTo = s.slideTo(s.slides.length - 1, 0, false, true);
  1244. }
  1245. else {
  1246. slideChangedBySlideTo = s.slideTo(s.activeIndex, 0, false, true);
  1247. }
  1248. }
  1249. if (s.params.lazyLoading && !slideChangedBySlideTo && s.lazy) {
  1250. s.lazy.load();
  1251. }
  1252. // Return locks after resize
  1253. s.params.allowSwipeToPrev = allowSwipeToPrev;
  1254. s.params.allowSwipeToNext = allowSwipeToNext;
  1255. if (s.params.onAfterResize) s.params.onAfterResize(s);
  1256. };
  1257. /*=========================
  1258. Events
  1259. ===========================*/
  1260. //Define Touch Events
  1261. s.touchEventsDesktop = {start: 'mousedown', move: 'mousemove', end: 'mouseup'};
  1262. if (window.navigator.pointerEnabled) s.touchEventsDesktop = {start: 'pointerdown', move: 'pointermove', end: 'pointerup'};
  1263. else if (window.navigator.msPointerEnabled) s.touchEventsDesktop = {start: 'MSPointerDown', move: 'MSPointerMove', end: 'MSPointerUp'};
  1264. s.touchEvents = {
  1265. start : s.support.touch || !s.params.simulateTouch ? 'touchstart' : s.touchEventsDesktop.start,
  1266. move : s.support.touch || !s.params.simulateTouch ? 'touchmove' : s.touchEventsDesktop.move,
  1267. end : s.support.touch || !s.params.simulateTouch ? 'touchend' : s.touchEventsDesktop.end
  1268. };
  1269. // WP8 Touch Events Fix
  1270. if (window.navigator.pointerEnabled || window.navigator.msPointerEnabled) {
  1271. (s.params.touchEventsTarget === 'container' ? s.container : s.wrapper).addClass('swiper-wp8-' + s.params.direction);
  1272. }
  1273. // Attach/detach events
  1274. s.initEvents = function (detach) {
  1275. var actionDom = detach ? 'off' : 'on';
  1276. var action = detach ? 'removeEventListener' : 'addEventListener';
  1277. var touchEventsTarget = s.params.touchEventsTarget === 'container' ? s.container[0] : s.wrapper[0];
  1278. var target = s.support.touch ? touchEventsTarget : document;
  1279. var moveCapture = s.params.nested ? true : false;
  1280. //Touch Events
  1281. if (s.browser.ie) {
  1282. touchEventsTarget[action](s.touchEvents.start, s.onTouchStart, false);
  1283. target[action](s.touchEvents.move, s.onTouchMove, moveCapture);
  1284. target[action](s.touchEvents.end, s.onTouchEnd, false);
  1285. }
  1286. else {
  1287. if (s.support.touch) {
  1288. var passiveListener = s.touchEvents.start === 'touchstart' && s.support.passiveListener && s.params.passiveListeners ? {passive: true, capture: false} : false;
  1289. touchEventsTarget[action](s.touchEvents.start, s.onTouchStart, passiveListener);
  1290. touchEventsTarget[action](s.touchEvents.move, s.onTouchMove, moveCapture);
  1291. touchEventsTarget[action](s.touchEvents.end, s.onTouchEnd, passiveListener);
  1292. }
  1293. if ((params.simulateTouch && !s.device.ios && !s.device.android) || (params.simulateTouch && !s.support.touch && s.device.ios)) {
  1294. touchEventsTarget[action]('mousedown', s.onTouchStart, false);
  1295. document[action]('mousemove', s.onTouchMove, moveCapture);
  1296. document[action]('mouseup', s.onTouchEnd, false);
  1297. }
  1298. }
  1299. window[action]('resize', s.onResize);
  1300. // Next, Prev, Index
  1301. if (s.params.nextButton && s.nextButton && s.nextButton.length > 0) {
  1302. s.nextButton[actionDom]('click', s.onClickNext);
  1303. if (s.params.a11y && s.a11y) s.nextButton[actionDom]('keydown', s.a11y.onEnterKey);
  1304. }
  1305. if (s.params.prevButton && s.prevButton && s.prevButton.length > 0) {
  1306. s.prevButton[actionDom]('click', s.onClickPrev);
  1307. if (s.params.a11y && s.a11y) s.prevButton[actionDom]('keydown', s.a11y.onEnterKey);
  1308. }
  1309. if (s.params.pagination && s.params.paginationClickable) {
  1310. s.paginationContainer[actionDom]('click', '.' + s.params.bulletClass, s.onClickIndex);
  1311. if (s.params.a11y && s.a11y) s.paginationContainer[actionDom]('keydown', '.' + s.params.bulletClass, s.a11y.onEnterKey);
  1312. }
  1313. // Prevent Links Clicks
  1314. if (s.params.preventClicks || s.params.preventClicksPropagation) touchEventsTarget[action]('click', s.preventClicks, true);
  1315. };
  1316. s.attachEvents = function () {
  1317. s.initEvents();
  1318. };
  1319. s.detachEvents = function () {
  1320. s.initEvents(true);
  1321. };
  1322. /*=========================
  1323. Handle Clicks
  1324. ===========================*/
  1325. // Prevent Clicks
  1326. s.allowClick = true;
  1327. s.preventClicks = function (e) {
  1328. if (!s.allowClick) {
  1329. if (s.params.preventClicks) e.preventDefault();
  1330. if (s.params.preventClicksPropagation && s.animating) {
  1331. e.stopPropagation();
  1332. e.stopImmediatePropagation();
  1333. }
  1334. }
  1335. };
  1336. // Clicks
  1337. s.onClickNext = function (e) {
  1338. e.preventDefault();
  1339. if (s.isEnd && !s.params.loop) return;
  1340. s.slideNext();
  1341. };
  1342. s.onClickPrev = function (e) {
  1343. e.preventDefault();
  1344. if (s.isBeginning && !s.params.loop) return;
  1345. s.slidePrev();
  1346. };
  1347. s.onClickIndex = function (e) {
  1348. e.preventDefault();
  1349. var index = $(this).index() * s.params.slidesPerGroup;
  1350. if (s.params.loop) index = index + s.loopedSlides;
  1351. s.slideTo(index);
  1352. };
  1353. /*=========================
  1354. Handle Touches
  1355. ===========================*/
  1356. function findElementInEvent(e, selector) {
  1357. var el = $(e.target);
  1358. if (!el.is(selector)) {
  1359. if (typeof selector === 'string') {
  1360. el = el.parents(selector);
  1361. }
  1362. else if (selector.nodeType) {
  1363. var found;
  1364. el.parents().each(function (index, _el) {
  1365. if (_el === selector) found = selector;
  1366. });
  1367. if (!found) return undefined;
  1368. else return selector;
  1369. }
  1370. }
  1371. if (el.length === 0) {
  1372. return undefined;
  1373. }
  1374. return el[0];
  1375. }
  1376. s.updateClickedSlide = function (e) {
  1377. var slide = findElementInEvent(e, '.' + s.params.slideClass);
  1378. var slideFound = false;
  1379. if (slide) {
  1380. for (var i = 0; i < s.slides.length; i++) {
  1381. if (s.slides[i] === slide) slideFound = true;
  1382. }
  1383. }
  1384. if (slide && slideFound) {
  1385. s.clickedSlide = slide;
  1386. s.clickedIndex = $(slide).index();
  1387. }
  1388. else {
  1389. s.clickedSlide = undefined;
  1390. s.clickedIndex = undefined;
  1391. return;
  1392. }
  1393. if (s.params.slideToClickedSlide && s.clickedIndex !== undefined && s.clickedIndex !== s.activeIndex) {
  1394. var slideToIndex = s.clickedIndex,
  1395. realIndex,
  1396. duplicatedSlides,
  1397. slidesPerView = s.params.slidesPerView === 'auto' ? s.currentSlidesPerView() : s.params.slidesPerView;
  1398. if (s.params.loop) {
  1399. if (s.animating) return;
  1400. realIndex = parseInt($(s.clickedSlide).attr('data-swiper-slide-index'), 10);
  1401. if (s.params.centeredSlides) {
  1402. if ((slideToIndex < s.loopedSlides - slidesPerView/2) || (slideToIndex > s.slides.length - s.loopedSlides + slidesPerView/2)) {
  1403. s.fixLoop();
  1404. slideToIndex = s.wrapper.children('.' + s.params.slideClass + '[data-swiper-slide-index="' + realIndex + '"]:not(.' + s.params.slideDuplicateClass + ')').eq(0).index();
  1405. setTimeout(function () {
  1406. s.slideTo(slideToIndex);
  1407. }, 0);
  1408. }
  1409. else {
  1410. s.slideTo(slideToIndex);
  1411. }
  1412. }
  1413. else {
  1414. if (slideToIndex > s.slides.length - slidesPerView) {
  1415. s.fixLoop();
  1416. slideToIndex = s.wrapper.children('.' + s.params.slideClass + '[data-swiper-slide-index="' + realIndex + '"]:not(.' + s.params.slideDuplicateClass + ')').eq(0).index();
  1417. setTimeout(function () {
  1418. s.slideTo(slideToIndex);
  1419. }, 0);
  1420. }
  1421. else {
  1422. s.slideTo(slideToIndex);
  1423. }
  1424. }
  1425. }
  1426. else {
  1427. s.slideTo(slideToIndex);
  1428. }
  1429. }
  1430. };
  1431. var isTouched,
  1432. isMoved,
  1433. allowTouchCallbacks,
  1434. touchStartTime,
  1435. isScrolling,
  1436. currentTranslate,
  1437. startTranslate,
  1438. allowThresholdMove,
  1439. // Form elements to match
  1440. formElements = 'input, select, textarea, button, video',
  1441. // Last click time
  1442. lastClickTime = Date.now(), clickTimeout,
  1443. //Velocities
  1444. velocities = [],
  1445. allowMomentumBounce;
  1446. // Animating Flag
  1447. s.animating = false;
  1448. // Touches information
  1449. s.touches = {
  1450. startX: 0,
  1451. startY: 0,
  1452. currentX: 0,
  1453. currentY: 0,
  1454. diff: 0
  1455. };
  1456. // Touch handlers
  1457. var isTouchEvent, startMoving;
  1458. var myTouchDiff = 0;
  1459. s.onTouchStart = function (e) {
  1460. if (e.originalEvent) e = e.originalEvent;
  1461. isTouchEvent = e.type === 'touchstart';
  1462. if (!isTouchEvent && 'which' in e && e.which === 3) return;
  1463. if (s.params.noSwiping && findElementInEvent(e, '.' + s.params.noSwipingClass)) {
  1464. s.allowClick = true;
  1465. return;
  1466. }
  1467. if (s.params.swipeHandler) {
  1468. if (!findElementInEvent(e, s.params.swipeHandler)) return;
  1469. }
  1470. var startX = s.touches.currentX = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX;
  1471. var startY = s.touches.currentY = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY;
  1472. // Do NOT start if iOS edge swipe is detected. Otherwise iOS app (UIWebView) cannot swipe-to-go-back anymore
  1473. if(s.device.ios && s.params.iOSEdgeSwipeDetection && startX <= s.params.iOSEdgeSwipeThreshold) {
  1474. return;
  1475. }
  1476. isTouched = true;
  1477. isMoved = false;
  1478. allowTouchCallbacks = true;
  1479. isScrolling = undefined;
  1480. startMoving = undefined;
  1481. s.touches.startX = startX;
  1482. s.touches.startY = startY;
  1483. touchStartTime = Date.now();
  1484. s.allowClick = true;
  1485. s.updateContainerSize();
  1486. s.swipeDirection = undefined;
  1487. if (s.params.threshold > 0) allowThresholdMove = false;
  1488. if (e.type !== 'touchstart') {
  1489. var preventDefault = true;
  1490. if ($(e.target).is(formElements)) preventDefault = false;
  1491. if (document.activeElement && $(document.activeElement).is(formElements)) {
  1492. document.activeElement.blur();
  1493. }
  1494. if (preventDefault) {
  1495. e.preventDefault();
  1496. }
  1497. }
  1498. s.emit('onTouchStart', s, e);
  1499. };
  1500. s.onTouchMove = function (e) {
  1501. if (e.originalEvent) e = e.originalEvent;
  1502. if (isTouchEvent && e.type === 'mousemove') return;
  1503. if (e.preventedByNestedSwiper) {
  1504. s.touches.startX = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX;
  1505. s.touches.startY = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY;
  1506. return;
  1507. }
  1508. if (s.params.onlyExternal) {///
  1509. // isMoved = true;
  1510. s.allowClick = false;
  1511. if (isTouched) {
  1512. s.touches.startX = s.touches.currentX = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX;
  1513. s.touches.startY = s.touches.currentY = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY;
  1514. touchStartTime = Date.now();
  1515. }
  1516. return;
  1517. }
  1518. if (isTouchEvent && s.params.touchReleaseOnEdges && !s.params.loop) {
  1519. if (!s.isHorizontal()) {
  1520. // Vertical
  1521. if (
  1522. (s.touches.currentY < s.touches.startY && s.translate <= s.maxTranslate()) ||
  1523. (s.touches.currentY > s.touches.startY && s.translate >= s.minTranslate())
  1524. ) {
  1525. return;
  1526. }
  1527. }
  1528. else {
  1529. if (
  1530. (s.touches.currentX < s.touches.startX && s.translate <= s.maxTranslate()) ||
  1531. (s.touches.currentX > s.touches.startX && s.translate >= s.minTranslate())
  1532. ) {
  1533. return;
  1534. }
  1535. }
  1536. }
  1537. if (isTouchEvent && document.activeElement) {
  1538. if (e.target === document.activeElement && $(e.target).is(formElements)) {
  1539. isMoved = true;
  1540. s.allowClick = false;
  1541. return;
  1542. }
  1543. }
  1544. if (allowTouchCallbacks) {
  1545. s.emit('onTouchMove', s, e);
  1546. }
  1547. if (e.targetTouches && e.targetTouches.length > 1) return;
  1548. s.touches.currentX = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX;
  1549. s.touches.currentY = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY;
  1550. if (typeof isScrolling === 'undefined') {
  1551. var touchAngle;
  1552. if (s.isHorizontal() && s.touches.currentY === s.touches.startY || !s.isHorizontal() && s.touches.currentX === s.touches.startX) {
  1553. isScrolling = false;
  1554. }
  1555. else {
  1556. touchAngle = Math.atan2(Math.abs(s.touches.currentY - s.touches.startY), Math.abs(s.touches.currentX - s.touches.startX)) * 180 / Math.PI;
  1557. isScrolling = s.isHorizontal() ? touchAngle > s.params.touchAngle : (90 - touchAngle > s.params.touchAngle);
  1558. }
  1559. }
  1560. if (isScrolling) {
  1561. s.emit('onTouchMoveOpposite', s, e);
  1562. }
  1563. if (typeof startMoving === 'undefined') {
  1564. if (s.touches.currentX !== s.touches.startX || s.touches.currentY !== s.touches.startY) {
  1565. startMoving = true;
  1566. }
  1567. }
  1568. if (!isTouched) return;
  1569. if (isScrolling) {
  1570. isTouched = false;
  1571. return;
  1572. }
  1573. if (!startMoving) {
  1574. return;
  1575. }
  1576. s.allowClick = false;
  1577. s.emit('onSliderMove', s, e);
  1578. var diff = s.touches.diff = s.isHorizontal() ? s.touches.currentX - s.touches.startX : s.touches.currentY - s.touches.startY;
  1579. diff = diff * s.params.touchRatio;
  1580. if(s.isEnd && diff < 0){
  1581. return;
  1582. }else if(s.isBeginning && diff > 0){
  1583. return;
  1584. }
  1585. e.preventDefault();
  1586. if (s.params.touchMoveStopPropagation && !s.params.nested) {
  1587. e.stopPropagation();
  1588. }
  1589. if (!isMoved) {
  1590. if (params.loop) {
  1591. s.fixLoop();
  1592. }
  1593. startTranslate = s.getWrapperTranslate();
  1594. s.setWrapperTransition(0);
  1595. if (s.animating) {
  1596. s.wrapper.trigger('webkitTransitionEnd transitionend oTransitionEnd MSTransitionEnd msTransitionEnd');
  1597. }
  1598. if (s.params.autoplay && s.autoplaying) {
  1599. if (s.params.autoplayDisableOnInteraction) {
  1600. s.stopAutoplay();
  1601. }
  1602. else {
  1603. s.pauseAutoplay();
  1604. }
  1605. }
  1606. allowMomentumBounce = false;
  1607. //Grab Cursor
  1608. if (s.params.grabCursor && (s.params.allowSwipeToNext === true || s.params.allowSwipeToPrev === true)) {
  1609. s.setGrabCursor(true);
  1610. }
  1611. }
  1612. isMoved = true;
  1613. if (s.rtl) diff = -diff;
  1614. s.swipeDirection = diff > 0 ? 'prev' : 'next';
  1615. currentTranslate = diff + startTranslate;
  1616. var disableParentSwiper = true;
  1617. if ((diff > 0 && currentTranslate > s.minTranslate())) {
  1618. disableParentSwiper = false;
  1619. if (s.params.resistance) currentTranslate = s.minTranslate() - 1 + Math.pow(-s.minTranslate() + startTranslate + diff, s.params.resistanceRatio);
  1620. }
  1621. else if (diff < 0 && currentTranslate < s.maxTranslate()) {
  1622. disableParentSwiper = false;
  1623. if (s.params.resistance) currentTranslate = s.maxTranslate() + 1 - Math.pow(s.maxTranslate() - startTranslate - diff, s.params.resistanceRatio);
  1624. }
  1625. if (disableParentSwiper) {
  1626. e.preventedByNestedSwiper = true;
  1627. }
  1628. // Directions locks
  1629. if (!s.params.allowSwipeToNext && s.swipeDirection === 'next' && currentTranslate < startTranslate) {
  1630. currentTranslate = startTranslate;
  1631. }
  1632. if (!s.params.allowSwipeToPrev && s.swipeDirection === 'prev' && currentTranslate > startTranslate) {
  1633. currentTranslate = startTranslate;
  1634. }
  1635. // Threshold
  1636. if (s.params.threshold > 0) {
  1637. if (Math.abs(diff) > s.params.threshold || allowThresholdMove) {
  1638. if (!allowThresholdMove) {
  1639. allowThresholdMove = true;
  1640. s.touches.startX = s.touches.currentX;
  1641. s.touches.startY = s.touches.currentY;
  1642. currentTranslate = startTranslate;
  1643. s.touches.diff = s.isHorizontal() ? s.touches.currentX - s.touches.startX : s.touches.currentY - s.touches.startY;
  1644. return;
  1645. }
  1646. }
  1647. else {
  1648. currentTranslate = startTranslate;
  1649. return;
  1650. }
  1651. }
  1652. if (!s.params.followFinger) return;
  1653. // Update active index in free mode
  1654. if (s.params.freeMode || s.params.watchSlidesProgress) {
  1655. s.updateActiveIndex();
  1656. }
  1657. if (s.params.freeMode) {
  1658. //Velocity
  1659. if (velocities.length === 0) {
  1660. velocities.push({
  1661. position: s.touches[s.isHorizontal() ? 'startX' : 'startY'],
  1662. time: touchStartTime
  1663. });
  1664. }
  1665. velocities.push({
  1666. position: s.touches[s.isHorizontal() ? 'currentX' : 'currentY'],
  1667. time: (new window.Date()).getTime()
  1668. });
  1669. }
  1670. myTouchDiff = diff;
  1671. // Update progress
  1672. s.updateProgress(currentTranslate);
  1673. // Update translate
  1674. s.setWrapperTranslate(currentTranslate);
  1675. };
  1676. s.onTouchEnd = function (e) {
  1677. if (e.originalEvent) e = e.originalEvent;
  1678. if (allowTouchCallbacks) {
  1679. s.emit('onTouchEnd', s, e);
  1680. }
  1681. allowTouchCallbacks = false;
  1682. if (!isTouched) return;
  1683. //Return Grab Cursor
  1684. if (s.params.grabCursor && isMoved && isTouched && (s.params.allowSwipeToNext === true || s.params.allowSwipeToPrev === true)) {
  1685. s.setGrabCursor(false);
  1686. }
  1687. // Time diff
  1688. var touchEndTime = Date.now();
  1689. var timeDiff = touchEndTime - touchStartTime;
  1690. // Tap, doubleTap, Click
  1691. if (s.allowClick) {
  1692. s.updateClickedSlide(e);
  1693. s.emit('onTap', s, e);
  1694. if (timeDiff < 300 && (touchEndTime - lastClickTime) > 300) {
  1695. if (clickTimeout) clearTimeout(clickTimeout);
  1696. clickTimeout = setTimeout(function () {
  1697. if (!s) return;
  1698. if (s.params.paginationHide && s.paginationContainer.length > 0 && !$(e.target).hasClass(s.params.bulletClass)) {
  1699. s.paginationContainer.toggleClass(s.params.paginationHiddenClass);
  1700. }
  1701. s.emit('onClick', s, e);
  1702. }, 300);
  1703. }
  1704. if (timeDiff < 300 && (touchEndTime - lastClickTime) < 300) {
  1705. if (clickTimeout) clearTimeout(clickTimeout);
  1706. s.emit('onDoubleTap', s, e);
  1707. }
  1708. }
  1709. lastClickTime = Date.now();
  1710. setTimeout(function () {
  1711. if (s) s.allowClick = true;
  1712. }, 0);
  1713. if (!isTouched || !isMoved || !s.swipeDirection || s.touches.diff === 0 || currentTranslate === startTranslate) {
  1714. isTouched = isMoved = false;
  1715. return;
  1716. }
  1717. isTouched = isMoved = false;
  1718. var currentPos;
  1719. if (s.params.followFinger) {
  1720. currentPos = s.rtl ? s.translate : -s.translate;
  1721. }
  1722. else {
  1723. currentPos = -currentTranslate;
  1724. }
  1725. if (s.params.freeMode) {
  1726. if (currentPos < -s.minTranslate()) {
  1727. s.slideTo(s.activeIndex);
  1728. return;
  1729. }
  1730. else if (currentPos > -s.maxTranslate()) {
  1731. if (s.slides.length < s.snapGrid.length) {
  1732. s.slideTo(s.snapGrid.length - 1);
  1733. }
  1734. else {
  1735. s.slideTo(s.slides.length - 1);
  1736. }
  1737. return;
  1738. }
  1739. if (s.params.freeModeMomentum) {
  1740. if (velocities.length > 1) {
  1741. var lastMoveEvent = velocities.pop(), velocityEvent = velocities.pop();
  1742. var distance = lastMoveEvent.position - velocityEvent.position;
  1743. var time = lastMoveEvent.time - velocityEvent.time;
  1744. s.velocity = distance / time;
  1745. s.velocity = s.velocity / 2;
  1746. if (Math.abs(s.velocity) < s.params.freeModeMinimumVelocity) {
  1747. s.velocity = 0;
  1748. }
  1749. // this implies that the user stopped moving a finger then released.
  1750. // There would be no events with distance zero, so the last event is stale.
  1751. if (time > 150 || (new window.Date().getTime() - lastMoveEvent.time) > 300) {
  1752. s.velocity = 0;
  1753. }
  1754. } else {
  1755. s.velocity = 0;
  1756. }
  1757. s.velocity = s.velocity * s.params.freeModeMomentumVelocityRatio;
  1758. velocities.length = 0;
  1759. var momentumDuration = 1000 * s.params.freeModeMomentumRatio;
  1760. var momentumDistance = s.velocity * momentumDuration;
  1761. var newPosition = s.translate + momentumDistance;
  1762. if (s.rtl) newPosition = - newPosition;
  1763. var doBounce = false;
  1764. var afterBouncePosition;
  1765. var bounceAmount = Math.abs(s.velocity) * 20 * s.params.freeModeMomentumBounceRatio;
  1766. if (newPosition < s.maxTranslate()) {
  1767. if (s.params.freeModeMomentumBounce) {
  1768. if (newPosition + s.maxTranslate() < -bounceAmount) {
  1769. newPosition = s.maxTranslate() - bounceAmount;
  1770. }
  1771. afterBouncePosition = s.maxTranslate();
  1772. doBounce = true;
  1773. allowMomentumBounce = true;
  1774. }
  1775. else {
  1776. newPosition = s.maxTranslate();
  1777. }
  1778. }
  1779. else if (newPosition > s.minTranslate()) {
  1780. if (s.params.freeModeMomentumBounce) {
  1781. if (newPosition - s.minTranslate() > bounceAmount) {
  1782. newPosition = s.minTranslate() + bounceAmount;
  1783. }
  1784. afterBouncePosition = s.minTranslate();
  1785. doBounce = true;
  1786. allowMomentumBounce = true;
  1787. }
  1788. else {
  1789. newPosition = s.minTranslate();
  1790. }
  1791. }
  1792. else if (s.params.freeModeSticky) {
  1793. var j = 0,
  1794. nextSlide;
  1795. for (j = 0; j < s.snapGrid.length; j += 1) {
  1796. if (s.snapGrid[j] > -newPosition) {
  1797. nextSlide = j;
  1798. break;
  1799. }
  1800. }
  1801. if (Math.abs(s.snapGrid[nextSlide] - newPosition) < Math.abs(s.snapGrid[nextSlide - 1] - newPosition) || s.swipeDirection === 'next') {
  1802. newPosition = s.snapGrid[nextSlide];
  1803. } else {
  1804. newPosition = s.snapGrid[nextSlide - 1];
  1805. }
  1806. if (!s.rtl) newPosition = - newPosition;
  1807. }
  1808. //Fix duration
  1809. if (s.velocity !== 0) {
  1810. if (s.rtl) {
  1811. momentumDuration = Math.abs((-newPosition - s.translate) / s.velocity);
  1812. }
  1813. else {
  1814. momentumDuration = Math.abs((newPosition - s.translate) / s.velocity);
  1815. }
  1816. }
  1817. else if (s.params.freeModeSticky) {
  1818. s.slideReset();
  1819. return;
  1820. }
  1821. if (s.params.freeModeMomentumBounce && doBounce) {
  1822. s.updateProgress(afterBouncePosition);
  1823. s.setWrapperTransition(momentumDuration);
  1824. s.setWrapperTranslate(newPosition);
  1825. s.onTransitionStart();
  1826. s.animating = true;
  1827. s.wrapper.transitionEnd(function () {
  1828. if (!s || !allowMomentumBounce) return;
  1829. s.emit('onMomentumBounce', s);
  1830. s.setWrapperTransition(s.params.speed);
  1831. s.setWrapperTranslate(afterBouncePosition);
  1832. s.wrapper.transitionEnd(function () {
  1833. if (!s) return;
  1834. s.onTransitionEnd();
  1835. });
  1836. });
  1837. } else if (s.velocity) {
  1838. s.updateProgress(newPosition);
  1839. s.setWrapperTransition(momentumDuration);
  1840. s.setWrapperTranslate(newPosition);
  1841. s.onTransitionStart();
  1842. if (!s.animating) {
  1843. s.animating = true;
  1844. s.wrapper.transitionEnd(function () {
  1845. if (!s) return;
  1846. s.onTransitionEnd();
  1847. });
  1848. }
  1849. } else {
  1850. s.updateProgress(newPosition);
  1851. }
  1852. s.updateActiveIndex();
  1853. }
  1854. if (!s.params.freeModeMomentum || timeDiff >= s.params.longSwipesMs) {
  1855. s.updateProgress();
  1856. s.updateActiveIndex();
  1857. }
  1858. return;
  1859. }
  1860. // Find current slide
  1861. var i, stopIndex = 0, groupSize = s.slidesSizesGrid[0];
  1862. for (i = 0; i < s.slidesGrid.length; i += s.params.slidesPerGroup) {
  1863. if (typeof s.slidesGrid[i + s.params.slidesPerGroup] !== 'undefined') {
  1864. if (currentPos >= s.slidesGrid[i] && currentPos < s.slidesGrid[i + s.params.slidesPerGroup]) {
  1865. stopIndex = i;
  1866. groupSize = s.slidesGrid[i + s.params.slidesPerGroup] - s.slidesGrid[i];
  1867. }
  1868. }
  1869. else {
  1870. if (currentPos >= s.slidesGrid[i]) {
  1871. stopIndex = i;
  1872. groupSize = s.slidesGrid[s.slidesGrid.length - 1] - s.slidesGrid[s.slidesGrid.length - 2];
  1873. }
  1874. }
  1875. }
  1876. // Find current slide size
  1877. var ratio = (currentPos - s.slidesGrid[stopIndex]) / groupSize;
  1878. if (timeDiff > s.params.longSwipesMs) {
  1879. // Long touches
  1880. if (!s.params.longSwipes) {
  1881. s.slideTo(s.activeIndex);
  1882. return;
  1883. }
  1884. if (s.swipeDirection === 'next') {
  1885. if (ratio >= s.params.longSwipesRatio) s.slideTo(stopIndex + s.params.slidesPerGroup);
  1886. else s.slideTo(stopIndex);
  1887. }
  1888. if (s.swipeDirection === 'prev') {
  1889. if (ratio > (1 - s.params.longSwipesRatio)) s.slideTo(stopIndex + s.params.slidesPerGroup);
  1890. else s.slideTo(stopIndex);
  1891. }
  1892. }
  1893. else {
  1894. // Short swipes
  1895. if (!s.params.shortSwipes) {
  1896. s.slideTo(s.activeIndex);
  1897. return;
  1898. }
  1899. if (s.swipeDirection === 'next') {
  1900. s.slideTo(stopIndex + s.params.slidesPerGroup);
  1901. }
  1902. if (s.swipeDirection === 'prev') {
  1903. s.slideTo(stopIndex);
  1904. }
  1905. }
  1906. };
  1907. /*=========================
  1908. Transitions
  1909. ===========================*/
  1910. s._slideTo = function (slideIndex, speed) {
  1911. return s.slideTo(slideIndex, speed, true, true);
  1912. };
  1913. s.slideTo = function (slideIndex, speed, runCallbacks, internal) {
  1914. if (typeof runCallbacks === 'undefined') runCallbacks = true;
  1915. if (typeof slideIndex === 'undefined') slideIndex = 0;
  1916. if (slideIndex < 0) slideIndex = 0;
  1917. s.snapIndex = Math.floor(slideIndex / s.params.slidesPerGroup);
  1918. if (s.snapIndex >= s.snapGrid.length) s.snapIndex = s.snapGrid.length - 1;
  1919. var translate = - s.snapGrid[s.snapIndex];
  1920. // Stop autoplay
  1921. if (s.params.autoplay && s.autoplaying) {
  1922. if (internal || !s.params.autoplayDisableOnInteraction) {
  1923. s.pauseAutoplay(speed);
  1924. }
  1925. else {
  1926. s.stopAutoplay();
  1927. }
  1928. }
  1929. // Update progress
  1930. s.updateProgress(translate);
  1931. // Normalize slideIndex
  1932. if(s.params.normalizeSlideIndex){
  1933. for (var i = 0; i < s.slidesGrid.length; i++) {
  1934. if (- Math.floor(translate * 100) >= Math.floor(s.slidesGrid[i] * 100)) {
  1935. slideIndex = i;
  1936. }
  1937. }
  1938. }
  1939. // Directions locks
  1940. if (!s.params.allowSwipeToNext && translate < s.translate && translate < s.minTranslate()) {
  1941. return false;
  1942. }
  1943. if (!s.params.allowSwipeToPrev && translate > s.translate && translate > s.maxTranslate()) {
  1944. if ((s.activeIndex || 0) !== slideIndex ) return false;
  1945. }
  1946. // Update Index
  1947. if (typeof speed === 'undefined') speed = s.params.speed;
  1948. s.previousIndex = s.activeIndex || 0;
  1949. s.activeIndex = slideIndex;
  1950. s.updateRealIndex();
  1951. if ((s.rtl && -translate === s.translate) || (!s.rtl && translate === s.translate)) {
  1952. // Update Height
  1953. if (s.params.autoHeight) {
  1954. s.updateAutoHeight();
  1955. }
  1956. s.updateClasses();
  1957. if (s.params.effect !== 'slide') {
  1958. s.setWrapperTranslate(translate);
  1959. }
  1960. return false;
  1961. }
  1962. s.updateClasses();
  1963. s.onTransitionStart(runCallbacks);
  1964. if (speed === 0 || s.browser.lteIE9) {
  1965. s.setWrapperTranslate(translate);
  1966. s.setWrapperTransition(0);
  1967. s.onTransitionEnd(runCallbacks);
  1968. }
  1969. else {
  1970. s.setWrapperTranslate(translate);
  1971. s.setWrapperTransition(speed);
  1972. if (!s.animating) {
  1973. s.animating = true;
  1974. s.wrapper.transitionEnd(function () {
  1975. if (!s) return;
  1976. s.onTransitionEnd(runCallbacks);
  1977. });
  1978. }
  1979. }
  1980. return true;
  1981. };
  1982. s.onTransitionStart = function (runCallbacks) {
  1983. if (typeof runCallbacks === 'undefined') runCallbacks = true;
  1984. if (s.params.autoHeight) {
  1985. s.updateAutoHeight();
  1986. }
  1987. if (s.lazy) s.lazy.onTransitionStart();
  1988. if (runCallbacks) {
  1989. s.emit('onTransitionStart', s);
  1990. if (s.activeIndex !== s.previousIndex) {
  1991. s.emit('onSlideChangeStart', s);
  1992. if (s.activeIndex > s.previousIndex) {
  1993. s.emit('onSlideNextStart', s);
  1994. }
  1995. else {
  1996. s.emit('onSlidePrevStart', s);
  1997. }
  1998. }
  1999. }
  2000. };
  2001. s.onTransitionEnd = function (runCallbacks) {
  2002. s.animating = false;
  2003. s.setWrapperTransition(0);
  2004. if (typeof runCallbacks === 'undefined') runCallbacks = true;
  2005. if (s.lazy) s.lazy.onTransitionEnd();
  2006. if (runCallbacks) {
  2007. s.emit('onTransitionEnd', s);
  2008. if (s.activeIndex !== s.previousIndex) {
  2009. s.emit('onSlideChangeEnd', s);
  2010. if (s.activeIndex > s.previousIndex) {
  2011. s.emit('onSlideNextEnd', s);
  2012. }
  2013. else {
  2014. s.emit('onSlidePrevEnd', s);
  2015. }
  2016. }
  2017. }
  2018. if (s.params.history && s.history) {
  2019. s.history.setHistory(s.params.history, s.activeIndex);
  2020. }
  2021. if (s.params.hashnav && s.hashnav) {
  2022. s.hashnav.setHash();
  2023. }
  2024. };
  2025. s.slideNext = function (runCallbacks, speed, internal) {
  2026. if (s.params.loop) {
  2027. if (s.animating) return false;
  2028. s.fixLoop();
  2029. var clientLeft = s.container[0].clientLeft;
  2030. return s.slideTo(s.activeIndex + s.params.slidesPerGroup, speed, runCallbacks, internal);
  2031. }
  2032. else return s.slideTo(s.activeIndex + s.params.slidesPerGroup, speed, runCallbacks, internal);
  2033. };
  2034. s._slideNext = function (speed) {
  2035. return s.slideNext(true, speed, true);
  2036. };
  2037. s.slidePrev = function (runCallbacks, speed, internal) {
  2038. if (s.params.loop) {
  2039. if (s.animating) return false;
  2040. s.fixLoop();
  2041. var clientLeft = s.container[0].clientLeft;
  2042. return s.slideTo(s.activeIndex - 1, speed, runCallbacks, internal);
  2043. }
  2044. else return s.slideTo(s.activeIndex - 1, speed, runCallbacks, internal);
  2045. };
  2046. s._slidePrev = function (speed) {
  2047. return s.slidePrev(true, speed, true);
  2048. };
  2049. s.slideReset = function (runCallbacks, speed, internal) {
  2050. return s.slideTo(s.activeIndex, speed, runCallbacks);
  2051. };
  2052. s.disableTouchControl = function () {
  2053. s.params.onlyExternal = true;
  2054. return true;
  2055. };
  2056. s.enableTouchControl = function () {
  2057. s.params.onlyExternal = false;
  2058. return true;
  2059. };
  2060. /*=========================
  2061. Translate/transition helpers
  2062. ===========================*/
  2063. s.setWrapperTransition = function (duration, byController) {
  2064. s.wrapper.transition(duration);
  2065. if (s.params.effect !== 'slide' && s.effects[s.params.effect]) {
  2066. s.effects[s.params.effect].setTransition(duration);
  2067. }
  2068. if (s.params.parallax && s.parallax) {
  2069. s.parallax.setTransition(duration);
  2070. }
  2071. if (s.params.scrollbar && s.scrollbar) {
  2072. s.scrollbar.setTransition(duration);
  2073. }
  2074. if (s.params.control && s.controller) {
  2075. s.controller.setTransition(duration, byController);
  2076. }
  2077. s.emit('onSetTransition', s, duration);
  2078. };
  2079. s.setWrapperTranslate = function (translate, updateActiveIndex, byController) {
  2080. var x = 0, y = 0, z = 0;
  2081. if (s.isHorizontal()) {
  2082. x = s.rtl ? -translate : translate;
  2083. }
  2084. else {
  2085. y = translate;
  2086. }
  2087. if (s.params.roundLengths) {
  2088. x = round(x);
  2089. y = round(y);
  2090. }
  2091. if (!s.params.virtualTranslate) {
  2092. if (s.support.transforms3d) s.wrapper.transform('translate3d(' + x + 'px, ' + y + 'px, ' + z + 'px)');
  2093. else s.wrapper.transform('translate(' + x + 'px, ' + y + 'px)');
  2094. }
  2095. s.translate = s.isHorizontal() ? x : y;
  2096. // Check if we need to update progress
  2097. var progress;
  2098. var translatesDiff = s.maxTranslate() - s.minTranslate();
  2099. if (translatesDiff === 0) {
  2100. progress = 0;
  2101. }
  2102. else {
  2103. progress = (translate - s.minTranslate()) / (translatesDiff);
  2104. }
  2105. if (progress !== s.progress) {
  2106. s.updateProgress(translate);
  2107. }
  2108. if (updateActiveIndex) s.updateActiveIndex();
  2109. if (s.params.effect !== 'slide' && s.effects[s.params.effect]) {
  2110. s.effects[s.params.effect].setTranslate(s.translate);
  2111. }
  2112. if (s.params.parallax && s.parallax) {
  2113. s.parallax.setTranslate(s.translate);
  2114. }
  2115. if (s.params.scrollbar && s.scrollbar) {
  2116. s.scrollbar.setTranslate(s.translate);
  2117. }
  2118. if (s.params.control && s.controller) {
  2119. s.controller.setTranslate(s.translate, byController);
  2120. }
  2121. s.emit('onSetTranslate', s, s.translate);
  2122. };
  2123. s.getTranslate = function (el, axis) {
  2124. var matrix, curTransform, curStyle, transformMatrix;
  2125. // automatic axis detection
  2126. if (typeof axis === 'undefined') {
  2127. axis = 'x';
  2128. }
  2129. if (s.params.virtualTranslate) {
  2130. return s.rtl ? -s.translate : s.translate;
  2131. }
  2132. curStyle = window.getComputedStyle(el, null);
  2133. if (window.WebKitCSSMatrix) {
  2134. curTransform = curStyle.transform || curStyle.webkitTransform;
  2135. if (curTransform.split(',').length > 6) {
  2136. curTransform = curTransform.split(', ').map(function(a){
  2137. return a.replace(',','.');
  2138. }).join(', ');
  2139. }
  2140. // Some old versions of Webkit choke when 'none' is passed; pass
  2141. // empty string instead in this case
  2142. transformMatrix = new window.WebKitCSSMatrix(curTransform === 'none' ? '' : curTransform);
  2143. }
  2144. else {
  2145. transformMatrix = curStyle.MozTransform || curStyle.OTransform || curStyle.MsTransform || curStyle.msTransform || curStyle.transform || curStyle.getPropertyValue('transform').replace('translate(', 'matrix(1, 0, 0, 1,');
  2146. matrix = transformMatrix.toString().split(',');
  2147. }
  2148. if (axis === 'x') {
  2149. //Latest Chrome and webkits Fix
  2150. if (window.WebKitCSSMatrix)
  2151. curTransform = transformMatrix.m41;
  2152. //Crazy IE10 Matrix
  2153. else if (matrix.length === 16)
  2154. curTransform = parseFloat(matrix[12]);
  2155. //Normal Browsers
  2156. else
  2157. curTransform = parseFloat(matrix[4]);
  2158. }
  2159. if (axis === 'y') {
  2160. //Latest Chrome and webkits Fix
  2161. if (window.WebKitCSSMatrix)
  2162. curTransform = transformMatrix.m42;
  2163. //Crazy IE10 Matrix
  2164. else if (matrix.length === 16)
  2165. curTransform = parseFloat(matrix[13]);
  2166. //Normal Browsers
  2167. else
  2168. curTransform = parseFloat(matrix[5]);
  2169. }
  2170. if (s.rtl && curTransform) curTransform = -curTransform;
  2171. return curTransform || 0;
  2172. };
  2173. s.getWrapperTranslate = function (axis) {
  2174. if (typeof axis === 'undefined') {
  2175. axis = s.isHorizontal() ? 'x' : 'y';
  2176. }
  2177. return s.getTranslate(s.wrapper[0], axis);
  2178. };
  2179. /*=========================
  2180. Observer
  2181. ===========================*/
  2182. s.observers = [];
  2183. function initObserver(target, options) {
  2184. options = options || {};
  2185. // create an observer instance
  2186. var ObserverFunc = window.MutationObserver || window.WebkitMutationObserver;
  2187. var observer = new ObserverFunc(function (mutations) {
  2188. mutations.forEach(function (mutation) {
  2189. s.onResize(true);
  2190. s.emit('onObserverUpdate', s, mutation);
  2191. });
  2192. });
  2193. observer.observe(target, {
  2194. attributes: typeof options.attributes === 'undefined' ? true : options.attributes,
  2195. childList: typeof options.childList === 'undefined' ? true : options.childList,
  2196. characterData: typeof options.characterData === 'undefined' ? true : options.characterData
  2197. });
  2198. s.observers.push(observer);
  2199. }
  2200. s.initObservers = function () {
  2201. if (s.params.observeParents) {
  2202. var containerParents = s.container.parents();
  2203. for (var i = 0; i < containerParents.length; i++) {
  2204. initObserver(containerParents[i]);
  2205. }
  2206. }
  2207. // Observe container
  2208. initObserver(s.container[0], {childList: false});
  2209. // Observe wrapper
  2210. initObserver(s.wrapper[0], {attributes: false});
  2211. };
  2212. s.disconnectObservers = function () {
  2213. for (var i = 0; i < s.observers.length; i++) {
  2214. s.observers[i].disconnect();
  2215. }
  2216. s.observers = [];
  2217. };
  2218. /*=========================
  2219. Loop
  2220. ===========================*/
  2221. // Create looped slides
  2222. s.createLoop = function () {
  2223. // Remove duplicated slides
  2224. s.wrapper.children('.' + s.params.slideClass + '.' + s.params.slideDuplicateClass).remove();
  2225. var slides = s.wrapper.children('.' + s.params.slideClass);
  2226. if(s.params.slidesPerView === 'auto' && !s.params.loopedSlides) s.params.loopedSlides = slides.length;
  2227. s.loopedSlides = parseInt(s.params.loopedSlides || s.params.slidesPerView, 10);
  2228. s.loopedSlides = s.loopedSlides + s.params.loopAdditionalSlides;
  2229. if (s.loopedSlides > slides.length) {
  2230. s.loopedSlides = slides.length;
  2231. }
  2232. var prependSlides = [], appendSlides = [], i;
  2233. slides.each(function (index, el) {
  2234. var slide = $(this);
  2235. if (index < s.loopedSlides) appendSlides.push(el);
  2236. if (index < slides.length && index >= slides.length - s.loopedSlides) prependSlides.push(el);
  2237. slide.attr('data-swiper-slide-index', index);
  2238. });
  2239. for (i = 0; i < appendSlides.length; i++) {
  2240. s.wrapper.append($(appendSlides[i].cloneNode(true)).addClass(s.params.slideDuplicateClass));
  2241. }
  2242. for (i = prependSlides.length - 1; i >= 0; i--) {
  2243. s.wrapper.prepend($(prependSlides[i].cloneNode(true)).addClass(s.params.slideDuplicateClass));
  2244. }
  2245. };
  2246. s.destroyLoop = function () {
  2247. s.wrapper.children('.' + s.params.slideClass + '.' + s.params.slideDuplicateClass).remove();
  2248. s.slides.removeAttr('data-swiper-slide-index');
  2249. };
  2250. s.reLoop = function (updatePosition) {
  2251. var oldIndex = s.activeIndex - s.loopedSlides;
  2252. s.destroyLoop();
  2253. s.createLoop();
  2254. s.updateSlidesSize();
  2255. if (updatePosition) {
  2256. s.slideTo(oldIndex + s.loopedSlides, 0, false);
  2257. }
  2258. };
  2259. s.fixLoop = function () {
  2260. var newIndex;
  2261. //Fix For Negative Oversliding
  2262. if (s.activeIndex < s.loopedSlides) {
  2263. newIndex = s.slides.length - s.loopedSlides * 3 + s.activeIndex;
  2264. newIndex = newIndex + s.loopedSlides;
  2265. s.slideTo(newIndex, 0, false, true);
  2266. }
  2267. //Fix For Positive Oversliding
  2268. else if ((s.params.slidesPerView === 'auto' && s.activeIndex >= s.loopedSlides * 2) || (s.activeIndex > s.slides.length - s.params.slidesPerView * 2)) {
  2269. newIndex = -s.slides.length + s.activeIndex + s.loopedSlides;
  2270. newIndex = newIndex + s.loopedSlides;
  2271. s.slideTo(newIndex, 0, false, true);
  2272. }
  2273. };
  2274. /*=========================
  2275. Append/Prepend/Remove Slides
  2276. ===========================*/
  2277. s.appendSlide = function (slides) {
  2278. if (s.params.loop) {
  2279. s.destroyLoop();
  2280. }
  2281. if (typeof slides === 'object' && slides.length) {
  2282. for (var i = 0; i < slides.length; i++) {
  2283. if (slides[i]) s.wrapper.append(slides[i]);
  2284. }
  2285. }
  2286. else {
  2287. s.wrapper.append(slides);
  2288. }
  2289. if (s.params.loop) {
  2290. s.createLoop();
  2291. }
  2292. if (!(s.params.observer && s.support.observer)) {
  2293. s.update(true);
  2294. }
  2295. };
  2296. s.prependSlide = function (slides) {
  2297. if (s.params.loop) {
  2298. s.destroyLoop();
  2299. }
  2300. var newActiveIndex = s.activeIndex + 1;
  2301. if (typeof slides === 'object' && slides.length) {
  2302. for (var i = 0; i < slides.length; i++) {
  2303. if (slides[i]) s.wrapper.prepend(slides[i]);
  2304. }
  2305. newActiveIndex = s.activeIndex + slides.length;
  2306. }
  2307. else {
  2308. s.wrapper.prepend(slides);
  2309. }
  2310. if (s.params.loop) {
  2311. s.createLoop();
  2312. }
  2313. if (!(s.params.observer && s.support.observer)) {
  2314. s.update(true);
  2315. }
  2316. s.slideTo(newActiveIndex, 0, false);
  2317. };
  2318. s.removeSlide = function (slidesIndexes) {
  2319. if (s.params.loop) {
  2320. s.destroyLoop();
  2321. s.slides = s.wrapper.children('.' + s.params.slideClass);
  2322. }
  2323. var newActiveIndex = s.activeIndex,
  2324. indexToRemove;
  2325. if (typeof slidesIndexes === 'object' && slidesIndexes.length) {
  2326. for (var i = 0; i < slidesIndexes.length; i++) {
  2327. indexToRemove = slidesIndexes[i];
  2328. if (s.slides[indexToRemove]) s.slides.eq(indexToRemove).remove();
  2329. if (indexToRemove < newActiveIndex) newActiveIndex--;
  2330. }
  2331. newActiveIndex = Math.max(newActiveIndex, 0);
  2332. }
  2333. else {
  2334. indexToRemove = slidesIndexes;
  2335. if (s.slides[indexToRemove]) s.slides.eq(indexToRemove).remove();
  2336. if (indexToRemove < newActiveIndex) newActiveIndex--;
  2337. newActiveIndex = Math.max(newActiveIndex, 0);
  2338. }
  2339. if (s.params.loop) {
  2340. s.createLoop();
  2341. }
  2342. if (!(s.params.observer && s.support.observer)) {
  2343. s.update(true);
  2344. }
  2345. if (s.params.loop) {
  2346. s.slideTo(newActiveIndex + s.loopedSlides, 0, false);
  2347. }
  2348. else {
  2349. s.slideTo(newActiveIndex, 0, false);
  2350. }
  2351. };
  2352. s.removeAllSlides = function () {
  2353. var slidesIndexes = [];
  2354. for (var i = 0; i < s.slides.length; i++) {
  2355. slidesIndexes.push(i);
  2356. }
  2357. s.removeSlide(slidesIndexes);
  2358. };
  2359. /*=========================
  2360. Effects
  2361. ===========================*/
  2362. s.effects = {
  2363. fade: {
  2364. setTranslate: function () {
  2365. for (var i = 0; i < s.slides.length; i++) {
  2366. var slide = s.slides.eq(i);
  2367. var offset = slide[0].swiperSlideOffset;
  2368. var tx = -offset;
  2369. if (!s.params.virtualTranslate) tx = tx - s.translate;
  2370. var ty = 0;
  2371. if (!s.isHorizontal()) {
  2372. ty = tx;
  2373. tx = 0;
  2374. }
  2375. var slideOpacity = s.params.fade.crossFade ?
  2376. Math.max(1 - Math.abs(slide[0].progress), 0) :
  2377. 1 + Math.min(Math.max(slide[0].progress, -1), 0);
  2378. slide
  2379. .css({
  2380. opacity: slideOpacity
  2381. })
  2382. .transform('translate3d(' + tx + 'px, ' + ty + 'px, 0px)');
  2383. }
  2384. },
  2385. setTransition: function (duration) {
  2386. s.slides.transition(duration);
  2387. if (s.params.virtualTranslate && duration !== 0) {
  2388. var eventTriggered = false;
  2389. s.slides.transitionEnd(function () {
  2390. if (eventTriggered) return;
  2391. if (!s) return;
  2392. eventTriggered = true;
  2393. s.animating = false;
  2394. var triggerEvents = ['webkitTransitionEnd', 'transitionend', 'oTransitionEnd', 'MSTransitionEnd', 'msTransitionEnd'];
  2395. for (var i = 0; i < triggerEvents.length; i++) {
  2396. s.wrapper.trigger(triggerEvents[i]);
  2397. }
  2398. });
  2399. }
  2400. }
  2401. },
  2402. flip: {
  2403. setTranslate: function () {
  2404. for (var i = 0; i < s.slides.length; i++) {
  2405. var slide = s.slides.eq(i);
  2406. var progress = slide[0].progress;
  2407. if (s.params.flip.limitRotation) {
  2408. progress = Math.max(Math.min(slide[0].progress, 1), -1);
  2409. }
  2410. var offset = slide[0].swiperSlideOffset;
  2411. var rotate = -180 * progress,
  2412. rotateY = rotate,
  2413. rotateX = 0,
  2414. tx = -offset,
  2415. ty = 0;
  2416. if (!s.isHorizontal()) {
  2417. ty = tx;
  2418. tx = 0;
  2419. rotateX = -rotateY;
  2420. rotateY = 0;
  2421. }
  2422. else if (s.rtl) {
  2423. rotateY = -rotateY;
  2424. }
  2425. slide[0].style.zIndex = -Math.abs(Math.round(progress)) + s.slides.length;
  2426. if (s.params.flip.slideShadows) {
  2427. //Set shadows
  2428. var shadowBefore = s.isHorizontal() ? slide.find('.swiper-slide-shadow-left') : slide.find('.swiper-slide-shadow-top');
  2429. var shadowAfter = s.isHorizontal() ? slide.find('.swiper-slide-shadow-right') : slide.find('.swiper-slide-shadow-bottom');
  2430. if (shadowBefore.length === 0) {
  2431. shadowBefore = $('<div class="swiper-slide-shadow-' + (s.isHorizontal() ? 'left' : 'top') + '"></div>');
  2432. slide.append(shadowBefore);
  2433. }
  2434. if (shadowAfter.length === 0) {
  2435. shadowAfter = $('<div class="swiper-slide-shadow-' + (s.isHorizontal() ? 'right' : 'bottom') + '"></div>');
  2436. slide.append(shadowAfter);
  2437. }
  2438. if (shadowBefore.length) shadowBefore[0].style.opacity = Math.max(-progress, 0);
  2439. if (shadowAfter.length) shadowAfter[0].style.opacity = Math.max(progress, 0);
  2440. }
  2441. slide
  2442. .transform('translate3d(' + tx + 'px, ' + ty + 'px, 0px) rotateX(' + rotateX + 'deg) rotateY(' + rotateY + 'deg)');
  2443. }
  2444. },
  2445. setTransition: function (duration) {
  2446. s.slides.transition(duration).find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').transition(duration);
  2447. if (s.params.virtualTranslate && duration !== 0) {
  2448. var eventTriggered = false;
  2449. s.slides.eq(s.activeIndex).transitionEnd(function () {
  2450. if (eventTriggered) return;
  2451. if (!s) return;
  2452. if (!$(this).hasClass(s.params.slideActiveClass)) return;
  2453. eventTriggered = true;
  2454. s.animating = false;
  2455. var triggerEvents = ['webkitTransitionEnd', 'transitionend', 'oTransitionEnd', 'MSTransitionEnd', 'msTransitionEnd'];
  2456. for (var i = 0; i < triggerEvents.length; i++) {
  2457. s.wrapper.trigger(triggerEvents[i]);
  2458. }
  2459. });
  2460. }
  2461. }
  2462. },
  2463. cube: {
  2464. setTranslate: function () {
  2465. var wrapperRotate = 0, cubeShadow;
  2466. if (s.params.cube.shadow) {
  2467. if (s.isHorizontal()) {
  2468. cubeShadow = s.wrapper.find('.swiper-cube-shadow');
  2469. if (cubeShadow.length === 0) {
  2470. cubeShadow = $('<div class="swiper-cube-shadow"></div>');
  2471. s.wrapper.append(cubeShadow);
  2472. }
  2473. cubeShadow.css({height: s.width + 'px'});
  2474. }
  2475. else {
  2476. cubeShadow = s.container.find('.swiper-cube-shadow');
  2477. if (cubeShadow.length === 0) {
  2478. cubeShadow = $('<div class="swiper-cube-shadow"></div>');
  2479. s.container.append(cubeShadow);
  2480. }
  2481. }
  2482. }
  2483. for (var i = 0; i < s.slides.length; i++) {
  2484. var slide = s.slides.eq(i);
  2485. var slideAngle = i * 90;
  2486. var round = Math.floor(slideAngle / 360);
  2487. if (s.rtl) {
  2488. slideAngle = -slideAngle;
  2489. round = Math.floor(-slideAngle / 360);
  2490. }
  2491. var progress = Math.max(Math.min(slide[0].progress, 1), -1);
  2492. var tx = 0, ty = 0, tz = 0;
  2493. if (i % 4 === 0) {
  2494. tx = - round * 4 * s.size;
  2495. tz = 0;
  2496. }
  2497. else if ((i - 1) % 4 === 0) {
  2498. tx = 0;
  2499. tz = - round * 4 * s.size;
  2500. }
  2501. else if ((i - 2) % 4 === 0) {
  2502. tx = s.size + round * 4 * s.size;
  2503. tz = s.size;
  2504. }
  2505. else if ((i - 3) % 4 === 0) {
  2506. tx = - s.size;
  2507. tz = 3 * s.size + s.size * 4 * round;
  2508. }
  2509. if (s.rtl) {
  2510. tx = -tx;
  2511. }
  2512. if (!s.isHorizontal()) {
  2513. ty = tx;
  2514. tx = 0;
  2515. }
  2516. var transform = 'rotateX(' + (s.isHorizontal() ? 0 : -slideAngle) + 'deg) rotateY(' + (s.isHorizontal() ? slideAngle : 0) + 'deg) translate3d(' + tx + 'px, ' + ty + 'px, ' + tz + 'px)';
  2517. if (progress <= 1 && progress > -1) {
  2518. wrapperRotate = i * 90 + progress * 90;
  2519. if (s.rtl) wrapperRotate = -i * 90 - progress * 90;
  2520. }
  2521. slide.transform(transform);
  2522. if (s.params.cube.slideShadows) {
  2523. //Set shadows
  2524. var shadowBefore = s.isHorizontal() ? slide.find('.swiper-slide-shadow-left') : slide.find('.swiper-slide-shadow-top');
  2525. var shadowAfter = s.isHorizontal() ? slide.find('.swiper-slide-shadow-right') : slide.find('.swiper-slide-shadow-bottom');
  2526. if (shadowBefore.length === 0) {
  2527. shadowBefore = $('<div class="swiper-slide-shadow-' + (s.isHorizontal() ? 'left' : 'top') + '"></div>');
  2528. slide.append(shadowBefore);
  2529. }
  2530. if (shadowAfter.length === 0) {
  2531. shadowAfter = $('<div class="swiper-slide-shadow-' + (s.isHorizontal() ? 'right' : 'bottom') + '"></div>');
  2532. slide.append(shadowAfter);
  2533. }
  2534. if (shadowBefore.length) shadowBefore[0].style.opacity = Math.max(-progress, 0);
  2535. if (shadowAfter.length) shadowAfter[0].style.opacity = Math.max(progress, 0);
  2536. }
  2537. }
  2538. s.wrapper.css({
  2539. '-webkit-transform-origin': '50% 50% -' + (s.size / 2) + 'px',
  2540. '-moz-transform-origin': '50% 50% -' + (s.size / 2) + 'px',
  2541. '-ms-transform-origin': '50% 50% -' + (s.size / 2) + 'px',
  2542. 'transform-origin': '50% 50% -' + (s.size / 2) + 'px'
  2543. });
  2544. if (s.params.cube.shadow) {
  2545. if (s.isHorizontal()) {
  2546. 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) + ')');
  2547. }
  2548. else {
  2549. var shadowAngle = Math.abs(wrapperRotate) - Math.floor(Math.abs(wrapperRotate) / 90) * 90;
  2550. var multiplier = 1.5 - (Math.sin(shadowAngle * 2 * Math.PI / 360) / 2 + Math.cos(shadowAngle * 2 * Math.PI / 360) / 2);
  2551. var scale1 = s.params.cube.shadowScale,
  2552. scale2 = s.params.cube.shadowScale / multiplier,
  2553. offset = s.params.cube.shadowOffset;
  2554. cubeShadow.transform('scale3d(' + scale1 + ', 1, ' + scale2 + ') translate3d(0px, ' + (s.height / 2 + offset) + 'px, ' + (-s.height / 2 / scale2) + 'px) rotateX(-90deg)');
  2555. }
  2556. }
  2557. var zFactor = (s.isSafari || s.isUiWebView) ? (-s.size / 2) : 0;
  2558. s.wrapper.transform('translate3d(0px,0,' + zFactor + 'px) rotateX(' + (s.isHorizontal() ? 0 : wrapperRotate) + 'deg) rotateY(' + (s.isHorizontal() ? -wrapperRotate : 0) + 'deg)');
  2559. },
  2560. setTransition: function (duration) {
  2561. s.slides.transition(duration).find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').transition(duration);
  2562. if (s.params.cube.shadow && !s.isHorizontal()) {
  2563. s.container.find('.swiper-cube-shadow').transition(duration);
  2564. }
  2565. }
  2566. },
  2567. coverflow: {
  2568. setTranslate: function () {
  2569. var transform = s.translate;
  2570. var center = s.isHorizontal() ? -transform + s.width / 2 : -transform + s.height / 2;
  2571. var rotate = s.isHorizontal() ? s.params.coverflow.rotate: -s.params.coverflow.rotate;
  2572. var translate = s.params.coverflow.depth;
  2573. //Each slide offset from center
  2574. for (var i = 0, length = s.slides.length; i < length; i++) {
  2575. var slide = s.slides.eq(i);
  2576. var slideSize = s.slidesSizesGrid[i];
  2577. var slideOffset = slide[0].swiperSlideOffset;
  2578. var offsetMultiplier = (center - slideOffset - slideSize / 2) / slideSize * s.params.coverflow.modifier;
  2579. var rotateY = s.isHorizontal() ? rotate * offsetMultiplier : 0;
  2580. var rotateX = s.isHorizontal() ? 0 : rotate * offsetMultiplier;
  2581. // var rotateZ = 0
  2582. var translateZ = -translate * Math.abs(offsetMultiplier);
  2583. var translateY = s.isHorizontal() ? 0 : s.params.coverflow.stretch * (offsetMultiplier);
  2584. var translateX = s.isHorizontal() ? s.params.coverflow.stretch * (offsetMultiplier) : 0;
  2585. //Fix for ultra small values
  2586. if (Math.abs(translateX) < 0.001) translateX = 0;
  2587. if (Math.abs(translateY) < 0.001) translateY = 0;
  2588. if (Math.abs(translateZ) < 0.001) translateZ = 0;
  2589. if (Math.abs(rotateY) < 0.001) rotateY = 0;
  2590. if (Math.abs(rotateX) < 0.001) rotateX = 0;
  2591. var slideTransform = 'translate3d(' + translateX + 'px,' + translateY + 'px,' + translateZ + 'px) rotateX(' + rotateX + 'deg) rotateY(' + rotateY + 'deg)';
  2592. slide.transform(slideTransform);
  2593. slide[0].style.zIndex = -Math.abs(Math.round(offsetMultiplier)) + 1;
  2594. if (s.params.coverflow.slideShadows) {
  2595. //Set shadows
  2596. var shadowBefore = s.isHorizontal() ? slide.find('.swiper-slide-shadow-left') : slide.find('.swiper-slide-shadow-top');
  2597. var shadowAfter = s.isHorizontal() ? slide.find('.swiper-slide-shadow-right') : slide.find('.swiper-slide-shadow-bottom');
  2598. if (shadowBefore.length === 0) {
  2599. shadowBefore = $('<div class="swiper-slide-shadow-' + (s.isHorizontal() ? 'left' : 'top') + '"></div>');
  2600. slide.append(shadowBefore);
  2601. }
  2602. if (shadowAfter.length === 0) {
  2603. shadowAfter = $('<div class="swiper-slide-shadow-' + (s.isHorizontal() ? 'right' : 'bottom') + '"></div>');
  2604. slide.append(shadowAfter);
  2605. }
  2606. if (shadowBefore.length) shadowBefore[0].style.opacity = offsetMultiplier > 0 ? offsetMultiplier : 0;
  2607. if (shadowAfter.length) shadowAfter[0].style.opacity = (-offsetMultiplier) > 0 ? -offsetMultiplier : 0;
  2608. }
  2609. }
  2610. //Set correct perspective for IE10
  2611. if (s.browser.ie) {
  2612. var ws = s.wrapper[0].style;
  2613. ws.perspectiveOrigin = center + 'px 50%';
  2614. }
  2615. },
  2616. setTransition: function (duration) {
  2617. s.slides.transition(duration).find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').transition(duration);
  2618. }
  2619. }
  2620. };
  2621. /*=========================
  2622. Images Lazy Loading
  2623. ===========================*/
  2624. s.lazy = {
  2625. initialImageLoaded: false,
  2626. loadImageInSlide: function (index, loadInDuplicate) {
  2627. if (typeof index === 'undefined') return;
  2628. if (typeof loadInDuplicate === 'undefined') loadInDuplicate = true;
  2629. if (s.slides.length === 0) return;
  2630. var slide = s.slides.eq(index);
  2631. var img = slide.find('.' + s.params.lazyLoadingClass + ':not(.' + s.params.lazyStatusLoadedClass + '):not(.' + s.params.lazyStatusLoadingClass + ')');
  2632. if (slide.hasClass(s.params.lazyLoadingClass) && !slide.hasClass(s.params.lazyStatusLoadedClass) && !slide.hasClass(s.params.lazyStatusLoadingClass)) {
  2633. img = img.add(slide[0]);
  2634. }
  2635. if (img.length === 0) return;
  2636. img.each(function () {
  2637. var _img = $(this);
  2638. _img.addClass(s.params.lazyStatusLoadingClass);
  2639. var background = _img.attr('data-background');
  2640. var src = _img.attr('data-src'),
  2641. srcset = _img.attr('data-srcset'),
  2642. sizes = _img.attr('data-sizes');
  2643. s.loadImage(_img[0], (src || background), srcset, sizes, false, function () {
  2644. if (typeof s === 'undefined' || s === null || !s) return;
  2645. if (background) {
  2646. _img.css('background-image', 'url("' + background + '")');
  2647. _img.removeAttr('data-background');
  2648. }
  2649. else {
  2650. if (srcset) {
  2651. _img.attr('srcset', srcset);
  2652. _img.removeAttr('data-srcset');
  2653. }
  2654. if (sizes) {
  2655. _img.attr('sizes', sizes);
  2656. _img.removeAttr('data-sizes');
  2657. }
  2658. if (src) {
  2659. _img.attr('src', src);
  2660. _img.removeAttr('data-src');
  2661. }
  2662. }
  2663. _img.addClass(s.params.lazyStatusLoadedClass).removeClass(s.params.lazyStatusLoadingClass);
  2664. slide.find('.' + s.params.lazyPreloaderClass + ', .' + s.params.preloaderClass).remove();
  2665. if (s.params.loop && loadInDuplicate) {
  2666. var slideOriginalIndex = slide.attr('data-swiper-slide-index');
  2667. if (slide.hasClass(s.params.slideDuplicateClass)) {
  2668. var originalSlide = s.wrapper.children('[data-swiper-slide-index="' + slideOriginalIndex + '"]:not(.' + s.params.slideDuplicateClass + ')');
  2669. s.lazy.loadImageInSlide(originalSlide.index(), false);
  2670. }
  2671. else {
  2672. var duplicatedSlide = s.wrapper.children('.' + s.params.slideDuplicateClass + '[data-swiper-slide-index="' + slideOriginalIndex + '"]');
  2673. s.lazy.loadImageInSlide(duplicatedSlide.index(), false);
  2674. }
  2675. }
  2676. s.emit('onLazyImageReady', s, slide[0], _img[0]);
  2677. });
  2678. s.emit('onLazyImageLoad', s, slide[0], _img[0]);
  2679. });
  2680. },
  2681. load: function () {
  2682. var i;
  2683. var slidesPerView = s.params.slidesPerView;
  2684. if (slidesPerView === 'auto') {
  2685. slidesPerView = 0;
  2686. }
  2687. if (!s.lazy.initialImageLoaded) s.lazy.initialImageLoaded = true;
  2688. if (s.params.watchSlidesVisibility) {
  2689. s.wrapper.children('.' + s.params.slideVisibleClass).each(function () {
  2690. s.lazy.loadImageInSlide($(this).index());
  2691. });
  2692. }
  2693. else {
  2694. if (slidesPerView > 1) {
  2695. for (i = s.activeIndex; i < s.activeIndex + slidesPerView ; i++) {
  2696. if (s.slides[i]) s.lazy.loadImageInSlide(i);
  2697. }
  2698. }
  2699. else {
  2700. s.lazy.loadImageInSlide(s.activeIndex);
  2701. }
  2702. }
  2703. if (s.params.lazyLoadingInPrevNext) {
  2704. if (slidesPerView > 1 || (s.params.lazyLoadingInPrevNextAmount && s.params.lazyLoadingInPrevNextAmount > 1)) {
  2705. var amount = s.params.lazyLoadingInPrevNextAmount;
  2706. var spv = slidesPerView;
  2707. var maxIndex = Math.min(s.activeIndex + spv + Math.max(amount, spv), s.slides.length);
  2708. var minIndex = Math.max(s.activeIndex - Math.max(spv, amount), 0);
  2709. // Next Slides
  2710. for (i = s.activeIndex + slidesPerView; i < maxIndex; i++) {
  2711. if (s.slides[i]) s.lazy.loadImageInSlide(i);
  2712. }
  2713. // Prev Slides
  2714. for (i = minIndex; i < s.activeIndex ; i++) {
  2715. if (s.slides[i]) s.lazy.loadImageInSlide(i);
  2716. }
  2717. }
  2718. else {
  2719. var nextSlide = s.wrapper.children('.' + s.params.slideNextClass);
  2720. if (nextSlide.length > 0) s.lazy.loadImageInSlide(nextSlide.index());
  2721. var prevSlide = s.wrapper.children('.' + s.params.slidePrevClass);
  2722. if (prevSlide.length > 0) s.lazy.loadImageInSlide(prevSlide.index());
  2723. }
  2724. }
  2725. },
  2726. onTransitionStart: function () {
  2727. if (s.params.lazyLoading) {
  2728. if (s.params.lazyLoadingOnTransitionStart || (!s.params.lazyLoadingOnTransitionStart && !s.lazy.initialImageLoaded)) {
  2729. s.lazy.load();
  2730. }
  2731. }
  2732. },
  2733. onTransitionEnd: function () {
  2734. if (s.params.lazyLoading && !s.params.lazyLoadingOnTransitionStart) {
  2735. s.lazy.load();
  2736. }
  2737. }
  2738. };
  2739. /*=========================
  2740. Scrollbar
  2741. ===========================*/
  2742. s.scrollbar = {
  2743. isTouched: false,
  2744. setDragPosition: function (e) {
  2745. var sb = s.scrollbar;
  2746. var x = 0, y = 0;
  2747. var translate;
  2748. var pointerPosition = s.isHorizontal() ?
  2749. ((e.type === 'touchstart' || e.type === 'touchmove') ? e.targetTouches[0].pageX : e.pageX || e.clientX) :
  2750. ((e.type === 'touchstart' || e.type === 'touchmove') ? e.targetTouches[0].pageY : e.pageY || e.clientY) ;
  2751. var position = (pointerPosition) - sb.track.offset()[s.isHorizontal() ? 'left' : 'top'] - sb.dragSize / 2;
  2752. var positionMin = -s.minTranslate() * sb.moveDivider;
  2753. var positionMax = -s.maxTranslate() * sb.moveDivider;
  2754. if (position < positionMin) {
  2755. position = positionMin;
  2756. }
  2757. else if (position > positionMax) {
  2758. position = positionMax;
  2759. }
  2760. position = -position / sb.moveDivider;
  2761. s.updateProgress(position);
  2762. s.setWrapperTranslate(position, true);
  2763. },
  2764. dragStart: function (e) {
  2765. var sb = s.scrollbar;
  2766. sb.isTouched = true;
  2767. e.preventDefault();
  2768. e.stopPropagation();
  2769. sb.setDragPosition(e);
  2770. clearTimeout(sb.dragTimeout);
  2771. sb.track.transition(0);
  2772. if (s.params.scrollbarHide) {
  2773. sb.track.css('opacity', 1);
  2774. }
  2775. s.wrapper.transition(100);
  2776. sb.drag.transition(100);
  2777. s.emit('onScrollbarDragStart', s);
  2778. },
  2779. dragMove: function (e) {
  2780. var sb = s.scrollbar;
  2781. if (!sb.isTouched) return;
  2782. if (e.preventDefault) e.preventDefault();
  2783. else e.returnValue = false;
  2784. sb.setDragPosition(e);
  2785. s.wrapper.transition(0);
  2786. sb.track.transition(0);
  2787. sb.drag.transition(0);
  2788. s.emit('onScrollbarDragMove', s);
  2789. },
  2790. dragEnd: function (e) {
  2791. var sb = s.scrollbar;
  2792. if (!sb.isTouched) return;
  2793. sb.isTouched = false;
  2794. if (s.params.scrollbarHide) {
  2795. clearTimeout(sb.dragTimeout);
  2796. sb.dragTimeout = setTimeout(function () {
  2797. sb.track.css('opacity', 0);
  2798. sb.track.transition(400);
  2799. }, 1000);
  2800. }
  2801. s.emit('onScrollbarDragEnd', s);
  2802. if (s.params.scrollbarSnapOnRelease) {
  2803. s.slideReset();
  2804. }
  2805. },
  2806. draggableEvents: (function () {
  2807. if ((s.params.simulateTouch === false && !s.support.touch)) return s.touchEventsDesktop;
  2808. else return s.touchEvents;
  2809. })(),
  2810. enableDraggable: function () {
  2811. var sb = s.scrollbar;
  2812. var target = s.support.touch ? sb.track : document;
  2813. $(sb.track).on(sb.draggableEvents.start, sb.dragStart);
  2814. $(target).on(sb.draggableEvents.move, sb.dragMove);
  2815. $(target).on(sb.draggableEvents.end, sb.dragEnd);
  2816. },
  2817. disableDraggable: function () {
  2818. var sb = s.scrollbar;
  2819. var target = s.support.touch ? sb.track : document;
  2820. $(sb.track).off(sb.draggableEvents.start, sb.dragStart);
  2821. $(target).off(sb.draggableEvents.move, sb.dragMove);
  2822. $(target).off(sb.draggableEvents.end, sb.dragEnd);
  2823. },
  2824. set: function () {
  2825. if (!s.params.scrollbar) return;
  2826. var sb = s.scrollbar;
  2827. sb.track = $(s.params.scrollbar);
  2828. if (s.params.uniqueNavElements && typeof s.params.scrollbar === 'string' && sb.track.length > 1 && s.container.find(s.params.scrollbar).length === 1) {
  2829. sb.track = s.container.find(s.params.scrollbar);
  2830. }
  2831. sb.drag = sb.track.find('.swiper-scrollbar-drag');
  2832. if (sb.drag.length === 0) {
  2833. sb.drag = $('<div class="swiper-scrollbar-drag"></div>');
  2834. sb.track.append(sb.drag);
  2835. }
  2836. sb.drag[0].style.width = '';
  2837. sb.drag[0].style.height = '';
  2838. sb.trackSize = s.isHorizontal() ? sb.track[0].offsetWidth : sb.track[0].offsetHeight;
  2839. sb.divider = s.size / s.virtualSize;
  2840. sb.moveDivider = sb.divider * (sb.trackSize / s.size);
  2841. sb.dragSize = sb.trackSize * sb.divider;
  2842. if (s.isHorizontal()) {
  2843. sb.drag[0].style.width = sb.dragSize + 'px';
  2844. }
  2845. else {
  2846. sb.drag[0].style.height = sb.dragSize + 'px';
  2847. }
  2848. if (sb.divider >= 1) {
  2849. sb.track[0].style.display = 'none';
  2850. }
  2851. else {
  2852. sb.track[0].style.display = '';
  2853. }
  2854. if (s.params.scrollbarHide) {
  2855. sb.track[0].style.opacity = 0;
  2856. }
  2857. },
  2858. setTranslate: function () {
  2859. if (!s.params.scrollbar) return;
  2860. var diff;
  2861. var sb = s.scrollbar;
  2862. var translate = s.translate || 0;
  2863. var newPos;
  2864. var newSize = sb.dragSize;
  2865. newPos = (sb.trackSize - sb.dragSize) * s.progress;
  2866. if (s.rtl && s.isHorizontal()) {
  2867. newPos = -newPos;
  2868. if (newPos > 0) {
  2869. newSize = sb.dragSize - newPos;
  2870. newPos = 0;
  2871. }
  2872. else if (-newPos + sb.dragSize > sb.trackSize) {
  2873. newSize = sb.trackSize + newPos;
  2874. }
  2875. }
  2876. else {
  2877. if (newPos < 0) {
  2878. newSize = sb.dragSize + newPos;
  2879. newPos = 0;
  2880. }
  2881. else if (newPos + sb.dragSize > sb.trackSize) {
  2882. newSize = sb.trackSize - newPos;
  2883. }
  2884. }
  2885. if (s.isHorizontal()) {
  2886. if (s.support.transforms3d) {
  2887. sb.drag.transform('translate3d(' + (newPos) + 'px, 0, 0)');
  2888. }
  2889. else {
  2890. sb.drag.transform('translateX(' + (newPos) + 'px)');
  2891. }
  2892. sb.drag[0].style.width = newSize + 'px';
  2893. }
  2894. else {
  2895. if (s.support.transforms3d) {
  2896. sb.drag.transform('translate3d(0px, ' + (newPos) + 'px, 0)');
  2897. }
  2898. else {
  2899. sb.drag.transform('translateY(' + (newPos) + 'px)');
  2900. }
  2901. sb.drag[0].style.height = newSize + 'px';
  2902. }
  2903. if (s.params.scrollbarHide) {
  2904. clearTimeout(sb.timeout);
  2905. sb.track[0].style.opacity = 1;
  2906. sb.timeout = setTimeout(function () {
  2907. sb.track[0].style.opacity = 0;
  2908. sb.track.transition(400);
  2909. }, 1000);
  2910. }
  2911. },
  2912. setTransition: function (duration) {
  2913. if (!s.params.scrollbar) return;
  2914. s.scrollbar.drag.transition(duration);
  2915. }
  2916. };
  2917. /*=========================
  2918. Controller
  2919. ===========================*/
  2920. s.controller = {
  2921. LinearSpline: function (x, y) {
  2922. var binarySearch = (function() {
  2923. var maxIndex, minIndex, guess;
  2924. return function(array, val) {
  2925. minIndex = -1;
  2926. maxIndex = array.length;
  2927. while (maxIndex - minIndex > 1)
  2928. if (array[guess = maxIndex + minIndex >> 1] <= val) {
  2929. minIndex = guess;
  2930. } else {
  2931. maxIndex = guess;
  2932. }
  2933. return maxIndex;
  2934. };
  2935. })();
  2936. this.x = x;
  2937. this.y = y;
  2938. this.lastIndex = x.length - 1;
  2939. // Given an x value (x2), return the expected y2 value:
  2940. // (x1,y1) is the known point before given value,
  2941. // (x3,y3) is the known point after given value.
  2942. var i1, i3;
  2943. var l = this.x.length;
  2944. this.interpolate = function (x2) {
  2945. if (!x2) return 0;
  2946. // Get the indexes of x1 and x3 (the array indexes before and after given x2):
  2947. i3 = binarySearch(this.x, x2);
  2948. i1 = i3 - 1;
  2949. // We have our indexes i1 & i3, so we can calculate already:
  2950. // y2 := ((x2−x1) × (y3−y1)) ÷ (x3−x1) + y1
  2951. return ((x2 - this.x[i1]) * (this.y[i3] - this.y[i1])) / (this.x[i3] - this.x[i1]) + this.y[i1];
  2952. };
  2953. },
  2954. //xxx: for now i will just save one spline function to to
  2955. getInterpolateFunction: function(c){
  2956. if(!s.controller.spline) s.controller.spline = s.params.loop ?
  2957. new s.controller.LinearSpline(s.slidesGrid, c.slidesGrid) :
  2958. new s.controller.LinearSpline(s.snapGrid, c.snapGrid);
  2959. },
  2960. setTranslate: function (translate, byController) {
  2961. var controlled = s.params.control;
  2962. var multiplier, controlledTranslate;
  2963. function setControlledTranslate(c) {
  2964. // this will create an Interpolate function based on the snapGrids
  2965. // x is the Grid of the scrolled scroller and y will be the controlled scroller
  2966. // it makes sense to create this only once and recall it for the interpolation
  2967. // the function does a lot of value caching for performance
  2968. translate = c.rtl && c.params.direction === 'horizontal' ? -s.translate : s.translate;
  2969. if (s.params.controlBy === 'slide') {
  2970. s.controller.getInterpolateFunction(c);
  2971. // i am not sure why the values have to be multiplicated this way, tried to invert the snapGrid
  2972. // but it did not work out
  2973. controlledTranslate = -s.controller.spline.interpolate(-translate);
  2974. }
  2975. if(!controlledTranslate || s.params.controlBy === 'container'){
  2976. multiplier = (c.maxTranslate() - c.minTranslate()) / (s.maxTranslate() - s.minTranslate());
  2977. controlledTranslate = (translate - s.minTranslate()) * multiplier + c.minTranslate();
  2978. }
  2979. if (s.params.controlInverse) {
  2980. controlledTranslate = c.maxTranslate() - controlledTranslate;
  2981. }
  2982. c.updateProgress(controlledTranslate);
  2983. c.setWrapperTranslate(controlledTranslate, false, s);
  2984. c.updateActiveIndex();
  2985. }
  2986. if (Array.isArray(controlled)) {
  2987. for (var i = 0; i < controlled.length; i++) {
  2988. if (controlled[i] !== byController && controlled[i] instanceof Swiper) {
  2989. setControlledTranslate(controlled[i]);
  2990. }
  2991. }
  2992. }
  2993. else if (controlled instanceof Swiper && byController !== controlled) {
  2994. setControlledTranslate(controlled);
  2995. }
  2996. },
  2997. setTransition: function (duration, byController) {
  2998. var controlled = s.params.control;
  2999. var i;
  3000. function setControlledTransition(c) {
  3001. c.setWrapperTransition(duration, s);
  3002. if (duration !== 0) {
  3003. c.onTransitionStart();
  3004. c.wrapper.transitionEnd(function(){
  3005. if (!controlled) return;
  3006. if (c.params.loop && s.params.controlBy === 'slide') {
  3007. c.fixLoop();
  3008. }
  3009. c.onTransitionEnd();
  3010. });
  3011. }
  3012. }
  3013. if (Array.isArray(controlled)) {
  3014. for (i = 0; i < controlled.length; i++) {
  3015. if (controlled[i] !== byController && controlled[i] instanceof Swiper) {
  3016. setControlledTransition(controlled[i]);
  3017. }
  3018. }
  3019. }
  3020. else if (controlled instanceof Swiper && byController !== controlled) {
  3021. setControlledTransition(controlled);
  3022. }
  3023. }
  3024. };
  3025. /*=========================
  3026. Hash Navigation
  3027. ===========================*/
  3028. s.hashnav = {
  3029. onHashCange: function (e, a) {
  3030. var newHash = document.location.hash.replace('#', '');
  3031. var activeSlideHash = s.slides.eq(s.activeIndex).attr('data-hash');
  3032. if (newHash !== activeSlideHash) {
  3033. s.slideTo(s.wrapper.children('.' + s.params.slideClass + '[data-hash="' + (newHash) + '"]').index());
  3034. }
  3035. },
  3036. attachEvents: function (detach) {
  3037. var action = detach ? 'off' : 'on';
  3038. $(window)[action]('hashchange', s.hashnav.onHashCange);
  3039. },
  3040. setHash: function () {
  3041. if (!s.hashnav.initialized || !s.params.hashnav) return;
  3042. if (s.params.replaceState && window.history && window.history.replaceState) {
  3043. window.history.replaceState(null, null, ('#' + s.slides.eq(s.activeIndex).attr('data-hash') || ''));
  3044. } else {
  3045. var slide = s.slides.eq(s.activeIndex);
  3046. var hash = slide.attr('data-hash') || slide.attr('data-history');
  3047. document.location.hash = hash || '';
  3048. }
  3049. },
  3050. init: function () {
  3051. if (!s.params.hashnav || s.params.history) return;
  3052. s.hashnav.initialized = true;
  3053. var hash = document.location.hash.replace('#', '');
  3054. if (hash) {
  3055. var speed = 0;
  3056. for (var i = 0, length = s.slides.length; i < length; i++) {
  3057. var slide = s.slides.eq(i);
  3058. var slideHash = slide.attr('data-hash') || slide.attr('data-history');
  3059. if (slideHash === hash && !slide.hasClass(s.params.slideDuplicateClass)) {
  3060. var index = slide.index();
  3061. s.slideTo(index, speed, s.params.runCallbacksOnInit, true);
  3062. }
  3063. }
  3064. }
  3065. if (s.params.hashnavWatchState) s.hashnav.attachEvents();
  3066. },
  3067. destroy: function () {
  3068. if (s.params.hashnavWatchState) s.hashnav.attachEvents(true);
  3069. }
  3070. };
  3071. /*=========================
  3072. History Api with fallback to Hashnav
  3073. ===========================*/
  3074. s.history = {
  3075. init: function () {
  3076. if (!s.params.history) return;
  3077. if (!window.history || !window.history.pushState) {
  3078. s.params.history = false;
  3079. s.params.hashnav = true;
  3080. return;
  3081. }
  3082. s.history.initialized = true;
  3083. this.paths = this.getPathValues();
  3084. if (!this.paths.key && !this.paths.value) return;
  3085. this.scrollToSlide(0, this.paths.value, s.params.runCallbacksOnInit);
  3086. if (!s.params.replaceState) {
  3087. window.addEventListener('popstate', this.setHistoryPopState);
  3088. }
  3089. },
  3090. setHistoryPopState: function() {
  3091. s.history.paths = s.history.getPathValues();
  3092. s.history.scrollToSlide(s.params.speed, s.history.paths.value, false);
  3093. },
  3094. getPathValues: function() {
  3095. var pathArray = window.location.pathname.slice(1).split('/');
  3096. var total = pathArray.length;
  3097. var key = pathArray[total - 2];
  3098. var value = pathArray[total - 1];
  3099. return { key: key, value: value };
  3100. },
  3101. setHistory: function (key, index) {
  3102. if (!s.history.initialized || !s.params.history) return;
  3103. var slide = s.slides.eq(index);
  3104. var value = this.slugify(slide.attr('data-history'));
  3105. if (!window.location.pathname.includes(key)) {
  3106. value = key + '/' + value;
  3107. }
  3108. if (s.params.replaceState) {
  3109. window.history.replaceState(null, null, value);
  3110. } else {
  3111. window.history.pushState(null, null, value);
  3112. }
  3113. },
  3114. slugify: function(text) {
  3115. return text.toString().toLowerCase()
  3116. .replace(/\s+/g, '-')
  3117. .replace(/[^\w\-]+/g, '')
  3118. .replace(/\-\-+/g, '-')
  3119. .replace(/^-+/, '')
  3120. .replace(/-+$/, '');
  3121. },
  3122. scrollToSlide: function(speed, value, runCallbacks) {
  3123. if (value) {
  3124. for (var i = 0, length = s.slides.length; i < length; i++) {
  3125. var slide = s.slides.eq(i);
  3126. var slideHistory = this.slugify(slide.attr('data-history'));
  3127. if (slideHistory === value && !slide.hasClass(s.params.slideDuplicateClass)) {
  3128. var index = slide.index();
  3129. s.slideTo(index, speed, runCallbacks);
  3130. }
  3131. }
  3132. } else {
  3133. s.slideTo(0, speed, runCallbacks);
  3134. }
  3135. }
  3136. };
  3137. /*=========================
  3138. Keyboard Control
  3139. ===========================*/
  3140. function handleKeyboard(e) {
  3141. if (e.originalEvent) e = e.originalEvent; //jquery fix
  3142. var kc = e.keyCode || e.charCode;
  3143. // Directions locks
  3144. if (!s.params.allowSwipeToNext && (s.isHorizontal() && kc === 39 || !s.isHorizontal() && kc === 40)) {
  3145. return false;
  3146. }
  3147. if (!s.params.allowSwipeToPrev && (s.isHorizontal() && kc === 37 || !s.isHorizontal() && kc === 38)) {
  3148. return false;
  3149. }
  3150. if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey) {
  3151. return;
  3152. }
  3153. if (document.activeElement && document.activeElement.nodeName && (document.activeElement.nodeName.toLowerCase() === 'input' || document.activeElement.nodeName.toLowerCase() === 'textarea')) {
  3154. return;
  3155. }
  3156. if (kc === 37 || kc === 39 || kc === 38 || kc === 40) {
  3157. var inView = false;
  3158. //Check that swiper should be inside of visible area of window
  3159. if (s.container.parents('.' + s.params.slideClass).length > 0 && s.container.parents('.' + s.params.slideActiveClass).length === 0) {
  3160. return;
  3161. }
  3162. var windowScroll = {
  3163. left: window.pageXOffset,
  3164. top: window.pageYOffset
  3165. };
  3166. var windowWidth = window.innerWidth;
  3167. var windowHeight = window.innerHeight;
  3168. var swiperOffset = s.container.offset();
  3169. if (s.rtl) swiperOffset.left = swiperOffset.left - s.container[0].scrollLeft;
  3170. var swiperCoord = [
  3171. [swiperOffset.left, swiperOffset.top],
  3172. [swiperOffset.left + s.width, swiperOffset.top],
  3173. [swiperOffset.left, swiperOffset.top + s.height],
  3174. [swiperOffset.left + s.width, swiperOffset.top + s.height]
  3175. ];
  3176. for (var i = 0; i < swiperCoord.length; i++) {
  3177. var point = swiperCoord[i];
  3178. if (
  3179. point[0] >= windowScroll.left && point[0] <= windowScroll.left + windowWidth &&
  3180. point[1] >= windowScroll.top && point[1] <= windowScroll.top + windowHeight
  3181. ) {
  3182. inView = true;
  3183. }
  3184. }
  3185. if (!inView) return;
  3186. }
  3187. if (s.isHorizontal()) {
  3188. if (kc === 37 || kc === 39) {
  3189. if (e.preventDefault) e.preventDefault();
  3190. else e.returnValue = false;
  3191. }
  3192. if ((kc === 39 && !s.rtl) || (kc === 37 && s.rtl)) s.slideNext();
  3193. if ((kc === 37 && !s.rtl) || (kc === 39 && s.rtl)) s.slidePrev();
  3194. }
  3195. else {
  3196. if (kc === 38 || kc === 40) {
  3197. if (e.preventDefault) e.preventDefault();
  3198. else e.returnValue = false;
  3199. }
  3200. if (kc === 40) s.slideNext();
  3201. if (kc === 38) s.slidePrev();
  3202. }
  3203. s.emit('onKeyPress', s, kc);
  3204. }
  3205. s.disableKeyboardControl = function () {
  3206. s.params.keyboardControl = false;
  3207. $(document).off('keydown', handleKeyboard);
  3208. };
  3209. s.enableKeyboardControl = function () {
  3210. s.params.keyboardControl = true;
  3211. $(document).on('keydown', handleKeyboard);
  3212. };
  3213. /*=========================
  3214. Mousewheel Control
  3215. ===========================*/
  3216. s.mousewheel = {
  3217. event: false,
  3218. lastScrollTime: (new window.Date()).getTime()
  3219. };
  3220. function isEventSupported() {
  3221. var eventName = 'onwheel';
  3222. var isSupported = eventName in document;
  3223. if (!isSupported) {
  3224. var element = document.createElement('div');
  3225. element.setAttribute(eventName, 'return;');
  3226. isSupported = typeof element[eventName] === 'function';
  3227. }
  3228. if (!isSupported &&
  3229. document.implementation &&
  3230. document.implementation.hasFeature &&
  3231. // always returns true in newer browsers as per the standard.
  3232. // @see http://dom.spec.whatwg.org/#dom-domimplementation-hasfeature
  3233. document.implementation.hasFeature('', '') !== true ) {
  3234. // This is the only way to test support for the `wheel` event in IE9+.
  3235. isSupported = document.implementation.hasFeature('Events.wheel', '3.0');
  3236. }
  3237. return isSupported;
  3238. }
  3239. /**
  3240. * Mouse wheel (and 2-finger trackpad) support on the web sucks. It is
  3241. * complicated, thus this doc is long and (hopefully) detailed enough to answer
  3242. * your questions.
  3243. *
  3244. * If you need to react to the mouse wheel in a predictable way, this code is
  3245. * like your bestest friend. * hugs *
  3246. *
  3247. * As of today, there are 4 DOM event types you can listen to:
  3248. *
  3249. * 'wheel' -- Chrome(31+), FF(17+), IE(9+)
  3250. * 'mousewheel' -- Chrome, IE(6+), Opera, Safari
  3251. * 'MozMousePixelScroll' -- FF(3.5 only!) (2010-2013) -- don't bother!
  3252. * 'DOMMouseScroll' -- FF(0.9.7+) since 2003
  3253. *
  3254. * So what to do? The is the best:
  3255. *
  3256. * normalizeWheel.getEventType();
  3257. *
  3258. * In your event callback, use this code to get sane interpretation of the
  3259. * deltas. This code will return an object with properties:
  3260. *
  3261. * spinX -- normalized spin speed (use for zoom) - x plane
  3262. * spinY -- " - y plane
  3263. * pixelX -- normalized distance (to pixels) - x plane
  3264. * pixelY -- " - y plane
  3265. *
  3266. * Wheel values are provided by the browser assuming you are using the wheel to
  3267. * scroll a web page by a number of lines or pixels (or pages). Values can vary
  3268. * significantly on different platforms and browsers, forgetting that you can
  3269. * scroll at different speeds. Some devices (like trackpads) emit more events
  3270. * at smaller increments with fine granularity, and some emit massive jumps with
  3271. * linear speed or acceleration.
  3272. *
  3273. * This code does its best to normalize the deltas for you:
  3274. *
  3275. * - spin is trying to normalize how far the wheel was spun (or trackpad
  3276. * dragged). This is super useful for zoom support where you want to
  3277. * throw away the chunky scroll steps on the PC and make those equal to
  3278. * the slow and smooth tiny steps on the Mac. Key data: This code tries to
  3279. * resolve a single slow step on a wheel to 1.
  3280. *
  3281. * - pixel is normalizing the desired scroll delta in pixel units. You'll
  3282. * get the crazy differences between browsers, but at least it'll be in
  3283. * pixels!
  3284. *
  3285. * - positive value indicates scrolling DOWN/RIGHT, negative UP/LEFT. This
  3286. * should translate to positive value zooming IN, negative zooming OUT.
  3287. * This matches the newer 'wheel' event.
  3288. *
  3289. * Why are there spinX, spinY (or pixels)?
  3290. *
  3291. * - spinX is a 2-finger side drag on the trackpad, and a shift + wheel turn
  3292. * with a mouse. It results in side-scrolling in the browser by default.
  3293. *
  3294. * - spinY is what you expect -- it's the classic axis of a mouse wheel.
  3295. *
  3296. * - I dropped spinZ/pixelZ. It is supported by the DOM 3 'wheel' event and
  3297. * probably is by browsers in conjunction with fancy 3D controllers .. but
  3298. * you know.
  3299. *
  3300. * Implementation info:
  3301. *
  3302. * Examples of 'wheel' event if you scroll slowly (down) by one step with an
  3303. * average mouse:
  3304. *
  3305. * OS X + Chrome (mouse) - 4 pixel delta (wheelDelta -120)
  3306. * OS X + Safari (mouse) - N/A pixel delta (wheelDelta -12)
  3307. * OS X + Firefox (mouse) - 0.1 line delta (wheelDelta N/A)
  3308. * Win8 + Chrome (mouse) - 100 pixel delta (wheelDelta -120)
  3309. * Win8 + Firefox (mouse) - 3 line delta (wheelDelta -120)
  3310. *
  3311. * On the trackpad:
  3312. *
  3313. * OS X + Chrome (trackpad) - 2 pixel delta (wheelDelta -6)
  3314. * OS X + Firefox (trackpad) - 1 pixel delta (wheelDelta N/A)
  3315. *
  3316. * On other/older browsers.. it's more complicated as there can be multiple and
  3317. * also missing delta values.
  3318. *
  3319. * The 'wheel' event is more standard:
  3320. *
  3321. * http://www.w3.org/TR/DOM-Level-3-Events/#events-wheelevents
  3322. *
  3323. * The basics is that it includes a unit, deltaMode (pixels, lines, pages), and
  3324. * deltaX, deltaY and deltaZ. Some browsers provide other values to maintain
  3325. * backward compatibility with older events. Those other values help us
  3326. * better normalize spin speed. Example of what the browsers provide:
  3327. *
  3328. * | event.wheelDelta | event.detail
  3329. * ------------------+------------------+--------------
  3330. * Safari v5/OS X | -120 | 0
  3331. * Safari v5/Win7 | -120 | 0
  3332. * Chrome v17/OS X | -120 | 0
  3333. * Chrome v17/Win7 | -120 | 0
  3334. * IE9/Win7 | -120 | undefined
  3335. * Firefox v4/OS X | undefined | 1
  3336. * Firefox v4/Win7 | undefined | 3
  3337. *
  3338. */
  3339. function normalizeWheel( /*object*/ event ) /*object*/ {
  3340. // Reasonable defaults
  3341. var PIXEL_STEP = 10;
  3342. var LINE_HEIGHT = 40;
  3343. var PAGE_HEIGHT = 800;
  3344. var sX = 0, sY = 0, // spinX, spinY
  3345. pX = 0, pY = 0; // pixelX, pixelY
  3346. // Legacy
  3347. if( 'detail' in event ) {
  3348. sY = event.detail;
  3349. }
  3350. if( 'wheelDelta' in event ) {
  3351. sY = -event.wheelDelta / 120;
  3352. }
  3353. if( 'wheelDeltaY' in event ) {
  3354. sY = -event.wheelDeltaY / 120;
  3355. }
  3356. if( 'wheelDeltaX' in event ) {
  3357. sX = -event.wheelDeltaX / 120;
  3358. }
  3359. if(s.isEnd && sY > 0){
  3360. return{
  3361. spinX: 0,
  3362. spinY: 0,
  3363. pixelX: 0,
  3364. pixelY: 0
  3365. };
  3366. }else if(s.isBeginning && sY < 0){
  3367. return{
  3368. spinX: 0,
  3369. spinY: 0,
  3370. pixelX: 0,
  3371. pixelY: 0
  3372. };
  3373. }
  3374. // side scrolling on FF with DOMMouseScroll
  3375. if( 'axis' in event && event.axis === event.HORIZONTAL_AXIS ) {
  3376. sX = sY;
  3377. sY = 0;
  3378. }
  3379. pX = sX * PIXEL_STEP;
  3380. pY = sY * PIXEL_STEP;
  3381. if( 'deltaY' in event ) {
  3382. pY = event.deltaY;
  3383. }
  3384. if( 'deltaX' in event ) {
  3385. pX = event.deltaX;
  3386. }
  3387. if( (pX || pY) && event.deltaMode ) {
  3388. if( event.deltaMode === 1 ) { // delta in LINE units
  3389. pX *= LINE_HEIGHT;
  3390. pY *= LINE_HEIGHT;
  3391. } else { // delta in PAGE units
  3392. pX *= PAGE_HEIGHT;
  3393. pY *= PAGE_HEIGHT;
  3394. }
  3395. }
  3396. // Fall-back if spin cannot be determined
  3397. if( pX && !sX ) {
  3398. sX = (pX < 1) ? -1 : 1;
  3399. }
  3400. if( pY && !sY ) {
  3401. sY = (pY < 1) ? -1 : 1;
  3402. }
  3403. return {
  3404. spinX: sX,
  3405. spinY: sY,
  3406. pixelX: pX,
  3407. pixelY: pY
  3408. };
  3409. }
  3410. if (s.params.mousewheelControl) {
  3411. /**
  3412. * The best combination if you prefer spinX + spinY normalization. It favors
  3413. * the older DOMMouseScroll for Firefox, as FF does not include wheelDelta with
  3414. * 'wheel' event, making spin speed determination impossible.
  3415. */
  3416. s.mousewheel.event = (navigator.userAgent.indexOf('firefox') > -1) ?
  3417. 'DOMMouseScroll' :
  3418. isEventSupported() ?
  3419. 'wheel' : 'mousewheel';
  3420. }
  3421. function handleMousewheel(e) {
  3422. if (e.originalEvent) e = e.originalEvent; //jquery fix
  3423. var delta = 0;
  3424. var rtlFactor = s.rtl ? -1 : 1;
  3425. var data = normalizeWheel( e );
  3426. if (s.params.mousewheelForceToAxis) {
  3427. if (s.isHorizontal()) {
  3428. if (Math.abs(data.pixelX) > Math.abs(data.pixelY)) delta = data.pixelX * rtlFactor;
  3429. else return;
  3430. }
  3431. else {
  3432. if (Math.abs(data.pixelY) > Math.abs(data.pixelX)) delta = data.pixelY;
  3433. else return;
  3434. }
  3435. }
  3436. else {
  3437. delta = Math.abs(data.pixelX) > Math.abs(data.pixelY) ? - data.pixelX * rtlFactor : - data.pixelY;
  3438. }
  3439. if (delta === 0) return;
  3440. if (s.params.mousewheelInvert) delta = -delta;
  3441. if (!s.params.freeMode) {
  3442. if ((new window.Date()).getTime() - s.mousewheel.lastScrollTime > 60) {
  3443. if (delta < 0) {
  3444. if ((!s.isEnd || s.params.loop) && !s.animating) {
  3445. s.slideNext();
  3446. s.emit('onScroll', s, e);
  3447. }
  3448. else if (s.params.mousewheelReleaseOnEdges) return true;
  3449. }
  3450. else {
  3451. if ((!s.isBeginning || s.params.loop) && !s.animating) {
  3452. s.slidePrev();
  3453. s.emit('onScroll', s, e);
  3454. }
  3455. else if (s.params.mousewheelReleaseOnEdges) return true;
  3456. }
  3457. }
  3458. s.mousewheel.lastScrollTime = (new window.Date()).getTime();
  3459. }
  3460. else {
  3461. //Freemode or scrollContainer:
  3462. var position = s.getWrapperTranslate() + delta * s.params.mousewheelSensitivity;
  3463. var wasBeginning = s.isBeginning,
  3464. wasEnd = s.isEnd;
  3465. if (position >= s.minTranslate()) position = s.minTranslate();
  3466. if (position <= s.maxTranslate()) position = s.maxTranslate();
  3467. s.setWrapperTransition(0);
  3468. s.setWrapperTranslate(position);
  3469. s.updateProgress();
  3470. s.updateActiveIndex();
  3471. if (!wasBeginning && s.isBeginning || !wasEnd && s.isEnd) {
  3472. s.updateClasses();
  3473. }
  3474. if (s.params.freeModeSticky) {
  3475. clearTimeout(s.mousewheel.timeout);
  3476. s.mousewheel.timeout = setTimeout(function () {
  3477. s.slideReset();
  3478. }, 300);
  3479. }
  3480. else {
  3481. if (s.params.lazyLoading && s.lazy) {
  3482. s.lazy.load();
  3483. }
  3484. }
  3485. // Emit event
  3486. s.emit('onScroll', s, e);
  3487. // Stop autoplay
  3488. if (s.params.autoplay && s.params.autoplayDisableOnInteraction) s.stopAutoplay();
  3489. // Return page scroll on edge positions
  3490. if (position === 0 || position === s.maxTranslate()) return;
  3491. }
  3492. if (e.preventDefault) e.preventDefault();
  3493. else e.returnValue = false;
  3494. return false;
  3495. }
  3496. s.disableMousewheelControl = function () {
  3497. if (!s.mousewheel.event) return false;
  3498. var target = s.container;
  3499. if (s.params.mousewheelEventsTarged !== 'container') {
  3500. target = $(s.params.mousewheelEventsTarged);
  3501. }
  3502. target.off(s.mousewheel.event, handleMousewheel);
  3503. s.params.mousewheelControl = false;
  3504. return true;
  3505. };
  3506. s.enableMousewheelControl = function () {
  3507. if (!s.mousewheel.event) return false;
  3508. var target = s.container;
  3509. if (s.params.mousewheelEventsTarged !== 'container') {
  3510. target = $(s.params.mousewheelEventsTarged);
  3511. }
  3512. target.on(s.mousewheel.event, handleMousewheel);
  3513. s.params.mousewheelControl = true;
  3514. return true;
  3515. };
  3516. /*=========================
  3517. Parallax
  3518. ===========================*/
  3519. function setParallaxTransform(el, progress) {
  3520. el = $(el);
  3521. var p, pX, pY;
  3522. var rtlFactor = s.rtl ? -1 : 1;
  3523. p = el.attr('data-swiper-parallax') || '0';
  3524. pX = el.attr('data-swiper-parallax-x');
  3525. pY = el.attr('data-swiper-parallax-y');
  3526. if (pX || pY) {
  3527. pX = pX || '0';
  3528. pY = pY || '0';
  3529. }
  3530. else {
  3531. if (s.isHorizontal()) {
  3532. pX = p;
  3533. pY = '0';
  3534. }
  3535. else {
  3536. pY = p;
  3537. pX = '0';
  3538. }
  3539. }
  3540. if ((pX).indexOf('%') >= 0) {
  3541. pX = parseInt(pX, 10) * progress * rtlFactor + '%';
  3542. }
  3543. else {
  3544. pX = pX * progress * rtlFactor + 'px' ;
  3545. }
  3546. if ((pY).indexOf('%') >= 0) {
  3547. pY = parseInt(pY, 10) * progress + '%';
  3548. }
  3549. else {
  3550. pY = pY * progress + 'px' ;
  3551. }
  3552. el.transform('translate3d(' + pX + ', ' + pY + ',0px)');
  3553. }
  3554. s.parallax = {
  3555. setTranslate: function () {
  3556. s.container.children('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y]').each(function(){
  3557. setParallaxTransform(this, s.progress);
  3558. });
  3559. s.slides.each(function () {
  3560. var slide = $(this);
  3561. slide.find('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y]').each(function () {
  3562. var progress = Math.min(Math.max(slide[0].progress, -1), 1);
  3563. setParallaxTransform(this, progress);
  3564. });
  3565. });
  3566. },
  3567. setTransition: function (duration) {
  3568. if (typeof duration === 'undefined') duration = s.params.speed;
  3569. s.container.find('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y]').each(function(){
  3570. var el = $(this);
  3571. var parallaxDuration = parseInt(el.attr('data-swiper-parallax-duration'), 10) || duration;
  3572. if (duration === 0) parallaxDuration = 0;
  3573. el.transition(parallaxDuration);
  3574. });
  3575. }
  3576. };
  3577. /*=========================
  3578. Zoom
  3579. ===========================*/
  3580. s.zoom = {
  3581. // "Global" Props
  3582. scale: 1,
  3583. currentScale: 1,
  3584. isScaling: false,
  3585. gesture: {
  3586. slide: undefined,
  3587. slideWidth: undefined,
  3588. slideHeight: undefined,
  3589. image: undefined,
  3590. imageWrap: undefined,
  3591. zoomMax: s.params.zoomMax
  3592. },
  3593. image: {
  3594. isTouched: undefined,
  3595. isMoved: undefined,
  3596. currentX: undefined,
  3597. currentY: undefined,
  3598. minX: undefined,
  3599. minY: undefined,
  3600. maxX: undefined,
  3601. maxY: undefined,
  3602. width: undefined,
  3603. height: undefined,
  3604. startX: undefined,
  3605. startY: undefined,
  3606. touchesStart: {},
  3607. touchesCurrent: {}
  3608. },
  3609. velocity: {
  3610. x: undefined,
  3611. y: undefined,
  3612. prevPositionX: undefined,
  3613. prevPositionY: undefined,
  3614. prevTime: undefined
  3615. },
  3616. // Calc Scale From Multi-touches
  3617. getDistanceBetweenTouches: function (e) {
  3618. if (e.targetTouches.length < 2) return 1;
  3619. var x1 = e.targetTouches[0].pageX,
  3620. y1 = e.targetTouches[0].pageY,
  3621. x2 = e.targetTouches[1].pageX,
  3622. y2 = e.targetTouches[1].pageY;
  3623. var distance = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
  3624. return distance;
  3625. },
  3626. // Events
  3627. onGestureStart: function (e) {
  3628. var z = s.zoom;
  3629. if (!s.support.gestures) {
  3630. if (e.type !== 'touchstart' || e.type === 'touchstart' && e.targetTouches.length < 2) {
  3631. return;
  3632. }
  3633. z.gesture.scaleStart = z.getDistanceBetweenTouches(e);
  3634. }
  3635. if (!z.gesture.slide || !z.gesture.slide.length) {
  3636. z.gesture.slide = $(this);
  3637. if (z.gesture.slide.length === 0) z.gesture.slide = s.slides.eq(s.activeIndex);
  3638. z.gesture.image = z.gesture.slide.find('img, svg, canvas');
  3639. z.gesture.imageWrap = z.gesture.image.parent('.' + s.params.zoomContainerClass);
  3640. z.gesture.zoomMax = z.gesture.imageWrap.attr('data-swiper-zoom') || s.params.zoomMax ;
  3641. if (z.gesture.imageWrap.length === 0) {
  3642. z.gesture.image = undefined;
  3643. return;
  3644. }
  3645. }
  3646. z.gesture.image.transition(0);
  3647. z.isScaling = true;
  3648. },
  3649. onGestureChange: function (e) {
  3650. var z = s.zoom;
  3651. if (!s.support.gestures) {
  3652. if (e.type !== 'touchmove' || e.type === 'touchmove' && e.targetTouches.length < 2) {
  3653. return;
  3654. }
  3655. z.gesture.scaleMove = z.getDistanceBetweenTouches(e);
  3656. }
  3657. if (!z.gesture.image || z.gesture.image.length === 0) return;
  3658. if (s.support.gestures) {
  3659. z.scale = e.scale * z.currentScale;
  3660. }
  3661. else {
  3662. z.scale = (z.gesture.scaleMove / z.gesture.scaleStart) * z.currentScale;
  3663. }
  3664. if (z.scale > z.gesture.zoomMax) {
  3665. z.scale = z.gesture.zoomMax - 1 + Math.pow((z.scale - z.gesture.zoomMax + 1), 0.5);
  3666. }
  3667. if (z.scale < s.params.zoomMin) {
  3668. z.scale = s.params.zoomMin + 1 - Math.pow((s.params.zoomMin - z.scale + 1), 0.5);
  3669. }
  3670. z.gesture.image.transform('translate3d(0,0,0) scale(' + z.scale + ')');
  3671. },
  3672. onGestureEnd: function (e) {
  3673. var z = s.zoom;
  3674. if (!s.support.gestures) {
  3675. if (e.type !== 'touchend' || e.type === 'touchend' && e.changedTouches.length < 2) {
  3676. return;
  3677. }
  3678. }
  3679. if (!z.gesture.image || z.gesture.image.length === 0) return;
  3680. z.scale = Math.max(Math.min(z.scale, z.gesture.zoomMax), s.params.zoomMin);
  3681. z.gesture.image.transition(s.params.speed).transform('translate3d(0,0,0) scale(' + z.scale + ')');
  3682. z.currentScale = z.scale;
  3683. z.isScaling = false;
  3684. if (z.scale === 1) z.gesture.slide = undefined;
  3685. },
  3686. onTouchStart: function (s, e) {
  3687. var z = s.zoom;
  3688. if (!z.gesture.image || z.gesture.image.length === 0) return;
  3689. if (z.image.isTouched) return;
  3690. if (s.device.os === 'android') e.preventDefault();
  3691. z.image.isTouched = true;
  3692. z.image.touchesStart.x = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX;
  3693. z.image.touchesStart.y = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY;
  3694. },
  3695. onTouchMove: function (e) {
  3696. var z = s.zoom;
  3697. if (!z.gesture.image || z.gesture.image.length === 0) return;
  3698. s.allowClick = false;
  3699. if (!z.image.isTouched || !z.gesture.slide) return;
  3700. if (!z.image.isMoved) {
  3701. z.image.width = z.gesture.image[0].offsetWidth;
  3702. z.image.height = z.gesture.image[0].offsetHeight;
  3703. z.image.startX = s.getTranslate(z.gesture.imageWrap[0], 'x') || 0;
  3704. z.image.startY = s.getTranslate(z.gesture.imageWrap[0], 'y') || 0;
  3705. z.gesture.slideWidth = z.gesture.slide[0].offsetWidth;
  3706. z.gesture.slideHeight = z.gesture.slide[0].offsetHeight;
  3707. z.gesture.imageWrap.transition(0);
  3708. if (s.rtl) z.image.startX = -z.image.startX;
  3709. if (s.rtl) z.image.startY = -z.image.startY;
  3710. }
  3711. // Define if we need image drag
  3712. var scaledWidth = z.image.width * z.scale;
  3713. var scaledHeight = z.image.height * z.scale;
  3714. if (scaledWidth < z.gesture.slideWidth && scaledHeight < z.gesture.slideHeight) return;
  3715. z.image.minX = Math.min((z.gesture.slideWidth / 2 - scaledWidth / 2), 0);
  3716. z.image.maxX = -z.image.minX;
  3717. z.image.minY = Math.min((z.gesture.slideHeight / 2 - scaledHeight / 2), 0);
  3718. z.image.maxY = -z.image.minY;
  3719. z.image.touchesCurrent.x = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX;
  3720. z.image.touchesCurrent.y = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY;
  3721. if (!z.image.isMoved && !z.isScaling) {
  3722. if (s.isHorizontal() &&
  3723. (Math.floor(z.image.minX) === Math.floor(z.image.startX) && z.image.touchesCurrent.x < z.image.touchesStart.x) ||
  3724. (Math.floor(z.image.maxX) === Math.floor(z.image.startX) && z.image.touchesCurrent.x > z.image.touchesStart.x)
  3725. ) {
  3726. z.image.isTouched = false;
  3727. return;
  3728. }
  3729. else if (!s.isHorizontal() &&
  3730. (Math.floor(z.image.minY) === Math.floor(z.image.startY) && z.image.touchesCurrent.y < z.image.touchesStart.y) ||
  3731. (Math.floor(z.image.maxY) === Math.floor(z.image.startY) && z.image.touchesCurrent.y > z.image.touchesStart.y)
  3732. ) {
  3733. z.image.isTouched = false;
  3734. return;
  3735. }
  3736. }
  3737. e.preventDefault();
  3738. e.stopPropagation();
  3739. z.image.isMoved = true;
  3740. z.image.currentX = z.image.touchesCurrent.x - z.image.touchesStart.x + z.image.startX;
  3741. z.image.currentY = z.image.touchesCurrent.y - z.image.touchesStart.y + z.image.startY;
  3742. if (z.image.currentX < z.image.minX) {
  3743. z.image.currentX = z.image.minX + 1 - Math.pow((z.image.minX - z.image.currentX + 1), 0.8);
  3744. }
  3745. if (z.image.currentX > z.image.maxX) {
  3746. z.image.currentX = z.image.maxX - 1 + Math.pow((z.image.currentX - z.image.maxX + 1), 0.8);
  3747. }
  3748. if (z.image.currentY < z.image.minY) {
  3749. z.image.currentY = z.image.minY + 1 - Math.pow((z.image.minY - z.image.currentY + 1), 0.8);
  3750. }
  3751. if (z.image.currentY > z.image.maxY) {
  3752. z.image.currentY = z.image.maxY - 1 + Math.pow((z.image.currentY - z.image.maxY + 1), 0.8);
  3753. }
  3754. //Velocity
  3755. if (!z.velocity.prevPositionX) z.velocity.prevPositionX = z.image.touchesCurrent.x;
  3756. if (!z.velocity.prevPositionY) z.velocity.prevPositionY = z.image.touchesCurrent.y;
  3757. if (!z.velocity.prevTime) z.velocity.prevTime = Date.now();
  3758. z.velocity.x = (z.image.touchesCurrent.x - z.velocity.prevPositionX) / (Date.now() - z.velocity.prevTime) / 2;
  3759. z.velocity.y = (z.image.touchesCurrent.y - z.velocity.prevPositionY) / (Date.now() - z.velocity.prevTime) / 2;
  3760. if (Math.abs(z.image.touchesCurrent.x - z.velocity.prevPositionX) < 2) z.velocity.x = 0;
  3761. if (Math.abs(z.image.touchesCurrent.y - z.velocity.prevPositionY) < 2) z.velocity.y = 0;
  3762. z.velocity.prevPositionX = z.image.touchesCurrent.x;
  3763. z.velocity.prevPositionY = z.image.touchesCurrent.y;
  3764. z.velocity.prevTime = Date.now();
  3765. z.gesture.imageWrap.transform('translate3d(' + z.image.currentX + 'px, ' + z.image.currentY + 'px,0)');
  3766. },
  3767. onTouchEnd: function (s, e) {
  3768. var z = s.zoom;
  3769. if (!z.gesture.image || z.gesture.image.length === 0) return;
  3770. if (!z.image.isTouched || !z.image.isMoved) {
  3771. z.image.isTouched = false;
  3772. z.image.isMoved = false;
  3773. return;
  3774. }
  3775. z.image.isTouched = false;
  3776. z.image.isMoved = false;
  3777. var momentumDurationX = 300;
  3778. var momentumDurationY = 300;
  3779. var momentumDistanceX = z.velocity.x * momentumDurationX;
  3780. var newPositionX = z.image.currentX + momentumDistanceX;
  3781. var momentumDistanceY = z.velocity.y * momentumDurationY;
  3782. var newPositionY = z.image.currentY + momentumDistanceY;
  3783. //Fix duration
  3784. if (z.velocity.x !== 0) momentumDurationX = Math.abs((newPositionX - z.image.currentX) / z.velocity.x);
  3785. if (z.velocity.y !== 0) momentumDurationY = Math.abs((newPositionY - z.image.currentY) / z.velocity.y);
  3786. var momentumDuration = Math.max(momentumDurationX, momentumDurationY);
  3787. z.image.currentX = newPositionX;
  3788. z.image.currentY = newPositionY;
  3789. // Define if we need image drag
  3790. var scaledWidth = z.image.width * z.scale;
  3791. var scaledHeight = z.image.height * z.scale;
  3792. z.image.minX = Math.min((z.gesture.slideWidth / 2 - scaledWidth / 2), 0);
  3793. z.image.maxX = -z.image.minX;
  3794. z.image.minY = Math.min((z.gesture.slideHeight / 2 - scaledHeight / 2), 0);
  3795. z.image.maxY = -z.image.minY;
  3796. z.image.currentX = Math.max(Math.min(z.image.currentX, z.image.maxX), z.image.minX);
  3797. z.image.currentY = Math.max(Math.min(z.image.currentY, z.image.maxY), z.image.minY);
  3798. z.gesture.imageWrap.transition(momentumDuration).transform('translate3d(' + z.image.currentX + 'px, ' + z.image.currentY + 'px,0)');
  3799. },
  3800. onTransitionEnd: function (s) {
  3801. var z = s.zoom;
  3802. if (z.gesture.slide && s.previousIndex !== s.activeIndex) {
  3803. z.gesture.image.transform('translate3d(0,0,0) scale(1)');
  3804. z.gesture.imageWrap.transform('translate3d(0,0,0)');
  3805. z.gesture.slide = z.gesture.image = z.gesture.imageWrap = undefined;
  3806. z.scale = z.currentScale = 1;
  3807. }
  3808. },
  3809. // Toggle Zoom
  3810. toggleZoom: function (s, e) {
  3811. var z = s.zoom;
  3812. if (!z.gesture.slide) {
  3813. z.gesture.slide = s.clickedSlide ? $(s.clickedSlide) : s.slides.eq(s.activeIndex);
  3814. z.gesture.image = z.gesture.slide.find('img, svg, canvas');
  3815. z.gesture.imageWrap = z.gesture.image.parent('.' + s.params.zoomContainerClass);
  3816. }
  3817. if (!z.gesture.image || z.gesture.image.length === 0) return;
  3818. var touchX, touchY, offsetX, offsetY, diffX, diffY, translateX, translateY, imageWidth, imageHeight, scaledWidth, scaledHeight, translateMinX, translateMinY, translateMaxX, translateMaxY, slideWidth, slideHeight;
  3819. if (typeof z.image.touchesStart.x === 'undefined' && e) {
  3820. touchX = e.type === 'touchend' ? e.changedTouches[0].pageX : e.pageX;
  3821. touchY = e.type === 'touchend' ? e.changedTouches[0].pageY : e.pageY;
  3822. }
  3823. else {
  3824. touchX = z.image.touchesStart.x;
  3825. touchY = z.image.touchesStart.y;
  3826. }
  3827. if (z.scale && z.scale !== 1) {
  3828. // Zoom Out
  3829. z.scale = z.currentScale = 1;
  3830. z.gesture.imageWrap.transition(300).transform('translate3d(0,0,0)');
  3831. z.gesture.image.transition(300).transform('translate3d(0,0,0) scale(1)');
  3832. z.gesture.slide = undefined;
  3833. }
  3834. else {
  3835. // Zoom In
  3836. z.scale = z.currentScale = z.gesture.imageWrap.attr('data-swiper-zoom') || s.params.zoomMax;
  3837. if (e) {
  3838. slideWidth = z.gesture.slide[0].offsetWidth;
  3839. slideHeight = z.gesture.slide[0].offsetHeight;
  3840. offsetX = z.gesture.slide.offset().left;
  3841. offsetY = z.gesture.slide.offset().top;
  3842. diffX = offsetX + slideWidth/2 - touchX;
  3843. diffY = offsetY + slideHeight/2 - touchY;
  3844. imageWidth = z.gesture.image[0].offsetWidth;
  3845. imageHeight = z.gesture.image[0].offsetHeight;
  3846. scaledWidth = imageWidth * z.scale;
  3847. scaledHeight = imageHeight * z.scale;
  3848. translateMinX = Math.min((slideWidth / 2 - scaledWidth / 2), 0);
  3849. translateMinY = Math.min((slideHeight / 2 - scaledHeight / 2), 0);
  3850. translateMaxX = -translateMinX;
  3851. translateMaxY = -translateMinY;
  3852. translateX = diffX * z.scale;
  3853. translateY = diffY * z.scale;
  3854. if (translateX < translateMinX) {
  3855. translateX = translateMinX;
  3856. }
  3857. if (translateX > translateMaxX) {
  3858. translateX = translateMaxX;
  3859. }
  3860. if (translateY < translateMinY) {
  3861. translateY = translateMinY;
  3862. }
  3863. if (translateY > translateMaxY) {
  3864. translateY = translateMaxY;
  3865. }
  3866. }
  3867. else {
  3868. translateX = 0;
  3869. translateY = 0;
  3870. }
  3871. z.gesture.imageWrap.transition(300).transform('translate3d(' + translateX + 'px, ' + translateY + 'px,0)');
  3872. z.gesture.image.transition(300).transform('translate3d(0,0,0) scale(' + z.scale + ')');
  3873. }
  3874. },
  3875. // Attach/Detach Events
  3876. attachEvents: function (detach) {
  3877. var action = detach ? 'off' : 'on';
  3878. if (s.params.zoom) {
  3879. var target = s.slides;
  3880. var passiveListener = s.touchEvents.start === 'touchstart' && s.support.passiveListener && s.params.passiveListeners ? {passive: true, capture: false} : false;
  3881. // Scale image
  3882. if (s.support.gestures) {
  3883. s.slides[action]('gesturestart', s.zoom.onGestureStart, passiveListener);
  3884. s.slides[action]('gesturechange', s.zoom.onGestureChange, passiveListener);
  3885. s.slides[action]('gestureend', s.zoom.onGestureEnd, passiveListener);
  3886. }
  3887. else if (s.touchEvents.start === 'touchstart') {
  3888. s.slides[action](s.touchEvents.start, s.zoom.onGestureStart, passiveListener);
  3889. s.slides[action](s.touchEvents.move, s.zoom.onGestureChange, passiveListener);
  3890. s.slides[action](s.touchEvents.end, s.zoom.onGestureEnd, passiveListener);
  3891. }
  3892. // Move image
  3893. s[action]('touchStart', s.zoom.onTouchStart);
  3894. s.slides.each(function (index, slide){
  3895. if ($(slide).find('.' + s.params.zoomContainerClass).length > 0) {
  3896. $(slide)[action](s.touchEvents.move, s.zoom.onTouchMove);
  3897. }
  3898. });
  3899. s[action]('touchEnd', s.zoom.onTouchEnd);
  3900. // Scale Out
  3901. s[action]('transitionEnd', s.zoom.onTransitionEnd);
  3902. if (s.params.zoomToggle) {
  3903. s.on('doubleTap', s.zoom.toggleZoom);
  3904. }
  3905. }
  3906. },
  3907. init: function () {
  3908. s.zoom.attachEvents();
  3909. },
  3910. destroy: function () {
  3911. s.zoom.attachEvents(true);
  3912. }
  3913. };
  3914. /*=========================
  3915. Plugins API. Collect all and init all plugins
  3916. ===========================*/
  3917. s._plugins = [];
  3918. for (var plugin in s.plugins) {
  3919. var p = s.plugins[plugin](s, s.params[plugin]);
  3920. if (p) s._plugins.push(p);
  3921. }
  3922. // Method to call all plugins event/method
  3923. s.callPlugins = function (eventName) {
  3924. for (var i = 0; i < s._plugins.length; i++) {
  3925. if (eventName in s._plugins[i]) {
  3926. s._plugins[i][eventName](arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]);
  3927. }
  3928. }
  3929. };
  3930. /*=========================
  3931. Events/Callbacks/Plugins Emitter
  3932. ===========================*/
  3933. function normalizeEventName (eventName) {
  3934. if (eventName.indexOf('on') !== 0) {
  3935. if (eventName[0] !== eventName[0].toUpperCase()) {
  3936. eventName = 'on' + eventName[0].toUpperCase() + eventName.substring(1);
  3937. }
  3938. else {
  3939. eventName = 'on' + eventName;
  3940. }
  3941. }
  3942. return eventName;
  3943. }
  3944. s.emitterEventListeners = {
  3945. };
  3946. s.emit = function (eventName) {
  3947. // Trigger callbacks
  3948. if (s.params[eventName]) {
  3949. s.params[eventName](arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]);
  3950. }
  3951. var i;
  3952. // Trigger events
  3953. if (s.emitterEventListeners[eventName]) {
  3954. for (i = 0; i < s.emitterEventListeners[eventName].length; i++) {
  3955. s.emitterEventListeners[eventName][i](arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]);
  3956. }
  3957. }
  3958. // Trigger plugins
  3959. if (s.callPlugins) s.callPlugins(eventName, arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]);
  3960. };
  3961. s.on = function (eventName, handler) {
  3962. eventName = normalizeEventName(eventName);
  3963. if (!s.emitterEventListeners[eventName]) s.emitterEventListeners[eventName] = [];
  3964. s.emitterEventListeners[eventName].push(handler);
  3965. return s;
  3966. };
  3967. s.off = function (eventName, handler) {
  3968. var i;
  3969. eventName = normalizeEventName(eventName);
  3970. if (typeof handler === 'undefined') {
  3971. // Remove all handlers for such event
  3972. s.emitterEventListeners[eventName] = [];
  3973. return s;
  3974. }
  3975. if (!s.emitterEventListeners[eventName] || s.emitterEventListeners[eventName].length === 0) return;
  3976. for (i = 0; i < s.emitterEventListeners[eventName].length; i++) {
  3977. if(s.emitterEventListeners[eventName][i] === handler) s.emitterEventListeners[eventName].splice(i, 1);
  3978. }
  3979. return s;
  3980. };
  3981. s.once = function (eventName, handler) {
  3982. eventName = normalizeEventName(eventName);
  3983. var _handler = function () {
  3984. handler(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]);
  3985. s.off(eventName, _handler);
  3986. };
  3987. s.on(eventName, _handler);
  3988. return s;
  3989. };
  3990. // Accessibility tools
  3991. s.a11y = {
  3992. makeFocusable: function ($el) {
  3993. $el.attr('tabIndex', '0');
  3994. return $el;
  3995. },
  3996. addRole: function ($el, role) {
  3997. $el.attr('role', role);
  3998. return $el;
  3999. },
  4000. addLabel: function ($el, label) {
  4001. $el.attr('aria-label', label);
  4002. return $el;
  4003. },
  4004. disable: function ($el) {
  4005. $el.attr('aria-disabled', true);
  4006. return $el;
  4007. },
  4008. enable: function ($el) {
  4009. $el.attr('aria-disabled', false);
  4010. return $el;
  4011. },
  4012. onEnterKey: function (event) {
  4013. if (event.keyCode !== 13) return;
  4014. if ($(event.target).is(s.params.nextButton)) {
  4015. s.onClickNext(event);
  4016. if (s.isEnd) {
  4017. s.a11y.notify(s.params.lastSlideMessage);
  4018. }
  4019. else {
  4020. s.a11y.notify(s.params.nextSlideMessage);
  4021. }
  4022. }
  4023. else if ($(event.target).is(s.params.prevButton)) {
  4024. s.onClickPrev(event);
  4025. if (s.isBeginning) {
  4026. s.a11y.notify(s.params.firstSlideMessage);
  4027. }
  4028. else {
  4029. s.a11y.notify(s.params.prevSlideMessage);
  4030. }
  4031. }
  4032. if ($(event.target).is('.' + s.params.bulletClass)) {
  4033. $(event.target)[0].click();
  4034. }
  4035. },
  4036. liveRegion: $('<span class="' + s.params.notificationClass + '" aria-live="assertive" aria-atomic="true"></span>'),
  4037. notify: function (message) {
  4038. var notification = s.a11y.liveRegion;
  4039. if (notification.length === 0) return;
  4040. notification.html('');
  4041. notification.html(message);
  4042. },
  4043. init: function () {
  4044. // Setup accessibility
  4045. if (s.params.nextButton && s.nextButton && s.nextButton.length > 0) {
  4046. s.a11y.makeFocusable(s.nextButton);
  4047. s.a11y.addRole(s.nextButton, 'button');
  4048. s.a11y.addLabel(s.nextButton, s.params.nextSlideMessage);
  4049. }
  4050. if (s.params.prevButton && s.prevButton && s.prevButton.length > 0) {
  4051. s.a11y.makeFocusable(s.prevButton);
  4052. s.a11y.addRole(s.prevButton, 'button');
  4053. s.a11y.addLabel(s.prevButton, s.params.prevSlideMessage);
  4054. }
  4055. $(s.container).append(s.a11y.liveRegion);
  4056. },
  4057. initPagination: function () {
  4058. if (s.params.pagination && s.params.paginationClickable && s.bullets && s.bullets.length) {
  4059. s.bullets.each(function () {
  4060. var bullet = $(this);
  4061. s.a11y.makeFocusable(bullet);
  4062. s.a11y.addRole(bullet, 'button');
  4063. s.a11y.addLabel(bullet, s.params.paginationBulletMessage.replace(/{{index}}/, bullet.index() + 1));
  4064. });
  4065. }
  4066. },
  4067. destroy: function () {
  4068. if (s.a11y.liveRegion && s.a11y.liveRegion.length > 0) s.a11y.liveRegion.remove();
  4069. }
  4070. };
  4071. /*=========================
  4072. Init/Destroy
  4073. ===========================*/
  4074. s.init = function () {
  4075. if (s.params.loop) s.createLoop();
  4076. s.updateContainerSize();
  4077. s.updateSlidesSize();
  4078. s.updatePagination();
  4079. if (s.params.scrollbar && s.scrollbar) {
  4080. s.scrollbar.set();
  4081. if (s.params.scrollbarDraggable) {
  4082. s.scrollbar.enableDraggable();
  4083. }
  4084. }
  4085. if (s.params.effect !== 'slide' && s.effects[s.params.effect]) {
  4086. if (!s.params.loop) s.updateProgress();
  4087. s.effects[s.params.effect].setTranslate();
  4088. }
  4089. if (s.params.loop) {
  4090. s.slideTo(s.params.initialSlide + s.loopedSlides, 0, s.params.runCallbacksOnInit);
  4091. }
  4092. else {
  4093. s.slideTo(s.params.initialSlide, 0, s.params.runCallbacksOnInit);
  4094. if (s.params.initialSlide === 0) {
  4095. if (s.parallax && s.params.parallax) s.parallax.setTranslate();
  4096. if (s.lazy && s.params.lazyLoading) {
  4097. s.lazy.load();
  4098. s.lazy.initialImageLoaded = true;
  4099. }
  4100. }
  4101. }
  4102. s.attachEvents();
  4103. if (s.params.observer && s.support.observer) {
  4104. s.initObservers();
  4105. }
  4106. if (s.params.preloadImages && !s.params.lazyLoading) {
  4107. s.preloadImages();
  4108. }
  4109. if (s.params.zoom && s.zoom) {
  4110. s.zoom.init();
  4111. }
  4112. if (s.params.autoplay) {
  4113. s.startAutoplay();
  4114. }
  4115. if (s.params.keyboardControl) {
  4116. if (s.enableKeyboardControl) s.enableKeyboardControl();
  4117. }
  4118. if (s.params.mousewheelControl) {
  4119. if (s.enableMousewheelControl) s.enableMousewheelControl();
  4120. }
  4121. // Deprecated hashnavReplaceState changed to replaceState for use in hashnav and history
  4122. if (s.params.hashnavReplaceState) {
  4123. s.params.replaceState = s.params.hashnavReplaceState;
  4124. }
  4125. if (s.params.history) {
  4126. if (s.history) s.history.init();
  4127. }
  4128. if (s.params.hashnav) {
  4129. if (s.hashnav) s.hashnav.init();
  4130. }
  4131. if (s.params.a11y && s.a11y) s.a11y.init();
  4132. s.emit('onInit', s);
  4133. };
  4134. // Cleanup dynamic styles
  4135. s.cleanupStyles = function () {
  4136. // Container
  4137. s.container.removeClass(s.classNames.join(' ')).removeAttr('style');
  4138. // Wrapper
  4139. s.wrapper.removeAttr('style');
  4140. // Slides
  4141. if (s.slides && s.slides.length) {
  4142. s.slides
  4143. .removeClass([
  4144. s.params.slideVisibleClass,
  4145. s.params.slideActiveClass,
  4146. s.params.slideNextClass,
  4147. s.params.slidePrevClass
  4148. ].join(' '))
  4149. .removeAttr('style')
  4150. .removeAttr('data-swiper-column')
  4151. .removeAttr('data-swiper-row');
  4152. }
  4153. // Pagination/Bullets
  4154. if (s.paginationContainer && s.paginationContainer.length) {
  4155. s.paginationContainer.removeClass(s.params.paginationHiddenClass);
  4156. }
  4157. if (s.bullets && s.bullets.length) {
  4158. s.bullets.removeClass(s.params.bulletActiveClass);
  4159. }
  4160. // Buttons
  4161. if (s.params.prevButton) $(s.params.prevButton).removeClass(s.params.buttonDisabledClass);
  4162. if (s.params.nextButton) $(s.params.nextButton).removeClass(s.params.buttonDisabledClass);
  4163. // Scrollbar
  4164. if (s.params.scrollbar && s.scrollbar) {
  4165. if (s.scrollbar.track && s.scrollbar.track.length) s.scrollbar.track.removeAttr('style');
  4166. if (s.scrollbar.drag && s.scrollbar.drag.length) s.scrollbar.drag.removeAttr('style');
  4167. }
  4168. };
  4169. // Destroy
  4170. s.destroy = function (deleteInstance, cleanupStyles) {
  4171. // Detach evebts
  4172. s.detachEvents();
  4173. // Stop autoplay
  4174. s.stopAutoplay();
  4175. // Disable draggable
  4176. if (s.params.scrollbar && s.scrollbar) {
  4177. if (s.params.scrollbarDraggable) {
  4178. s.scrollbar.disableDraggable();
  4179. }
  4180. }
  4181. // Destroy loop
  4182. if (s.params.loop) {
  4183. s.destroyLoop();
  4184. }
  4185. // Cleanup styles
  4186. if (cleanupStyles) {
  4187. s.cleanupStyles();
  4188. }
  4189. // Disconnect observer
  4190. s.disconnectObservers();
  4191. // Destroy zoom
  4192. if (s.params.zoom && s.zoom) {
  4193. s.zoom.destroy();
  4194. }
  4195. // Disable keyboard/mousewheel
  4196. if (s.params.keyboardControl) {
  4197. if (s.disableKeyboardControl) s.disableKeyboardControl();
  4198. }
  4199. if (s.params.mousewheelControl) {
  4200. if (s.disableMousewheelControl) s.disableMousewheelControl();
  4201. }
  4202. // Disable a11y
  4203. if (s.params.a11y && s.a11y) s.a11y.destroy();
  4204. // Delete history popstate
  4205. if (s.params.history && !s.params.replaceState) {
  4206. window.removeEventListener('popstate', s.history.setHistoryPopState);
  4207. }
  4208. if (s.params.hashnav && s.hashnav) {
  4209. s.hashnav.destroy();
  4210. }
  4211. // Destroy callback
  4212. s.emit('onDestroy');
  4213. // Delete instance
  4214. if (deleteInstance !== false) s = null;
  4215. };
  4216. s.init();
  4217. // Return swiper instance
  4218. return s;
  4219. };
  4220. /*==================================================
  4221. Prototype
  4222. ====================================================*/
  4223. Swiper.prototype = {
  4224. isSafari: (function () {
  4225. var ua = window.navigator.userAgent.toLowerCase();
  4226. return (ua.indexOf('safari') >= 0 && ua.indexOf('chrome') < 0 && ua.indexOf('android') < 0);
  4227. })(),
  4228. isUiWebView: /(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(window.navigator.userAgent),
  4229. isArray: function (arr) {
  4230. return Object.prototype.toString.apply(arr) === '[object Array]';
  4231. },
  4232. /*==================================================
  4233. Browser
  4234. ====================================================*/
  4235. browser: {
  4236. ie: window.navigator.pointerEnabled || window.navigator.msPointerEnabled,
  4237. ieTouch: (window.navigator.msPointerEnabled && window.navigator.msMaxTouchPoints > 1) || (window.navigator.pointerEnabled && window.navigator.maxTouchPoints > 1),
  4238. lteIE9: (function() {
  4239. // create temporary DIV
  4240. var div = document.createElement('div');
  4241. // add content to tmp DIV which is wrapped into the IE HTML conditional statement
  4242. div.innerHTML = '<!--[if lte IE 9]><i></i><![endif]-->';
  4243. // return true / false value based on what will browser render
  4244. return div.getElementsByTagName('i').length === 1;
  4245. })()
  4246. },
  4247. /*==================================================
  4248. Devices
  4249. ====================================================*/
  4250. device: (function () {
  4251. var ua = window.navigator.userAgent;
  4252. var android = ua.match(/(Android);?[\s\/]+([\d.]+)?/);
  4253. var ipad = ua.match(/(iPad).*OS\s([\d_]+)/);
  4254. var ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/);
  4255. var iphone = !ipad && ua.match(/(iPhone\sOS|iOS)\s([\d_]+)/);
  4256. return {
  4257. ios: ipad || iphone || ipod,
  4258. android: android
  4259. };
  4260. })(),
  4261. /*==================================================
  4262. Feature Detection
  4263. ====================================================*/
  4264. support: {
  4265. touch : (window.Modernizr && Modernizr.touch === true) || (function () {
  4266. return !!(('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch);
  4267. })(),
  4268. transforms3d : (window.Modernizr && Modernizr.csstransforms3d === true) || (function () {
  4269. var div = document.createElement('div').style;
  4270. return ('webkitPerspective' in div || 'MozPerspective' in div || 'OPerspective' in div || 'MsPerspective' in div || 'perspective' in div);
  4271. })(),
  4272. flexbox: (function () {
  4273. var div = document.createElement('div').style;
  4274. var styles = ('alignItems webkitAlignItems webkitBoxAlign msFlexAlign mozBoxAlign webkitFlexDirection msFlexDirection mozBoxDirection mozBoxOrient webkitBoxDirection webkitBoxOrient').split(' ');
  4275. for (var i = 0; i < styles.length; i++) {
  4276. if (styles[i] in div) return true;
  4277. }
  4278. })(),
  4279. observer: (function () {
  4280. return ('MutationObserver' in window || 'WebkitMutationObserver' in window);
  4281. })(),
  4282. passiveListener: (function () {
  4283. var supportsPassive = false;
  4284. try {
  4285. var opts = Object.defineProperty({}, 'passive', {
  4286. get: function() {
  4287. supportsPassive = true;
  4288. }
  4289. });
  4290. window.addEventListener('testPassiveListener', null, opts);
  4291. } catch (e) {}
  4292. return supportsPassive;
  4293. })(),
  4294. gestures: (function () {
  4295. return 'ongesturestart' in window;
  4296. })()
  4297. },
  4298. /*==================================================
  4299. Plugins
  4300. ====================================================*/
  4301. plugins: {}
  4302. };
  4303. /*===========================
  4304. Dom7 Library
  4305. ===========================*/
  4306. var Dom7 = (function () {
  4307. var Dom7 = function (arr) {
  4308. var _this = this, i = 0;
  4309. // Create array-like object
  4310. for (i = 0; i < arr.length; i++) {
  4311. _this[i] = arr[i];
  4312. }
  4313. _this.length = arr.length;
  4314. // Return collection with methods
  4315. return this;
  4316. };
  4317. var $ = function (selector, context) {
  4318. var arr = [], i = 0;
  4319. if (selector && !context) {
  4320. if (selector instanceof Dom7) {
  4321. return selector;
  4322. }
  4323. }
  4324. if (selector) {
  4325. // String
  4326. if (typeof selector === 'string') {
  4327. var els, tempParent, html = selector.trim();
  4328. if (html.indexOf('<') >= 0 && html.indexOf('>') >= 0) {
  4329. var toCreate = 'div';
  4330. if (html.indexOf('<li') === 0) toCreate = 'ul';
  4331. if (html.indexOf('<tr') === 0) toCreate = 'tbody';
  4332. if (html.indexOf('<td') === 0 || html.indexOf('<th') === 0) toCreate = 'tr';
  4333. if (html.indexOf('<tbody') === 0) toCreate = 'table';
  4334. if (html.indexOf('<option') === 0) toCreate = 'select';
  4335. tempParent = document.createElement(toCreate);
  4336. tempParent.innerHTML = selector;
  4337. for (i = 0; i < tempParent.childNodes.length; i++) {
  4338. arr.push(tempParent.childNodes[i]);
  4339. }
  4340. }
  4341. else {
  4342. if (!context && selector[0] === '#' && !selector.match(/[ .<>:~]/)) {
  4343. // Pure ID selector
  4344. els = [document.getElementById(selector.split('#')[1])];
  4345. }
  4346. else {
  4347. // Other selectors
  4348. els = (context || document).querySelectorAll(selector);
  4349. }
  4350. for (i = 0; i < els.length; i++) {
  4351. if (els[i]) arr.push(els[i]);
  4352. }
  4353. }
  4354. }
  4355. // Node/element
  4356. else if (selector.nodeType || selector === window || selector === document) {
  4357. arr.push(selector);
  4358. }
  4359. //Array of elements or instance of Dom
  4360. else if (selector.length > 0 && selector[0].nodeType) {
  4361. for (i = 0; i < selector.length; i++) {
  4362. arr.push(selector[i]);
  4363. }
  4364. }
  4365. }
  4366. return new Dom7(arr);
  4367. };
  4368. Dom7.prototype = {
  4369. // Classes and attriutes
  4370. addClass: function (className) {
  4371. if (typeof className === 'undefined') {
  4372. return this;
  4373. }
  4374. var classes = className.split(' ');
  4375. for (var i = 0; i < classes.length; i++) {
  4376. for (var j = 0; j < this.length; j++) {
  4377. this[j].classList.add(classes[i]);
  4378. }
  4379. }
  4380. return this;
  4381. },
  4382. removeClass: function (className) {
  4383. var classes = className.split(' ');
  4384. for (var i = 0; i < classes.length; i++) {
  4385. for (var j = 0; j < this.length; j++) {
  4386. this[j].classList.remove(classes[i]);
  4387. }
  4388. }
  4389. return this;
  4390. },
  4391. hasClass: function (className) {
  4392. if (!this[0]) return false;
  4393. else return this[0].classList.contains(className);
  4394. },
  4395. toggleClass: function (className) {
  4396. var classes = className.split(' ');
  4397. for (var i = 0; i < classes.length; i++) {
  4398. for (var j = 0; j < this.length; j++) {
  4399. this[j].classList.toggle(classes[i]);
  4400. }
  4401. }
  4402. return this;
  4403. },
  4404. attr: function (attrs, value) {
  4405. if (arguments.length === 1 && typeof attrs === 'string') {
  4406. // Get attr
  4407. if (this[0]) return this[0].getAttribute(attrs);
  4408. else return undefined;
  4409. }
  4410. else {
  4411. // Set attrs
  4412. for (var i = 0; i < this.length; i++) {
  4413. if (arguments.length === 2) {
  4414. // String
  4415. this[i].setAttribute(attrs, value);
  4416. }
  4417. else {
  4418. // Object
  4419. for (var attrName in attrs) {
  4420. this[i][attrName] = attrs[attrName];
  4421. this[i].setAttribute(attrName, attrs[attrName]);
  4422. }
  4423. }
  4424. }
  4425. return this;
  4426. }
  4427. },
  4428. removeAttr: function (attr) {
  4429. for (var i = 0; i < this.length; i++) {
  4430. this[i].removeAttribute(attr);
  4431. }
  4432. return this;
  4433. },
  4434. data: function (key, value) {
  4435. if (typeof value === 'undefined') {
  4436. // Get value
  4437. if (this[0]) {
  4438. var dataKey = this[0].getAttribute('data-' + key);
  4439. if (dataKey) return dataKey;
  4440. else if (this[0].dom7ElementDataStorage && (key in this[0].dom7ElementDataStorage)) return this[0].dom7ElementDataStorage[key];
  4441. else return undefined;
  4442. }
  4443. else return undefined;
  4444. }
  4445. else {
  4446. // Set value
  4447. for (var i = 0; i < this.length; i++) {
  4448. var el = this[i];
  4449. if (!el.dom7ElementDataStorage) el.dom7ElementDataStorage = {};
  4450. el.dom7ElementDataStorage[key] = value;
  4451. }
  4452. return this;
  4453. }
  4454. },
  4455. // Transforms
  4456. transform : function (transform) {
  4457. for (var i = 0; i < this.length; i++) {
  4458. var elStyle = this[i].style;
  4459. elStyle.webkitTransform = elStyle.MsTransform = elStyle.msTransform = elStyle.MozTransform = elStyle.OTransform = elStyle.transform = transform;
  4460. }
  4461. return this;
  4462. },
  4463. transition: function (duration) {
  4464. if (typeof duration !== 'string') {
  4465. duration = duration + 'ms';
  4466. }
  4467. for (var i = 0; i < this.length; i++) {
  4468. var elStyle = this[i].style;
  4469. elStyle.webkitTransitionDuration = elStyle.MsTransitionDuration = elStyle.msTransitionDuration = elStyle.MozTransitionDuration = elStyle.OTransitionDuration = elStyle.transitionDuration = duration;
  4470. }
  4471. return this;
  4472. },
  4473. //Events
  4474. on: function (eventName, targetSelector, listener, capture) {
  4475. function handleLiveEvent(e) {
  4476. var target = e.target;
  4477. if ($(target).is(targetSelector)) listener.call(target, e);
  4478. else {
  4479. var parents = $(target).parents();
  4480. for (var k = 0; k < parents.length; k++) {
  4481. if ($(parents[k]).is(targetSelector)) listener.call(parents[k], e);
  4482. }
  4483. }
  4484. }
  4485. var events = eventName.split(' ');
  4486. var i, j;
  4487. for (i = 0; i < this.length; i++) {
  4488. if (typeof targetSelector === 'function' || targetSelector === false) {
  4489. // Usual events
  4490. if (typeof targetSelector === 'function') {
  4491. listener = arguments[1];
  4492. capture = arguments[2] || false;
  4493. }
  4494. for (j = 0; j < events.length; j++) {
  4495. this[i].addEventListener(events[j], listener, capture);
  4496. }
  4497. }
  4498. else {
  4499. //Live events
  4500. for (j = 0; j < events.length; j++) {
  4501. if (!this[i].dom7LiveListeners) this[i].dom7LiveListeners = [];
  4502. this[i].dom7LiveListeners.push({listener: listener, liveListener: handleLiveEvent});
  4503. this[i].addEventListener(events[j], handleLiveEvent, capture);
  4504. }
  4505. }
  4506. }
  4507. return this;
  4508. },
  4509. off: function (eventName, targetSelector, listener, capture) {
  4510. var events = eventName.split(' ');
  4511. for (var i = 0; i < events.length; i++) {
  4512. for (var j = 0; j < this.length; j++) {
  4513. if (typeof targetSelector === 'function' || targetSelector === false) {
  4514. // Usual events
  4515. if (typeof targetSelector === 'function') {
  4516. listener = arguments[1];
  4517. capture = arguments[2] || false;
  4518. }
  4519. this[j].removeEventListener(events[i], listener, capture);
  4520. }
  4521. else {
  4522. // Live event
  4523. if (this[j].dom7LiveListeners) {
  4524. for (var k = 0; k < this[j].dom7LiveListeners.length; k++) {
  4525. if (this[j].dom7LiveListeners[k].listener === listener) {
  4526. this[j].removeEventListener(events[i], this[j].dom7LiveListeners[k].liveListener, capture);
  4527. }
  4528. }
  4529. }
  4530. }
  4531. }
  4532. }
  4533. return this;
  4534. },
  4535. once: function (eventName, targetSelector, listener, capture) {
  4536. var dom = this;
  4537. if (typeof targetSelector === 'function') {
  4538. targetSelector = false;
  4539. listener = arguments[1];
  4540. capture = arguments[2];
  4541. }
  4542. function proxy(e) {
  4543. listener(e);
  4544. dom.off(eventName, targetSelector, proxy, capture);
  4545. }
  4546. dom.on(eventName, targetSelector, proxy, capture);
  4547. },
  4548. trigger: function (eventName, eventData) {
  4549. for (var i = 0; i < this.length; i++) {
  4550. var evt;
  4551. try {
  4552. evt = new window.CustomEvent(eventName, {detail: eventData, bubbles: true, cancelable: true});
  4553. }
  4554. catch (e) {
  4555. evt = document.createEvent('Event');
  4556. evt.initEvent(eventName, true, true);
  4557. evt.detail = eventData;
  4558. }
  4559. this[i].dispatchEvent(evt);
  4560. }
  4561. return this;
  4562. },
  4563. transitionEnd: function (callback) {
  4564. var events = ['webkitTransitionEnd', 'transitionend', 'oTransitionEnd', 'MSTransitionEnd', 'msTransitionEnd'],
  4565. i, j, dom = this;
  4566. function fireCallBack(e) {
  4567. /*jshint validthis:true */
  4568. if (e.target !== this) return;
  4569. callback.call(this, e);
  4570. for (i = 0; i < events.length; i++) {
  4571. dom.off(events[i], fireCallBack);
  4572. }
  4573. }
  4574. if (callback) {
  4575. for (i = 0; i < events.length; i++) {
  4576. dom.on(events[i], fireCallBack);
  4577. }
  4578. }
  4579. return this;
  4580. },
  4581. // Sizing/Styles
  4582. width: function () {
  4583. if (this[0] === window) {
  4584. return window.innerWidth;
  4585. }
  4586. else {
  4587. if (this.length > 0) {
  4588. return parseFloat(this.css('width'));
  4589. }
  4590. else {
  4591. return null;
  4592. }
  4593. }
  4594. },
  4595. outerWidth: function (includeMargins) {
  4596. if (this.length > 0) {
  4597. if (includeMargins)
  4598. return this[0].offsetWidth + parseFloat(this.css('margin-right')) + parseFloat(this.css('margin-left'));
  4599. else
  4600. return this[0].offsetWidth;
  4601. }
  4602. else return null;
  4603. },
  4604. height: function () {
  4605. if (this[0] === window) {
  4606. return window.innerHeight;
  4607. }
  4608. else {
  4609. if (this.length > 0) {
  4610. return parseFloat(this.css('height'));
  4611. }
  4612. else {
  4613. return null;
  4614. }
  4615. }
  4616. },
  4617. outerHeight: function (includeMargins) {
  4618. if (this.length > 0) {
  4619. if (includeMargins)
  4620. return this[0].offsetHeight + parseFloat(this.css('margin-top')) + parseFloat(this.css('margin-bottom'));
  4621. else
  4622. return this[0].offsetHeight;
  4623. }
  4624. else return null;
  4625. },
  4626. offset: function () {
  4627. if (this.length > 0) {
  4628. var el = this[0];
  4629. var box = el.getBoundingClientRect();
  4630. var body = document.body;
  4631. var clientTop = el.clientTop || body.clientTop || 0;
  4632. var clientLeft = el.clientLeft || body.clientLeft || 0;
  4633. var scrollTop = window.pageYOffset || el.scrollTop;
  4634. var scrollLeft = window.pageXOffset || el.scrollLeft;
  4635. return {
  4636. top: box.top + scrollTop - clientTop,
  4637. left: box.left + scrollLeft - clientLeft
  4638. };
  4639. }
  4640. else {
  4641. return null;
  4642. }
  4643. },
  4644. css: function (props, value) {
  4645. var i;
  4646. if (arguments.length === 1) {
  4647. if (typeof props === 'string') {
  4648. if (this[0]) return window.getComputedStyle(this[0], null).getPropertyValue(props);
  4649. }
  4650. else {
  4651. for (i = 0; i < this.length; i++) {
  4652. for (var prop in props) {
  4653. this[i].style[prop] = props[prop];
  4654. }
  4655. }
  4656. return this;
  4657. }
  4658. }
  4659. if (arguments.length === 2 && typeof props === 'string') {
  4660. for (i = 0; i < this.length; i++) {
  4661. this[i].style[props] = value;
  4662. }
  4663. return this;
  4664. }
  4665. return this;
  4666. },
  4667. //Dom manipulation
  4668. each: function (callback) {
  4669. for (var i = 0; i < this.length; i++) {
  4670. callback.call(this[i], i, this[i]);
  4671. }
  4672. return this;
  4673. },
  4674. html: function (html) {
  4675. if (typeof html === 'undefined') {
  4676. return this[0] ? this[0].innerHTML : undefined;
  4677. }
  4678. else {
  4679. for (var i = 0; i < this.length; i++) {
  4680. this[i].innerHTML = html;
  4681. }
  4682. return this;
  4683. }
  4684. },
  4685. text: function (text) {
  4686. if (typeof text === 'undefined') {
  4687. if (this[0]) {
  4688. return this[0].textContent.trim();
  4689. }
  4690. else return null;
  4691. }
  4692. else {
  4693. for (var i = 0; i < this.length; i++) {
  4694. this[i].textContent = text;
  4695. }
  4696. return this;
  4697. }
  4698. },
  4699. is: function (selector) {
  4700. if (!this[0]) return false;
  4701. var compareWith, i;
  4702. if (typeof selector === 'string') {
  4703. var el = this[0];
  4704. if (el === document) return selector === document;
  4705. if (el === window) return selector === window;
  4706. if (el.matches) return el.matches(selector);
  4707. else if (el.webkitMatchesSelector) return el.webkitMatchesSelector(selector);
  4708. else if (el.mozMatchesSelector) return el.mozMatchesSelector(selector);
  4709. else if (el.msMatchesSelector) return el.msMatchesSelector(selector);
  4710. else {
  4711. compareWith = $(selector);
  4712. for (i = 0; i < compareWith.length; i++) {
  4713. if (compareWith[i] === this[0]) return true;
  4714. }
  4715. return false;
  4716. }
  4717. }
  4718. else if (selector === document) return this[0] === document;
  4719. else if (selector === window) return this[0] === window;
  4720. else {
  4721. if (selector.nodeType || selector instanceof Dom7) {
  4722. compareWith = selector.nodeType ? [selector] : selector;
  4723. for (i = 0; i < compareWith.length; i++) {
  4724. if (compareWith[i] === this[0]) return true;
  4725. }
  4726. return false;
  4727. }
  4728. return false;
  4729. }
  4730. },
  4731. index: function () {
  4732. if (this[0]) {
  4733. var child = this[0];
  4734. var i = 0;
  4735. while ((child = child.previousSibling) !== null) {
  4736. if (child.nodeType === 1) i++;
  4737. }
  4738. return i;
  4739. }
  4740. else return undefined;
  4741. },
  4742. eq: function (index) {
  4743. if (typeof index === 'undefined') return this;
  4744. var length = this.length;
  4745. var returnIndex;
  4746. if (index > length - 1) {
  4747. return new Dom7([]);
  4748. }
  4749. if (index < 0) {
  4750. returnIndex = length + index;
  4751. if (returnIndex < 0) return new Dom7([]);
  4752. else return new Dom7([this[returnIndex]]);
  4753. }
  4754. return new Dom7([this[index]]);
  4755. },
  4756. append: function (newChild) {
  4757. var i, j;
  4758. for (i = 0; i < this.length; i++) {
  4759. if (typeof newChild === 'string') {
  4760. var tempDiv = document.createElement('div');
  4761. tempDiv.innerHTML = newChild;
  4762. while (tempDiv.firstChild) {
  4763. this[i].appendChild(tempDiv.firstChild);
  4764. }
  4765. }
  4766. else if (newChild instanceof Dom7) {
  4767. for (j = 0; j < newChild.length; j++) {
  4768. this[i].appendChild(newChild[j]);
  4769. }
  4770. }
  4771. else {
  4772. this[i].appendChild(newChild);
  4773. }
  4774. }
  4775. return this;
  4776. },
  4777. prepend: function (newChild) {
  4778. var i, j;
  4779. for (i = 0; i < this.length; i++) {
  4780. if (typeof newChild === 'string') {
  4781. var tempDiv = document.createElement('div');
  4782. tempDiv.innerHTML = newChild;
  4783. for (j = tempDiv.childNodes.length - 1; j >= 0; j--) {
  4784. this[i].insertBefore(tempDiv.childNodes[j], this[i].childNodes[0]);
  4785. }
  4786. // this[i].insertAdjacentHTML('afterbegin', newChild);
  4787. }
  4788. else if (newChild instanceof Dom7) {
  4789. for (j = 0; j < newChild.length; j++) {
  4790. this[i].insertBefore(newChild[j], this[i].childNodes[0]);
  4791. }
  4792. }
  4793. else {
  4794. this[i].insertBefore(newChild, this[i].childNodes[0]);
  4795. }
  4796. }
  4797. return this;
  4798. },
  4799. insertBefore: function (selector) {
  4800. var before = $(selector);
  4801. for (var i = 0; i < this.length; i++) {
  4802. if (before.length === 1) {
  4803. before[0].parentNode.insertBefore(this[i], before[0]);
  4804. }
  4805. else if (before.length > 1) {
  4806. for (var j = 0; j < before.length; j++) {
  4807. before[j].parentNode.insertBefore(this[i].cloneNode(true), before[j]);
  4808. }
  4809. }
  4810. }
  4811. },
  4812. insertAfter: function (selector) {
  4813. var after = $(selector);
  4814. for (var i = 0; i < this.length; i++) {
  4815. if (after.length === 1) {
  4816. after[0].parentNode.insertBefore(this[i], after[0].nextSibling);
  4817. }
  4818. else if (after.length > 1) {
  4819. for (var j = 0; j < after.length; j++) {
  4820. after[j].parentNode.insertBefore(this[i].cloneNode(true), after[j].nextSibling);
  4821. }
  4822. }
  4823. }
  4824. },
  4825. next: function (selector) {
  4826. if (this.length > 0) {
  4827. if (selector) {
  4828. if (this[0].nextElementSibling && $(this[0].nextElementSibling).is(selector)) return new Dom7([this[0].nextElementSibling]);
  4829. else return new Dom7([]);
  4830. }
  4831. else {
  4832. if (this[0].nextElementSibling) return new Dom7([this[0].nextElementSibling]);
  4833. else return new Dom7([]);
  4834. }
  4835. }
  4836. else return new Dom7([]);
  4837. },
  4838. nextAll: function (selector) {
  4839. var nextEls = [];
  4840. var el = this[0];
  4841. if (!el) return new Dom7([]);
  4842. while (el.nextElementSibling) {
  4843. var next = el.nextElementSibling;
  4844. if (selector) {
  4845. if($(next).is(selector)) nextEls.push(next);
  4846. }
  4847. else nextEls.push(next);
  4848. el = next;
  4849. }
  4850. return new Dom7(nextEls);
  4851. },
  4852. prev: function (selector) {
  4853. if (this.length > 0) {
  4854. if (selector) {
  4855. if (this[0].previousElementSibling && $(this[0].previousElementSibling).is(selector)) return new Dom7([this[0].previousElementSibling]);
  4856. else return new Dom7([]);
  4857. }
  4858. else {
  4859. if (this[0].previousElementSibling) return new Dom7([this[0].previousElementSibling]);
  4860. else return new Dom7([]);
  4861. }
  4862. }
  4863. else return new Dom7([]);
  4864. },
  4865. prevAll: function (selector) {
  4866. var prevEls = [];
  4867. var el = this[0];
  4868. if (!el) return new Dom7([]);
  4869. while (el.previousElementSibling) {
  4870. var prev = el.previousElementSibling;
  4871. if (selector) {
  4872. if($(prev).is(selector)) prevEls.push(prev);
  4873. }
  4874. else prevEls.push(prev);
  4875. el = prev;
  4876. }
  4877. return new Dom7(prevEls);
  4878. },
  4879. parent: function (selector) {
  4880. var parents = [];
  4881. for (var i = 0; i < this.length; i++) {
  4882. if (selector) {
  4883. if ($(this[i].parentNode).is(selector)) parents.push(this[i].parentNode);
  4884. }
  4885. else {
  4886. parents.push(this[i].parentNode);
  4887. }
  4888. }
  4889. return $($.unique(parents));
  4890. },
  4891. parents: function (selector) {
  4892. var parents = [];
  4893. for (var i = 0; i < this.length; i++) {
  4894. var parent = this[i].parentNode;
  4895. while (parent) {
  4896. if (selector) {
  4897. if ($(parent).is(selector)) parents.push(parent);
  4898. }
  4899. else {
  4900. parents.push(parent);
  4901. }
  4902. parent = parent.parentNode;
  4903. }
  4904. }
  4905. return $($.unique(parents));
  4906. },
  4907. find : function (selector) {
  4908. var foundElements = [];
  4909. for (var i = 0; i < this.length; i++) {
  4910. var found = this[i].querySelectorAll(selector);
  4911. for (var j = 0; j < found.length; j++) {
  4912. foundElements.push(found[j]);
  4913. }
  4914. }
  4915. return new Dom7(foundElements);
  4916. },
  4917. children: function (selector) {
  4918. var children = [];
  4919. for (var i = 0; i < this.length; i++) {
  4920. var childNodes = this[i].childNodes;
  4921. for (var j = 0; j < childNodes.length; j++) {
  4922. if (!selector) {
  4923. if (childNodes[j].nodeType === 1) children.push(childNodes[j]);
  4924. }
  4925. else {
  4926. if (childNodes[j].nodeType === 1 && $(childNodes[j]).is(selector)) children.push(childNodes[j]);
  4927. }
  4928. }
  4929. }
  4930. return new Dom7($.unique(children));
  4931. },
  4932. remove: function () {
  4933. for (var i = 0; i < this.length; i++) {
  4934. if (this[i].parentNode) this[i].parentNode.removeChild(this[i]);
  4935. }
  4936. return this;
  4937. },
  4938. add: function () {
  4939. var dom = this;
  4940. var i, j;
  4941. for (i = 0; i < arguments.length; i++) {
  4942. var toAdd = $(arguments[i]);
  4943. for (j = 0; j < toAdd.length; j++) {
  4944. dom[dom.length] = toAdd[j];
  4945. dom.length++;
  4946. }
  4947. }
  4948. return dom;
  4949. }
  4950. };
  4951. $.fn = Dom7.prototype;
  4952. $.unique = function (arr) {
  4953. var unique = [];
  4954. for (var i = 0; i < arr.length; i++) {
  4955. if (unique.indexOf(arr[i]) === -1) unique.push(arr[i]);
  4956. }
  4957. return unique;
  4958. };
  4959. return $;
  4960. })();
  4961. /*===========================
  4962. Get Dom libraries
  4963. ===========================*/
  4964. var swiperDomPlugins = ['jQuery', 'Zepto', 'Dom7'];
  4965. for (var i = 0; i < swiperDomPlugins.length; i++) {
  4966. if (window[swiperDomPlugins[i]]) {
  4967. addLibraryPlugin(window[swiperDomPlugins[i]]);
  4968. }
  4969. }
  4970. // Required DOM Plugins
  4971. var domLib;
  4972. if (typeof Dom7 === 'undefined') {
  4973. domLib = window.Dom7 || window.Zepto || window.jQuery;
  4974. }
  4975. else {
  4976. domLib = Dom7;
  4977. }
  4978. /*===========================
  4979. Add .swiper plugin from Dom libraries
  4980. ===========================*/
  4981. function addLibraryPlugin(lib) {
  4982. lib.fn.swiper = function (params) {
  4983. var firstInstance;
  4984. lib(this).each(function () {
  4985. var s = new Swiper(this, params);
  4986. if (!firstInstance) firstInstance = s;
  4987. });
  4988. return firstInstance;
  4989. };
  4990. }
  4991. if (domLib) {
  4992. if (!('transitionEnd' in domLib.fn)) {
  4993. domLib.fn.transitionEnd = function (callback) {
  4994. var events = ['webkitTransitionEnd', 'transitionend', 'oTransitionEnd', 'MSTransitionEnd', 'msTransitionEnd'],
  4995. i, j, dom = this;
  4996. function fireCallBack(e) {
  4997. /*jshint validthis:true */
  4998. if (e.target !== this) return;
  4999. callback.call(this, e);
  5000. for (i = 0; i < events.length; i++) {
  5001. dom.off(events[i], fireCallBack);
  5002. }
  5003. }
  5004. if (callback) {
  5005. for (i = 0; i < events.length; i++) {
  5006. dom.on(events[i], fireCallBack);
  5007. }
  5008. }
  5009. return this;
  5010. };
  5011. }
  5012. if (!('transform' in domLib.fn)) {
  5013. domLib.fn.transform = function (transform) {
  5014. for (var i = 0; i < this.length; i++) {
  5015. var elStyle = this[i].style;
  5016. elStyle.webkitTransform = elStyle.MsTransform = elStyle.msTransform = elStyle.MozTransform = elStyle.OTransform = elStyle.transform = transform;
  5017. }
  5018. return this;
  5019. };
  5020. }
  5021. if (!('transition' in domLib.fn)) {
  5022. domLib.fn.transition = function (duration) {
  5023. if (typeof duration !== 'string') {
  5024. duration = duration + 'ms';
  5025. }
  5026. for (var i = 0; i < this.length; i++) {
  5027. var elStyle = this[i].style;
  5028. elStyle.webkitTransitionDuration = elStyle.MsTransitionDuration = elStyle.msTransitionDuration = elStyle.MozTransitionDuration = elStyle.OTransitionDuration = elStyle.transitionDuration = duration;
  5029. }
  5030. return this;
  5031. };
  5032. }
  5033. if (!('outerWidth' in domLib.fn)) {
  5034. domLib.fn.outerWidth = function (includeMargins) {
  5035. if (this.length > 0) {
  5036. if (includeMargins)
  5037. return this[0].offsetWidth + parseFloat(this.css('margin-right')) + parseFloat(this.css('margin-left'));
  5038. else
  5039. return this[0].offsetWidth;
  5040. }
  5041. else return null;
  5042. };
  5043. }
  5044. }
  5045. window.Swiper = Swiper;
  5046. })();
  5047. /*===========================
  5048. Swiper AMD Export
  5049. ===========================*/
  5050. if (typeof(module) !== 'undefined')
  5051. {
  5052. module.exports = window.Swiper;
  5053. }
  5054. else if (typeof define === 'function' && define.amd) {
  5055. define([], function () {
  5056. 'use strict';
  5057. return window.Swiper;
  5058. });
  5059. }
  5060. //# sourceMappingURL=maps/swiper.js.map