swiper.js 257 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719
  1. /**
  2. * Swiper 4.3.3
  3. * Most modern mobile touch slider and framework with hardware accelerated transitions
  4. * http://www.idangero.us/swiper/
  5. *
  6. * Copyright 2014-2018 Vladimir Kharlampidi
  7. *
  8. * Released under the MIT License
  9. *
  10. * Released on: June 5, 2018
  11. */
  12. (function (global, factory) {
  13. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  14. typeof define === 'function' && define.amd ? define(factory) :
  15. (global.Swiper = factory());
  16. }(this, (function () { 'use strict';
  17. /**
  18. * SSR Window 1.0.0
  19. * Better handling for window object in SSR environment
  20. * https://github.com/nolimits4web/ssr-window
  21. *
  22. * Copyright 2018, Vladimir Kharlampidi
  23. *
  24. * Licensed under MIT
  25. *
  26. * Released on: February 10, 2018
  27. */
  28. var d;
  29. if (typeof document === 'undefined') {
  30. d = {
  31. body: {},
  32. addEventListener: function addEventListener() {},
  33. removeEventListener: function removeEventListener() {},
  34. activeElement: {
  35. blur: function blur() {},
  36. nodeName: '',
  37. },
  38. querySelector: function querySelector() {
  39. return null;
  40. },
  41. querySelectorAll: function querySelectorAll() {
  42. return [];
  43. },
  44. getElementById: function getElementById() {
  45. return null;
  46. },
  47. createEvent: function createEvent() {
  48. return {
  49. initEvent: function initEvent() {},
  50. };
  51. },
  52. createElement: function createElement() {
  53. return {
  54. children: [],
  55. childNodes: [],
  56. style: {},
  57. setAttribute: function setAttribute() {},
  58. getElementsByTagName: function getElementsByTagName() {
  59. return [];
  60. },
  61. };
  62. },
  63. location: { hash: '' },
  64. };
  65. } else {
  66. // eslint-disable-next-line
  67. d = document;
  68. }
  69. var doc = d;
  70. var w;
  71. if (typeof window === 'undefined') {
  72. w = {
  73. document: doc,
  74. navigator: {
  75. userAgent: '',
  76. },
  77. location: {},
  78. history: {},
  79. CustomEvent: function CustomEvent() {
  80. return this;
  81. },
  82. addEventListener: function addEventListener() {},
  83. removeEventListener: function removeEventListener() {},
  84. getComputedStyle: function getComputedStyle() {
  85. return {
  86. getPropertyValue: function getPropertyValue() {
  87. return '';
  88. },
  89. };
  90. },
  91. Image: function Image() {},
  92. Date: function Date() {},
  93. screen: {},
  94. setTimeout: function setTimeout() {},
  95. clearTimeout: function clearTimeout() {},
  96. };
  97. } else {
  98. // eslint-disable-next-line
  99. w = window;
  100. }
  101. var win = w;
  102. /**
  103. * Dom7 2.0.6
  104. * Minimalistic JavaScript library for DOM manipulation, with a jQuery-compatible API
  105. * http://framework7.io/docs/dom.html
  106. *
  107. * Copyright 2018, Vladimir Kharlampidi
  108. * The iDangero.us
  109. * http://www.idangero.us/
  110. *
  111. * Licensed under MIT
  112. *
  113. * Released on: May 27, 2018
  114. */
  115. var Dom7 = function Dom7(arr) {
  116. var self = this;
  117. // Create array-like object
  118. for (var i = 0; i < arr.length; i += 1) {
  119. self[i] = arr[i];
  120. }
  121. self.length = arr.length;
  122. // Return collection with methods
  123. return this;
  124. };
  125. function $(selector, context) {
  126. var arr = [];
  127. var i = 0;
  128. if (selector && !context) {
  129. if (selector instanceof Dom7) {
  130. return selector;
  131. }
  132. }
  133. if (selector) {
  134. // String
  135. if (typeof selector === 'string') {
  136. var els;
  137. var tempParent;
  138. var html = selector.trim();
  139. if (html.indexOf('<') >= 0 && html.indexOf('>') >= 0) {
  140. var toCreate = 'div';
  141. if (html.indexOf('<li') === 0) { toCreate = 'ul'; }
  142. if (html.indexOf('<tr') === 0) { toCreate = 'tbody'; }
  143. if (html.indexOf('<td') === 0 || html.indexOf('<th') === 0) { toCreate = 'tr'; }
  144. if (html.indexOf('<tbody') === 0) { toCreate = 'table'; }
  145. if (html.indexOf('<option') === 0) { toCreate = 'select'; }
  146. tempParent = doc.createElement(toCreate);
  147. tempParent.innerHTML = html;
  148. for (i = 0; i < tempParent.childNodes.length; i += 1) {
  149. arr.push(tempParent.childNodes[i]);
  150. }
  151. } else {
  152. if (!context && selector[0] === '#' && !selector.match(/[ .<>:~]/)) {
  153. // Pure ID selector
  154. els = [doc.getElementById(selector.trim().split('#')[1])];
  155. } else {
  156. // Other selectors
  157. els = (context || doc).querySelectorAll(selector.trim());
  158. }
  159. for (i = 0; i < els.length; i += 1) {
  160. if (els[i]) { arr.push(els[i]); }
  161. }
  162. }
  163. } else if (selector.nodeType || selector === win || selector === doc) {
  164. // Node/element
  165. arr.push(selector);
  166. } else if (selector.length > 0 && selector[0].nodeType) {
  167. // Array of elements or instance of Dom
  168. for (i = 0; i < selector.length; i += 1) {
  169. arr.push(selector[i]);
  170. }
  171. }
  172. }
  173. return new Dom7(arr);
  174. }
  175. $.fn = Dom7.prototype;
  176. $.Class = Dom7;
  177. $.Dom7 = Dom7;
  178. function unique(arr) {
  179. var uniqueArray = [];
  180. for (var i = 0; i < arr.length; i += 1) {
  181. if (uniqueArray.indexOf(arr[i]) === -1) { uniqueArray.push(arr[i]); }
  182. }
  183. return uniqueArray;
  184. }
  185. // Classes and attributes
  186. function addClass(className) {
  187. var this$1 = this;
  188. if (typeof className === 'undefined') {
  189. return this;
  190. }
  191. var classes = className.split(' ');
  192. for (var i = 0; i < classes.length; i += 1) {
  193. for (var j = 0; j < this.length; j += 1) {
  194. if (typeof this$1[j].classList !== 'undefined') { this$1[j].classList.add(classes[i]); }
  195. }
  196. }
  197. return this;
  198. }
  199. function removeClass(className) {
  200. var this$1 = this;
  201. var classes = className.split(' ');
  202. for (var i = 0; i < classes.length; i += 1) {
  203. for (var j = 0; j < this.length; j += 1) {
  204. if (typeof this$1[j].classList !== 'undefined') { this$1[j].classList.remove(classes[i]); }
  205. }
  206. }
  207. return this;
  208. }
  209. function hasClass(className) {
  210. if (!this[0]) { return false; }
  211. return this[0].classList.contains(className);
  212. }
  213. function toggleClass(className) {
  214. var this$1 = this;
  215. var classes = className.split(' ');
  216. for (var i = 0; i < classes.length; i += 1) {
  217. for (var j = 0; j < this.length; j += 1) {
  218. if (typeof this$1[j].classList !== 'undefined') { this$1[j].classList.toggle(classes[i]); }
  219. }
  220. }
  221. return this;
  222. }
  223. function attr(attrs, value) {
  224. var arguments$1 = arguments;
  225. var this$1 = this;
  226. if (arguments.length === 1 && typeof attrs === 'string') {
  227. // Get attr
  228. if (this[0]) { return this[0].getAttribute(attrs); }
  229. return undefined;
  230. }
  231. // Set attrs
  232. for (var i = 0; i < this.length; i += 1) {
  233. if (arguments$1.length === 2) {
  234. // String
  235. this$1[i].setAttribute(attrs, value);
  236. } else {
  237. // Object
  238. // eslint-disable-next-line
  239. for (var attrName in attrs) {
  240. this$1[i][attrName] = attrs[attrName];
  241. this$1[i].setAttribute(attrName, attrs[attrName]);
  242. }
  243. }
  244. }
  245. return this;
  246. }
  247. // eslint-disable-next-line
  248. function removeAttr(attr) {
  249. var this$1 = this;
  250. for (var i = 0; i < this.length; i += 1) {
  251. this$1[i].removeAttribute(attr);
  252. }
  253. return this;
  254. }
  255. function data(key, value) {
  256. var this$1 = this;
  257. var el;
  258. if (typeof value === 'undefined') {
  259. el = this[0];
  260. // Get value
  261. if (el) {
  262. if (el.dom7ElementDataStorage && (key in el.dom7ElementDataStorage)) {
  263. return el.dom7ElementDataStorage[key];
  264. }
  265. var dataKey = el.getAttribute(("data-" + key));
  266. if (dataKey) {
  267. return dataKey;
  268. }
  269. return undefined;
  270. }
  271. return undefined;
  272. }
  273. // Set value
  274. for (var i = 0; i < this.length; i += 1) {
  275. el = this$1[i];
  276. if (!el.dom7ElementDataStorage) { el.dom7ElementDataStorage = {}; }
  277. el.dom7ElementDataStorage[key] = value;
  278. }
  279. return this;
  280. }
  281. // Transforms
  282. // eslint-disable-next-line
  283. function transform(transform) {
  284. var this$1 = this;
  285. for (var i = 0; i < this.length; i += 1) {
  286. var elStyle = this$1[i].style;
  287. elStyle.webkitTransform = transform;
  288. elStyle.transform = transform;
  289. }
  290. return this;
  291. }
  292. function transition(duration) {
  293. var this$1 = this;
  294. if (typeof duration !== 'string') {
  295. duration = duration + "ms"; // eslint-disable-line
  296. }
  297. for (var i = 0; i < this.length; i += 1) {
  298. var elStyle = this$1[i].style;
  299. elStyle.webkitTransitionDuration = duration;
  300. elStyle.transitionDuration = duration;
  301. }
  302. return this;
  303. }
  304. // Events
  305. function on() {
  306. var this$1 = this;
  307. var assign;
  308. var args = [], len = arguments.length;
  309. while ( len-- ) args[ len ] = arguments[ len ];
  310. var eventType = args[0];
  311. var targetSelector = args[1];
  312. var listener = args[2];
  313. var capture = args[3];
  314. if (typeof args[1] === 'function') {
  315. (assign = args, eventType = assign[0], listener = assign[1], capture = assign[2]);
  316. targetSelector = undefined;
  317. }
  318. if (!capture) { capture = false; }
  319. function handleLiveEvent(e) {
  320. var target = e.target;
  321. if (!target) { return; }
  322. var eventData = e.target.dom7EventData || [];
  323. if (eventData.indexOf(e) < 0) {
  324. eventData.unshift(e);
  325. }
  326. if ($(target).is(targetSelector)) { listener.apply(target, eventData); }
  327. else {
  328. var parents = $(target).parents(); // eslint-disable-line
  329. for (var k = 0; k < parents.length; k += 1) {
  330. if ($(parents[k]).is(targetSelector)) { listener.apply(parents[k], eventData); }
  331. }
  332. }
  333. }
  334. function handleEvent(e) {
  335. var eventData = e && e.target ? e.target.dom7EventData || [] : [];
  336. if (eventData.indexOf(e) < 0) {
  337. eventData.unshift(e);
  338. }
  339. listener.apply(this, eventData);
  340. }
  341. var events = eventType.split(' ');
  342. var j;
  343. for (var i = 0; i < this.length; i += 1) {
  344. var el = this$1[i];
  345. if (!targetSelector) {
  346. for (j = 0; j < events.length; j += 1) {
  347. var event = events[j];
  348. if (!el.dom7Listeners) { el.dom7Listeners = {}; }
  349. if (!el.dom7Listeners[event]) { el.dom7Listeners[event] = []; }
  350. el.dom7Listeners[event].push({
  351. listener: listener,
  352. proxyListener: handleEvent,
  353. });
  354. el.addEventListener(event, handleEvent, capture);
  355. }
  356. } else {
  357. // Live events
  358. for (j = 0; j < events.length; j += 1) {
  359. var event$1 = events[j];
  360. if (!el.dom7LiveListeners) { el.dom7LiveListeners = {}; }
  361. if (!el.dom7LiveListeners[event$1]) { el.dom7LiveListeners[event$1] = []; }
  362. el.dom7LiveListeners[event$1].push({
  363. listener: listener,
  364. proxyListener: handleLiveEvent,
  365. });
  366. el.addEventListener(event$1, handleLiveEvent, capture);
  367. }
  368. }
  369. }
  370. return this;
  371. }
  372. function off() {
  373. var this$1 = this;
  374. var assign;
  375. var args = [], len = arguments.length;
  376. while ( len-- ) args[ len ] = arguments[ len ];
  377. var eventType = args[0];
  378. var targetSelector = args[1];
  379. var listener = args[2];
  380. var capture = args[3];
  381. if (typeof args[1] === 'function') {
  382. (assign = args, eventType = assign[0], listener = assign[1], capture = assign[2]);
  383. targetSelector = undefined;
  384. }
  385. if (!capture) { capture = false; }
  386. var events = eventType.split(' ');
  387. for (var i = 0; i < events.length; i += 1) {
  388. var event = events[i];
  389. for (var j = 0; j < this.length; j += 1) {
  390. var el = this$1[j];
  391. var handlers = (void 0);
  392. if (!targetSelector && el.dom7Listeners) {
  393. handlers = el.dom7Listeners[event];
  394. } else if (targetSelector && el.dom7LiveListeners) {
  395. handlers = el.dom7LiveListeners[event];
  396. }
  397. if (handlers && handlers.length) {
  398. for (var k = handlers.length - 1; k >= 0; k -= 1) {
  399. var handler = handlers[k];
  400. if (listener && handler.listener === listener) {
  401. el.removeEventListener(event, handler.proxyListener, capture);
  402. handlers.splice(k, 1);
  403. } else if (!listener) {
  404. el.removeEventListener(event, handler.proxyListener, capture);
  405. handlers.splice(k, 1);
  406. }
  407. }
  408. }
  409. }
  410. }
  411. return this;
  412. }
  413. function trigger() {
  414. var this$1 = this;
  415. var args = [], len = arguments.length;
  416. while ( len-- ) args[ len ] = arguments[ len ];
  417. var events = args[0].split(' ');
  418. var eventData = args[1];
  419. for (var i = 0; i < events.length; i += 1) {
  420. var event = events[i];
  421. for (var j = 0; j < this.length; j += 1) {
  422. var el = this$1[j];
  423. var evt = (void 0);
  424. try {
  425. evt = new win.CustomEvent(event, {
  426. detail: eventData,
  427. bubbles: true,
  428. cancelable: true,
  429. });
  430. } catch (e) {
  431. evt = doc.createEvent('Event');
  432. evt.initEvent(event, true, true);
  433. evt.detail = eventData;
  434. }
  435. // eslint-disable-next-line
  436. el.dom7EventData = args.filter(function (data, dataIndex) { return dataIndex > 0; });
  437. el.dispatchEvent(evt);
  438. el.dom7EventData = [];
  439. delete el.dom7EventData;
  440. }
  441. }
  442. return this;
  443. }
  444. function transitionEnd(callback) {
  445. var events = ['webkitTransitionEnd', 'transitionend'];
  446. var dom = this;
  447. var i;
  448. function fireCallBack(e) {
  449. /* jshint validthis:true */
  450. if (e.target !== this) { return; }
  451. callback.call(this, e);
  452. for (i = 0; i < events.length; i += 1) {
  453. dom.off(events[i], fireCallBack);
  454. }
  455. }
  456. if (callback) {
  457. for (i = 0; i < events.length; i += 1) {
  458. dom.on(events[i], fireCallBack);
  459. }
  460. }
  461. return this;
  462. }
  463. function outerWidth(includeMargins) {
  464. if (this.length > 0) {
  465. if (includeMargins) {
  466. // eslint-disable-next-line
  467. var styles = this.styles();
  468. return this[0].offsetWidth + parseFloat(styles.getPropertyValue('margin-right')) + parseFloat(styles.getPropertyValue('margin-left'));
  469. }
  470. return this[0].offsetWidth;
  471. }
  472. return null;
  473. }
  474. function outerHeight(includeMargins) {
  475. if (this.length > 0) {
  476. if (includeMargins) {
  477. // eslint-disable-next-line
  478. var styles = this.styles();
  479. return this[0].offsetHeight + parseFloat(styles.getPropertyValue('margin-top')) + parseFloat(styles.getPropertyValue('margin-bottom'));
  480. }
  481. return this[0].offsetHeight;
  482. }
  483. return null;
  484. }
  485. function offset() {
  486. if (this.length > 0) {
  487. var el = this[0];
  488. var box = el.getBoundingClientRect();
  489. var body = doc.body;
  490. var clientTop = el.clientTop || body.clientTop || 0;
  491. var clientLeft = el.clientLeft || body.clientLeft || 0;
  492. var scrollTop = el === win ? win.scrollY : el.scrollTop;
  493. var scrollLeft = el === win ? win.scrollX : el.scrollLeft;
  494. return {
  495. top: (box.top + scrollTop) - clientTop,
  496. left: (box.left + scrollLeft) - clientLeft,
  497. };
  498. }
  499. return null;
  500. }
  501. function styles() {
  502. if (this[0]) { return win.getComputedStyle(this[0], null); }
  503. return {};
  504. }
  505. function css(props, value) {
  506. var this$1 = this;
  507. var i;
  508. if (arguments.length === 1) {
  509. if (typeof props === 'string') {
  510. if (this[0]) { return win.getComputedStyle(this[0], null).getPropertyValue(props); }
  511. } else {
  512. for (i = 0; i < this.length; i += 1) {
  513. // eslint-disable-next-line
  514. for (var prop in props) {
  515. this$1[i].style[prop] = props[prop];
  516. }
  517. }
  518. return this;
  519. }
  520. }
  521. if (arguments.length === 2 && typeof props === 'string') {
  522. for (i = 0; i < this.length; i += 1) {
  523. this$1[i].style[props] = value;
  524. }
  525. return this;
  526. }
  527. return this;
  528. }
  529. // Iterate over the collection passing elements to `callback`
  530. function each(callback) {
  531. var this$1 = this;
  532. // Don't bother continuing without a callback
  533. if (!callback) { return this; }
  534. // Iterate over the current collection
  535. for (var i = 0; i < this.length; i += 1) {
  536. // If the callback returns false
  537. if (callback.call(this$1[i], i, this$1[i]) === false) {
  538. // End the loop early
  539. return this$1;
  540. }
  541. }
  542. // Return `this` to allow chained DOM operations
  543. return this;
  544. }
  545. // eslint-disable-next-line
  546. function html(html) {
  547. var this$1 = this;
  548. if (typeof html === 'undefined') {
  549. return this[0] ? this[0].innerHTML : undefined;
  550. }
  551. for (var i = 0; i < this.length; i += 1) {
  552. this$1[i].innerHTML = html;
  553. }
  554. return this;
  555. }
  556. // eslint-disable-next-line
  557. function text(text) {
  558. var this$1 = this;
  559. if (typeof text === 'undefined') {
  560. if (this[0]) {
  561. return this[0].textContent.trim();
  562. }
  563. return null;
  564. }
  565. for (var i = 0; i < this.length; i += 1) {
  566. this$1[i].textContent = text;
  567. }
  568. return this;
  569. }
  570. function is(selector) {
  571. var el = this[0];
  572. var compareWith;
  573. var i;
  574. if (!el || typeof selector === 'undefined') { return false; }
  575. if (typeof selector === 'string') {
  576. if (el.matches) { return el.matches(selector); }
  577. else if (el.webkitMatchesSelector) { return el.webkitMatchesSelector(selector); }
  578. else if (el.msMatchesSelector) { return el.msMatchesSelector(selector); }
  579. compareWith = $(selector);
  580. for (i = 0; i < compareWith.length; i += 1) {
  581. if (compareWith[i] === el) { return true; }
  582. }
  583. return false;
  584. } else if (selector === doc) { return el === doc; }
  585. else if (selector === win) { return el === win; }
  586. if (selector.nodeType || selector instanceof Dom7) {
  587. compareWith = selector.nodeType ? [selector] : selector;
  588. for (i = 0; i < compareWith.length; i += 1) {
  589. if (compareWith[i] === el) { return true; }
  590. }
  591. return false;
  592. }
  593. return false;
  594. }
  595. function index() {
  596. var child = this[0];
  597. var i;
  598. if (child) {
  599. i = 0;
  600. // eslint-disable-next-line
  601. while ((child = child.previousSibling) !== null) {
  602. if (child.nodeType === 1) { i += 1; }
  603. }
  604. return i;
  605. }
  606. return undefined;
  607. }
  608. // eslint-disable-next-line
  609. function eq(index) {
  610. if (typeof index === 'undefined') { return this; }
  611. var length = this.length;
  612. var returnIndex;
  613. if (index > length - 1) {
  614. return new Dom7([]);
  615. }
  616. if (index < 0) {
  617. returnIndex = length + index;
  618. if (returnIndex < 0) { return new Dom7([]); }
  619. return new Dom7([this[returnIndex]]);
  620. }
  621. return new Dom7([this[index]]);
  622. }
  623. function append() {
  624. var this$1 = this;
  625. var args = [], len = arguments.length;
  626. while ( len-- ) args[ len ] = arguments[ len ];
  627. var newChild;
  628. for (var k = 0; k < args.length; k += 1) {
  629. newChild = args[k];
  630. for (var i = 0; i < this.length; i += 1) {
  631. if (typeof newChild === 'string') {
  632. var tempDiv = doc.createElement('div');
  633. tempDiv.innerHTML = newChild;
  634. while (tempDiv.firstChild) {
  635. this$1[i].appendChild(tempDiv.firstChild);
  636. }
  637. } else if (newChild instanceof Dom7) {
  638. for (var j = 0; j < newChild.length; j += 1) {
  639. this$1[i].appendChild(newChild[j]);
  640. }
  641. } else {
  642. this$1[i].appendChild(newChild);
  643. }
  644. }
  645. }
  646. return this;
  647. }
  648. function prepend(newChild) {
  649. var this$1 = this;
  650. var i;
  651. var j;
  652. for (i = 0; i < this.length; i += 1) {
  653. if (typeof newChild === 'string') {
  654. var tempDiv = doc.createElement('div');
  655. tempDiv.innerHTML = newChild;
  656. for (j = tempDiv.childNodes.length - 1; j >= 0; j -= 1) {
  657. this$1[i].insertBefore(tempDiv.childNodes[j], this$1[i].childNodes[0]);
  658. }
  659. } else if (newChild instanceof Dom7) {
  660. for (j = 0; j < newChild.length; j += 1) {
  661. this$1[i].insertBefore(newChild[j], this$1[i].childNodes[0]);
  662. }
  663. } else {
  664. this$1[i].insertBefore(newChild, this$1[i].childNodes[0]);
  665. }
  666. }
  667. return this;
  668. }
  669. function next(selector) {
  670. if (this.length > 0) {
  671. if (selector) {
  672. if (this[0].nextElementSibling && $(this[0].nextElementSibling).is(selector)) {
  673. return new Dom7([this[0].nextElementSibling]);
  674. }
  675. return new Dom7([]);
  676. }
  677. if (this[0].nextElementSibling) { return new Dom7([this[0].nextElementSibling]); }
  678. return new Dom7([]);
  679. }
  680. return new Dom7([]);
  681. }
  682. function nextAll(selector) {
  683. var nextEls = [];
  684. var el = this[0];
  685. if (!el) { return new Dom7([]); }
  686. while (el.nextElementSibling) {
  687. var next = el.nextElementSibling; // eslint-disable-line
  688. if (selector) {
  689. if ($(next).is(selector)) { nextEls.push(next); }
  690. } else { nextEls.push(next); }
  691. el = next;
  692. }
  693. return new Dom7(nextEls);
  694. }
  695. function prev(selector) {
  696. if (this.length > 0) {
  697. var el = this[0];
  698. if (selector) {
  699. if (el.previousElementSibling && $(el.previousElementSibling).is(selector)) {
  700. return new Dom7([el.previousElementSibling]);
  701. }
  702. return new Dom7([]);
  703. }
  704. if (el.previousElementSibling) { return new Dom7([el.previousElementSibling]); }
  705. return new Dom7([]);
  706. }
  707. return new Dom7([]);
  708. }
  709. function prevAll(selector) {
  710. var prevEls = [];
  711. var el = this[0];
  712. if (!el) { return new Dom7([]); }
  713. while (el.previousElementSibling) {
  714. var prev = el.previousElementSibling; // eslint-disable-line
  715. if (selector) {
  716. if ($(prev).is(selector)) { prevEls.push(prev); }
  717. } else { prevEls.push(prev); }
  718. el = prev;
  719. }
  720. return new Dom7(prevEls);
  721. }
  722. function parent(selector) {
  723. var this$1 = this;
  724. var parents = []; // eslint-disable-line
  725. for (var i = 0; i < this.length; i += 1) {
  726. if (this$1[i].parentNode !== null) {
  727. if (selector) {
  728. if ($(this$1[i].parentNode).is(selector)) { parents.push(this$1[i].parentNode); }
  729. } else {
  730. parents.push(this$1[i].parentNode);
  731. }
  732. }
  733. }
  734. return $(unique(parents));
  735. }
  736. function parents(selector) {
  737. var this$1 = this;
  738. var parents = []; // eslint-disable-line
  739. for (var i = 0; i < this.length; i += 1) {
  740. var parent = this$1[i].parentNode; // eslint-disable-line
  741. while (parent) {
  742. if (selector) {
  743. if ($(parent).is(selector)) { parents.push(parent); }
  744. } else {
  745. parents.push(parent);
  746. }
  747. parent = parent.parentNode;
  748. }
  749. }
  750. return $(unique(parents));
  751. }
  752. function closest(selector) {
  753. var closest = this; // eslint-disable-line
  754. if (typeof selector === 'undefined') {
  755. return new Dom7([]);
  756. }
  757. if (!closest.is(selector)) {
  758. closest = closest.parents(selector).eq(0);
  759. }
  760. return closest;
  761. }
  762. function find(selector) {
  763. var this$1 = this;
  764. var foundElements = [];
  765. for (var i = 0; i < this.length; i += 1) {
  766. var found = this$1[i].querySelectorAll(selector);
  767. for (var j = 0; j < found.length; j += 1) {
  768. foundElements.push(found[j]);
  769. }
  770. }
  771. return new Dom7(foundElements);
  772. }
  773. function children(selector) {
  774. var this$1 = this;
  775. var children = []; // eslint-disable-line
  776. for (var i = 0; i < this.length; i += 1) {
  777. var childNodes = this$1[i].childNodes;
  778. for (var j = 0; j < childNodes.length; j += 1) {
  779. if (!selector) {
  780. if (childNodes[j].nodeType === 1) { children.push(childNodes[j]); }
  781. } else if (childNodes[j].nodeType === 1 && $(childNodes[j]).is(selector)) {
  782. children.push(childNodes[j]);
  783. }
  784. }
  785. }
  786. return new Dom7(unique(children));
  787. }
  788. function remove() {
  789. var this$1 = this;
  790. for (var i = 0; i < this.length; i += 1) {
  791. if (this$1[i].parentNode) { this$1[i].parentNode.removeChild(this$1[i]); }
  792. }
  793. return this;
  794. }
  795. function add() {
  796. var args = [], len = arguments.length;
  797. while ( len-- ) args[ len ] = arguments[ len ];
  798. var dom = this;
  799. var i;
  800. var j;
  801. for (i = 0; i < args.length; i += 1) {
  802. var toAdd = $(args[i]);
  803. for (j = 0; j < toAdd.length; j += 1) {
  804. dom[dom.length] = toAdd[j];
  805. dom.length += 1;
  806. }
  807. }
  808. return dom;
  809. }
  810. var Methods = {
  811. addClass: addClass,
  812. removeClass: removeClass,
  813. hasClass: hasClass,
  814. toggleClass: toggleClass,
  815. attr: attr,
  816. removeAttr: removeAttr,
  817. data: data,
  818. transform: transform,
  819. transition: transition,
  820. on: on,
  821. off: off,
  822. trigger: trigger,
  823. transitionEnd: transitionEnd,
  824. outerWidth: outerWidth,
  825. outerHeight: outerHeight,
  826. offset: offset,
  827. css: css,
  828. each: each,
  829. html: html,
  830. text: text,
  831. is: is,
  832. index: index,
  833. eq: eq,
  834. append: append,
  835. prepend: prepend,
  836. next: next,
  837. nextAll: nextAll,
  838. prev: prev,
  839. prevAll: prevAll,
  840. parent: parent,
  841. parents: parents,
  842. closest: closest,
  843. find: find,
  844. children: children,
  845. remove: remove,
  846. add: add,
  847. styles: styles,
  848. };
  849. Object.keys(Methods).forEach(function (methodName) {
  850. $.fn[methodName] = Methods[methodName];
  851. });
  852. var Utils = {
  853. deleteProps: function deleteProps(obj) {
  854. var object = obj;
  855. Object.keys(object).forEach(function (key) {
  856. try {
  857. object[key] = null;
  858. } catch (e) {
  859. // no getter for object
  860. }
  861. try {
  862. delete object[key];
  863. } catch (e) {
  864. // something got wrong
  865. }
  866. });
  867. },
  868. nextTick: function nextTick(callback, delay) {
  869. if ( delay === void 0 ) delay = 0;
  870. return setTimeout(callback, delay);
  871. },
  872. now: function now() {
  873. return Date.now();
  874. },
  875. getTranslate: function getTranslate(el, axis) {
  876. if ( axis === void 0 ) axis = 'x';
  877. var matrix;
  878. var curTransform;
  879. var transformMatrix;
  880. var curStyle = win.getComputedStyle(el, null);
  881. if (win.WebKitCSSMatrix) {
  882. curTransform = curStyle.transform || curStyle.webkitTransform;
  883. if (curTransform.split(',').length > 6) {
  884. curTransform = curTransform.split(', ').map(function (a) { return a.replace(',', '.'); }).join(', ');
  885. }
  886. // Some old versions of Webkit choke when 'none' is passed; pass
  887. // empty string instead in this case
  888. transformMatrix = new win.WebKitCSSMatrix(curTransform === 'none' ? '' : curTransform);
  889. } else {
  890. transformMatrix = curStyle.MozTransform || curStyle.OTransform || curStyle.MsTransform || curStyle.msTransform || curStyle.transform || curStyle.getPropertyValue('transform').replace('translate(', 'matrix(1, 0, 0, 1,');
  891. matrix = transformMatrix.toString().split(',');
  892. }
  893. if (axis === 'x') {
  894. // Latest Chrome and webkits Fix
  895. if (win.WebKitCSSMatrix) { curTransform = transformMatrix.m41; }
  896. // Crazy IE10 Matrix
  897. else if (matrix.length === 16) { curTransform = parseFloat(matrix[12]); }
  898. // Normal Browsers
  899. else { curTransform = parseFloat(matrix[4]); }
  900. }
  901. if (axis === 'y') {
  902. // Latest Chrome and webkits Fix
  903. if (win.WebKitCSSMatrix) { curTransform = transformMatrix.m42; }
  904. // Crazy IE10 Matrix
  905. else if (matrix.length === 16) { curTransform = parseFloat(matrix[13]); }
  906. // Normal Browsers
  907. else { curTransform = parseFloat(matrix[5]); }
  908. }
  909. return curTransform || 0;
  910. },
  911. parseUrlQuery: function parseUrlQuery(url) {
  912. var query = {};
  913. var urlToParse = url || win.location.href;
  914. var i;
  915. var params;
  916. var param;
  917. var length;
  918. if (typeof urlToParse === 'string' && urlToParse.length) {
  919. urlToParse = urlToParse.indexOf('?') > -1 ? urlToParse.replace(/\S*\?/, '') : '';
  920. params = urlToParse.split('&').filter(function (paramsPart) { return paramsPart !== ''; });
  921. length = params.length;
  922. for (i = 0; i < length; i += 1) {
  923. param = params[i].replace(/#\S+/g, '').split('=');
  924. query[decodeURIComponent(param[0])] = typeof param[1] === 'undefined' ? undefined : decodeURIComponent(param[1]) || '';
  925. }
  926. }
  927. return query;
  928. },
  929. isObject: function isObject(o) {
  930. return typeof o === 'object' && o !== null && o.constructor && o.constructor === Object;
  931. },
  932. extend: function extend() {
  933. var args = [], len$1 = arguments.length;
  934. while ( len$1-- ) args[ len$1 ] = arguments[ len$1 ];
  935. var to = Object(args[0]);
  936. for (var i = 1; i < args.length; i += 1) {
  937. var nextSource = args[i];
  938. if (nextSource !== undefined && nextSource !== null) {
  939. var keysArray = Object.keys(Object(nextSource));
  940. for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex += 1) {
  941. var nextKey = keysArray[nextIndex];
  942. var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
  943. if (desc !== undefined && desc.enumerable) {
  944. if (Utils.isObject(to[nextKey]) && Utils.isObject(nextSource[nextKey])) {
  945. Utils.extend(to[nextKey], nextSource[nextKey]);
  946. } else if (!Utils.isObject(to[nextKey]) && Utils.isObject(nextSource[nextKey])) {
  947. to[nextKey] = {};
  948. Utils.extend(to[nextKey], nextSource[nextKey]);
  949. } else {
  950. to[nextKey] = nextSource[nextKey];
  951. }
  952. }
  953. }
  954. }
  955. }
  956. return to;
  957. },
  958. };
  959. var Support = (function Support() {
  960. var testDiv = doc.createElement('div');
  961. return {
  962. touch: (win.Modernizr && win.Modernizr.touch === true) || (function checkTouch() {
  963. return !!(('ontouchstart' in win) || (win.DocumentTouch && doc instanceof win.DocumentTouch));
  964. }()),
  965. pointerEvents: !!(win.navigator.pointerEnabled || win.PointerEvent),
  966. prefixedPointerEvents: !!win.navigator.msPointerEnabled,
  967. transition: (function checkTransition() {
  968. var style = testDiv.style;
  969. return ('transition' in style || 'webkitTransition' in style || 'MozTransition' in style);
  970. }()),
  971. transforms3d: (win.Modernizr && win.Modernizr.csstransforms3d === true) || (function checkTransforms3d() {
  972. var style = testDiv.style;
  973. return ('webkitPerspective' in style || 'MozPerspective' in style || 'OPerspective' in style || 'MsPerspective' in style || 'perspective' in style);
  974. }()),
  975. flexbox: (function checkFlexbox() {
  976. var style = testDiv.style;
  977. var styles = ('alignItems webkitAlignItems webkitBoxAlign msFlexAlign mozBoxAlign webkitFlexDirection msFlexDirection mozBoxDirection mozBoxOrient webkitBoxDirection webkitBoxOrient').split(' ');
  978. for (var i = 0; i < styles.length; i += 1) {
  979. if (styles[i] in style) { return true; }
  980. }
  981. return false;
  982. }()),
  983. observer: (function checkObserver() {
  984. return ('MutationObserver' in win || 'WebkitMutationObserver' in win);
  985. }()),
  986. passiveListener: (function checkPassiveListener() {
  987. var supportsPassive = false;
  988. try {
  989. var opts = Object.defineProperty({}, 'passive', {
  990. // eslint-disable-next-line
  991. get: function get() {
  992. supportsPassive = true;
  993. },
  994. });
  995. win.addEventListener('testPassiveListener', null, opts);
  996. } catch (e) {
  997. // No support
  998. }
  999. return supportsPassive;
  1000. }()),
  1001. gestures: (function checkGestures() {
  1002. return 'ongesturestart' in win;
  1003. }()),
  1004. };
  1005. }());
  1006. var SwiperClass = function SwiperClass(params) {
  1007. if ( params === void 0 ) params = {};
  1008. var self = this;
  1009. self.params = params;
  1010. // Events
  1011. self.eventsListeners = {};
  1012. if (self.params && self.params.on) {
  1013. Object.keys(self.params.on).forEach(function (eventName) {
  1014. self.on(eventName, self.params.on[eventName]);
  1015. });
  1016. }
  1017. };
  1018. var staticAccessors = { components: { configurable: true } };
  1019. SwiperClass.prototype.on = function on (events, handler, priority) {
  1020. var self = this;
  1021. if (typeof handler !== 'function') { return self; }
  1022. var method = priority ? 'unshift' : 'push';
  1023. events.split(' ').forEach(function (event) {
  1024. if (!self.eventsListeners[event]) { self.eventsListeners[event] = []; }
  1025. self.eventsListeners[event][method](handler);
  1026. });
  1027. return self;
  1028. };
  1029. SwiperClass.prototype.once = function once (events, handler, priority) {
  1030. var self = this;
  1031. if (typeof handler !== 'function') { return self; }
  1032. function onceHandler() {
  1033. var args = [], len = arguments.length;
  1034. while ( len-- ) args[ len ] = arguments[ len ];
  1035. handler.apply(self, args);
  1036. self.off(events, onceHandler);
  1037. }
  1038. return self.on(events, onceHandler, priority);
  1039. };
  1040. SwiperClass.prototype.off = function off (events, handler) {
  1041. var self = this;
  1042. if (!self.eventsListeners) { return self; }
  1043. events.split(' ').forEach(function (event) {
  1044. if (typeof handler === 'undefined') {
  1045. self.eventsListeners[event] = [];
  1046. } else {
  1047. self.eventsListeners[event].forEach(function (eventHandler, index) {
  1048. if (eventHandler === handler) {
  1049. self.eventsListeners[event].splice(index, 1);
  1050. }
  1051. });
  1052. }
  1053. });
  1054. return self;
  1055. };
  1056. SwiperClass.prototype.emit = function emit () {
  1057. var args = [], len = arguments.length;
  1058. while ( len-- ) args[ len ] = arguments[ len ];
  1059. var self = this;
  1060. if (!self.eventsListeners) { return self; }
  1061. var events;
  1062. var data;
  1063. var context;
  1064. if (typeof args[0] === 'string' || Array.isArray(args[0])) {
  1065. events = args[0];
  1066. data = args.slice(1, args.length);
  1067. context = self;
  1068. } else {
  1069. events = args[0].events;
  1070. data = args[0].data;
  1071. context = args[0].context || self;
  1072. }
  1073. var eventsArray = Array.isArray(events) ? events : events.split(' ');
  1074. eventsArray.forEach(function (event) {
  1075. if (self.eventsListeners && self.eventsListeners[event]) {
  1076. var handlers = [];
  1077. self.eventsListeners[event].forEach(function (eventHandler) {
  1078. handlers.push(eventHandler);
  1079. });
  1080. handlers.forEach(function (eventHandler) {
  1081. eventHandler.apply(context, data);
  1082. });
  1083. }
  1084. });
  1085. return self;
  1086. };
  1087. SwiperClass.prototype.useModulesParams = function useModulesParams (instanceParams) {
  1088. var instance = this;
  1089. if (!instance.modules) { return; }
  1090. Object.keys(instance.modules).forEach(function (moduleName) {
  1091. var module = instance.modules[moduleName];
  1092. // Extend params
  1093. if (module.params) {
  1094. Utils.extend(instanceParams, module.params);
  1095. }
  1096. });
  1097. };
  1098. SwiperClass.prototype.useModules = function useModules (modulesParams) {
  1099. if ( modulesParams === void 0 ) modulesParams = {};
  1100. var instance = this;
  1101. if (!instance.modules) { return; }
  1102. Object.keys(instance.modules).forEach(function (moduleName) {
  1103. var module = instance.modules[moduleName];
  1104. var moduleParams = modulesParams[moduleName] || {};
  1105. // Extend instance methods and props
  1106. if (module.instance) {
  1107. Object.keys(module.instance).forEach(function (modulePropName) {
  1108. var moduleProp = module.instance[modulePropName];
  1109. if (typeof moduleProp === 'function') {
  1110. instance[modulePropName] = moduleProp.bind(instance);
  1111. } else {
  1112. instance[modulePropName] = moduleProp;
  1113. }
  1114. });
  1115. }
  1116. // Add event listeners
  1117. if (module.on && instance.on) {
  1118. Object.keys(module.on).forEach(function (moduleEventName) {
  1119. instance.on(moduleEventName, module.on[moduleEventName]);
  1120. });
  1121. }
  1122. // Module create callback
  1123. if (module.create) {
  1124. module.create.bind(instance)(moduleParams);
  1125. }
  1126. });
  1127. };
  1128. staticAccessors.components.set = function (components) {
  1129. var Class = this;
  1130. if (!Class.use) { return; }
  1131. Class.use(components);
  1132. };
  1133. SwiperClass.installModule = function installModule (module) {
  1134. var params = [], len = arguments.length - 1;
  1135. while ( len-- > 0 ) params[ len ] = arguments[ len + 1 ];
  1136. var Class = this;
  1137. if (!Class.prototype.modules) { Class.prototype.modules = {}; }
  1138. var name = module.name || (((Object.keys(Class.prototype.modules).length) + "_" + (Utils.now())));
  1139. Class.prototype.modules[name] = module;
  1140. // Prototype
  1141. if (module.proto) {
  1142. Object.keys(module.proto).forEach(function (key) {
  1143. Class.prototype[key] = module.proto[key];
  1144. });
  1145. }
  1146. // Class
  1147. if (module.static) {
  1148. Object.keys(module.static).forEach(function (key) {
  1149. Class[key] = module.static[key];
  1150. });
  1151. }
  1152. // Callback
  1153. if (module.install) {
  1154. module.install.apply(Class, params);
  1155. }
  1156. return Class;
  1157. };
  1158. SwiperClass.use = function use (module) {
  1159. var params = [], len = arguments.length - 1;
  1160. while ( len-- > 0 ) params[ len ] = arguments[ len + 1 ];
  1161. var Class = this;
  1162. if (Array.isArray(module)) {
  1163. module.forEach(function (m) { return Class.installModule(m); });
  1164. return Class;
  1165. }
  1166. return Class.installModule.apply(Class, [ module ].concat( params ));
  1167. };
  1168. Object.defineProperties( SwiperClass, staticAccessors );
  1169. function updateSize () {
  1170. var swiper = this;
  1171. var width;
  1172. var height;
  1173. var $el = swiper.$el;
  1174. if (typeof swiper.params.width !== 'undefined') {
  1175. width = swiper.params.width;
  1176. } else {
  1177. width = $el[0].clientWidth;
  1178. }
  1179. if (typeof swiper.params.height !== 'undefined') {
  1180. height = swiper.params.height;
  1181. } else {
  1182. height = $el[0].clientHeight;
  1183. }
  1184. if ((width === 0 && swiper.isHorizontal()) || (height === 0 && swiper.isVertical())) {
  1185. return;
  1186. }
  1187. // Subtract paddings
  1188. width = width - parseInt($el.css('padding-left'), 10) - parseInt($el.css('padding-right'), 10);
  1189. height = height - parseInt($el.css('padding-top'), 10) - parseInt($el.css('padding-bottom'), 10);
  1190. Utils.extend(swiper, {
  1191. width: width,
  1192. height: height,
  1193. size: swiper.isHorizontal() ? width : height,
  1194. });
  1195. }
  1196. function updateSlides () {
  1197. var swiper = this;
  1198. var params = swiper.params;
  1199. var $wrapperEl = swiper.$wrapperEl;
  1200. var swiperSize = swiper.size;
  1201. var rtl = swiper.rtlTranslate;
  1202. var wrongRTL = swiper.wrongRTL;
  1203. var isVirtual = swiper.virtual && params.virtual.enabled;
  1204. var previousSlidesLength = isVirtual ? swiper.virtual.slides.length : swiper.slides.length;
  1205. var slides = $wrapperEl.children(("." + (swiper.params.slideClass)));
  1206. var slidesLength = isVirtual ? swiper.virtual.slides.length : slides.length;
  1207. var snapGrid = [];
  1208. var slidesGrid = [];
  1209. var slidesSizesGrid = [];
  1210. var offsetBefore = params.slidesOffsetBefore;
  1211. if (typeof offsetBefore === 'function') {
  1212. offsetBefore = params.slidesOffsetBefore.call(swiper);
  1213. }
  1214. var offsetAfter = params.slidesOffsetAfter;
  1215. if (typeof offsetAfter === 'function') {
  1216. offsetAfter = params.slidesOffsetAfter.call(swiper);
  1217. }
  1218. var previousSnapGridLength = swiper.snapGrid.length;
  1219. var previousSlidesGridLength = swiper.snapGrid.length;
  1220. var spaceBetween = params.spaceBetween;
  1221. var slidePosition = -offsetBefore;
  1222. var prevSlideSize = 0;
  1223. var index = 0;
  1224. if (typeof swiperSize === 'undefined') {
  1225. return;
  1226. }
  1227. if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) {
  1228. spaceBetween = (parseFloat(spaceBetween.replace('%', '')) / 100) * swiperSize;
  1229. }
  1230. swiper.virtualSize = -spaceBetween;
  1231. // reset margins
  1232. if (rtl) { slides.css({ marginLeft: '', marginTop: '' }); }
  1233. else { slides.css({ marginRight: '', marginBottom: '' }); }
  1234. var slidesNumberEvenToRows;
  1235. if (params.slidesPerColumn > 1) {
  1236. if (Math.floor(slidesLength / params.slidesPerColumn) === slidesLength / swiper.params.slidesPerColumn) {
  1237. slidesNumberEvenToRows = slidesLength;
  1238. } else {
  1239. slidesNumberEvenToRows = Math.ceil(slidesLength / params.slidesPerColumn) * params.slidesPerColumn;
  1240. }
  1241. if (params.slidesPerView !== 'auto' && params.slidesPerColumnFill === 'row') {
  1242. slidesNumberEvenToRows = Math.max(slidesNumberEvenToRows, params.slidesPerView * params.slidesPerColumn);
  1243. }
  1244. }
  1245. // Calc slides
  1246. var slideSize;
  1247. var slidesPerColumn = params.slidesPerColumn;
  1248. var slidesPerRow = slidesNumberEvenToRows / slidesPerColumn;
  1249. var numFullColumns = slidesPerRow - ((params.slidesPerColumn * slidesPerRow) - slidesLength);
  1250. for (var i = 0; i < slidesLength; i += 1) {
  1251. slideSize = 0;
  1252. var slide = slides.eq(i);
  1253. if (params.slidesPerColumn > 1) {
  1254. // Set slides order
  1255. var newSlideOrderIndex = (void 0);
  1256. var column = (void 0);
  1257. var row = (void 0);
  1258. if (params.slidesPerColumnFill === 'column') {
  1259. column = Math.floor(i / slidesPerColumn);
  1260. row = i - (column * slidesPerColumn);
  1261. if (column > numFullColumns || (column === numFullColumns && row === slidesPerColumn - 1)) {
  1262. row += 1;
  1263. if (row >= slidesPerColumn) {
  1264. row = 0;
  1265. column += 1;
  1266. }
  1267. }
  1268. newSlideOrderIndex = column + ((row * slidesNumberEvenToRows) / slidesPerColumn);
  1269. slide
  1270. .css({
  1271. '-webkit-box-ordinal-group': newSlideOrderIndex,
  1272. '-moz-box-ordinal-group': newSlideOrderIndex,
  1273. '-ms-flex-order': newSlideOrderIndex,
  1274. '-webkit-order': newSlideOrderIndex,
  1275. order: newSlideOrderIndex,
  1276. });
  1277. } else {
  1278. row = Math.floor(i / slidesPerRow);
  1279. column = i - (row * slidesPerRow);
  1280. }
  1281. slide
  1282. .css(
  1283. ("margin-" + (swiper.isHorizontal() ? 'top' : 'left')),
  1284. (row !== 0 && params.spaceBetween) && (((params.spaceBetween) + "px"))
  1285. )
  1286. .attr('data-swiper-column', column)
  1287. .attr('data-swiper-row', row);
  1288. }
  1289. if (slide.css('display') === 'none') { continue; } // eslint-disable-line
  1290. if (params.slidesPerView === 'auto') {
  1291. var slideStyles = win.getComputedStyle(slide[0], null);
  1292. var currentTransform = slide[0].style.transform;
  1293. var currentWebKitTransform = slide[0].style.webkitTransform;
  1294. if (currentTransform) {
  1295. slide[0].style.transform = 'none';
  1296. }
  1297. if (currentWebKitTransform) {
  1298. slide[0].style.webkitTransform = 'none';
  1299. }
  1300. if (swiper.isHorizontal()) {
  1301. slideSize = slide[0].getBoundingClientRect().width +
  1302. parseFloat(slideStyles.getPropertyValue('margin-left')) +
  1303. parseFloat(slideStyles.getPropertyValue('margin-right'));
  1304. } else {
  1305. slideSize = slide[0].getBoundingClientRect().height +
  1306. parseFloat(slideStyles.getPropertyValue('margin-top')) +
  1307. parseFloat(slideStyles.getPropertyValue('margin-bottom'));
  1308. }
  1309. if (currentTransform) {
  1310. slide[0].style.transform = currentTransform;
  1311. }
  1312. if (currentWebKitTransform) {
  1313. slide[0].style.webkitTransform = currentWebKitTransform;
  1314. }
  1315. if (params.roundLengths) { slideSize = Math.floor(slideSize); }
  1316. } else {
  1317. slideSize = (swiperSize - ((params.slidesPerView - 1) * spaceBetween)) / params.slidesPerView;
  1318. if (params.roundLengths) { slideSize = Math.floor(slideSize); }
  1319. if (slides[i]) {
  1320. if (swiper.isHorizontal()) {
  1321. slides[i].style.width = slideSize + "px";
  1322. } else {
  1323. slides[i].style.height = slideSize + "px";
  1324. }
  1325. }
  1326. }
  1327. if (slides[i]) {
  1328. slides[i].swiperSlideSize = slideSize;
  1329. }
  1330. slidesSizesGrid.push(slideSize);
  1331. if (params.centeredSlides) {
  1332. slidePosition = slidePosition + (slideSize / 2) + (prevSlideSize / 2) + spaceBetween;
  1333. if (prevSlideSize === 0 && i !== 0) { slidePosition = slidePosition - (swiperSize / 2) - spaceBetween; }
  1334. if (i === 0) { slidePosition = slidePosition - (swiperSize / 2) - spaceBetween; }
  1335. if (Math.abs(slidePosition) < 1 / 1000) { slidePosition = 0; }
  1336. if (params.roundLengths) { slidePosition = Math.floor(slidePosition); }
  1337. if ((index) % params.slidesPerGroup === 0) { snapGrid.push(slidePosition); }
  1338. slidesGrid.push(slidePosition);
  1339. } else {
  1340. if (params.roundLengths) { slidePosition = Math.floor(slidePosition); }
  1341. if ((index) % params.slidesPerGroup === 0) { snapGrid.push(slidePosition); }
  1342. slidesGrid.push(slidePosition);
  1343. slidePosition = slidePosition + slideSize + spaceBetween;
  1344. }
  1345. swiper.virtualSize += slideSize + spaceBetween;
  1346. prevSlideSize = slideSize;
  1347. index += 1;
  1348. }
  1349. swiper.virtualSize = Math.max(swiper.virtualSize, swiperSize) + offsetAfter;
  1350. var newSlidesGrid;
  1351. if (
  1352. rtl && wrongRTL && (params.effect === 'slide' || params.effect === 'coverflow')) {
  1353. $wrapperEl.css({ width: ((swiper.virtualSize + params.spaceBetween) + "px") });
  1354. }
  1355. if (!Support.flexbox || params.setWrapperSize) {
  1356. if (swiper.isHorizontal()) { $wrapperEl.css({ width: ((swiper.virtualSize + params.spaceBetween) + "px") }); }
  1357. else { $wrapperEl.css({ height: ((swiper.virtualSize + params.spaceBetween) + "px") }); }
  1358. }
  1359. if (params.slidesPerColumn > 1) {
  1360. swiper.virtualSize = (slideSize + params.spaceBetween) * slidesNumberEvenToRows;
  1361. swiper.virtualSize = Math.ceil(swiper.virtualSize / params.slidesPerColumn) - params.spaceBetween;
  1362. if (swiper.isHorizontal()) { $wrapperEl.css({ width: ((swiper.virtualSize + params.spaceBetween) + "px") }); }
  1363. else { $wrapperEl.css({ height: ((swiper.virtualSize + params.spaceBetween) + "px") }); }
  1364. if (params.centeredSlides) {
  1365. newSlidesGrid = [];
  1366. for (var i$1 = 0; i$1 < snapGrid.length; i$1 += 1) {
  1367. var slidesGridItem = snapGrid[i$1];
  1368. if (params.roundLengths) { slidesGridItem = Math.floor(slidesGridItem); }
  1369. if (snapGrid[i$1] < swiper.virtualSize + snapGrid[0]) { newSlidesGrid.push(slidesGridItem); }
  1370. }
  1371. snapGrid = newSlidesGrid;
  1372. }
  1373. }
  1374. // Remove last grid elements depending on width
  1375. if (!params.centeredSlides) {
  1376. newSlidesGrid = [];
  1377. for (var i$2 = 0; i$2 < snapGrid.length; i$2 += 1) {
  1378. var slidesGridItem$1 = snapGrid[i$2];
  1379. if (params.roundLengths) { slidesGridItem$1 = Math.floor(slidesGridItem$1); }
  1380. if (snapGrid[i$2] <= swiper.virtualSize - swiperSize) {
  1381. newSlidesGrid.push(slidesGridItem$1);
  1382. }
  1383. }
  1384. snapGrid = newSlidesGrid;
  1385. if (Math.floor(swiper.virtualSize - swiperSize) - Math.floor(snapGrid[snapGrid.length - 1]) > 1) {
  1386. snapGrid.push(swiper.virtualSize - swiperSize);
  1387. }
  1388. }
  1389. if (snapGrid.length === 0) { snapGrid = [0]; }
  1390. if (params.spaceBetween !== 0) {
  1391. if (swiper.isHorizontal()) {
  1392. if (rtl) { slides.css({ marginLeft: (spaceBetween + "px") }); }
  1393. else { slides.css({ marginRight: (spaceBetween + "px") }); }
  1394. } else { slides.css({ marginBottom: (spaceBetween + "px") }); }
  1395. }
  1396. Utils.extend(swiper, {
  1397. slides: slides,
  1398. snapGrid: snapGrid,
  1399. slidesGrid: slidesGrid,
  1400. slidesSizesGrid: slidesSizesGrid,
  1401. });
  1402. if (slidesLength !== previousSlidesLength) {
  1403. swiper.emit('slidesLengthChange');
  1404. }
  1405. if (snapGrid.length !== previousSnapGridLength) {
  1406. if (swiper.params.watchOverflow) { swiper.checkOverflow(); }
  1407. swiper.emit('snapGridLengthChange');
  1408. }
  1409. if (slidesGrid.length !== previousSlidesGridLength) {
  1410. swiper.emit('slidesGridLengthChange');
  1411. }
  1412. if (params.watchSlidesProgress || params.watchSlidesVisibility) {
  1413. swiper.updateSlidesOffset();
  1414. }
  1415. }
  1416. function updateAutoHeight (speed) {
  1417. var swiper = this;
  1418. var activeSlides = [];
  1419. var newHeight = 0;
  1420. var i;
  1421. if (typeof speed === 'number') {
  1422. swiper.setTransition(speed);
  1423. } else if (speed === true) {
  1424. swiper.setTransition(swiper.params.speed);
  1425. }
  1426. // Find slides currently in view
  1427. if (swiper.params.slidesPerView !== 'auto' && swiper.params.slidesPerView > 1) {
  1428. for (i = 0; i < Math.ceil(swiper.params.slidesPerView); i += 1) {
  1429. var index = swiper.activeIndex + i;
  1430. if (index > swiper.slides.length) { break; }
  1431. activeSlides.push(swiper.slides.eq(index)[0]);
  1432. }
  1433. } else {
  1434. activeSlides.push(swiper.slides.eq(swiper.activeIndex)[0]);
  1435. }
  1436. // Find new height from highest slide in view
  1437. for (i = 0; i < activeSlides.length; i += 1) {
  1438. if (typeof activeSlides[i] !== 'undefined') {
  1439. var height = activeSlides[i].offsetHeight;
  1440. newHeight = height > newHeight ? height : newHeight;
  1441. }
  1442. }
  1443. // Update Height
  1444. if (newHeight) { swiper.$wrapperEl.css('height', (newHeight + "px")); }
  1445. }
  1446. function updateSlidesOffset () {
  1447. var swiper = this;
  1448. var slides = swiper.slides;
  1449. for (var i = 0; i < slides.length; i += 1) {
  1450. slides[i].swiperSlideOffset = swiper.isHorizontal() ? slides[i].offsetLeft : slides[i].offsetTop;
  1451. }
  1452. }
  1453. function updateSlidesProgress (translate) {
  1454. if ( translate === void 0 ) translate = (this && this.translate) || 0;
  1455. var swiper = this;
  1456. var params = swiper.params;
  1457. var slides = swiper.slides;
  1458. var rtl = swiper.rtlTranslate;
  1459. if (slides.length === 0) { return; }
  1460. if (typeof slides[0].swiperSlideOffset === 'undefined') { swiper.updateSlidesOffset(); }
  1461. var offsetCenter = -translate;
  1462. if (rtl) { offsetCenter = translate; }
  1463. // Visible Slides
  1464. slides.removeClass(params.slideVisibleClass);
  1465. for (var i = 0; i < slides.length; i += 1) {
  1466. var slide = slides[i];
  1467. var slideProgress =
  1468. (
  1469. (offsetCenter + (params.centeredSlides ? swiper.minTranslate() : 0)) - slide.swiperSlideOffset
  1470. ) / (slide.swiperSlideSize + params.spaceBetween);
  1471. if (params.watchSlidesVisibility) {
  1472. var slideBefore = -(offsetCenter - slide.swiperSlideOffset);
  1473. var slideAfter = slideBefore + swiper.slidesSizesGrid[i];
  1474. var isVisible =
  1475. (slideBefore >= 0 && slideBefore < swiper.size) ||
  1476. (slideAfter > 0 && slideAfter <= swiper.size) ||
  1477. (slideBefore <= 0 && slideAfter >= swiper.size);
  1478. if (isVisible) {
  1479. slides.eq(i).addClass(params.slideVisibleClass);
  1480. }
  1481. }
  1482. slide.progress = rtl ? -slideProgress : slideProgress;
  1483. }
  1484. }
  1485. function updateProgress (translate) {
  1486. if ( translate === void 0 ) translate = (this && this.translate) || 0;
  1487. var swiper = this;
  1488. var params = swiper.params;
  1489. var translatesDiff = swiper.maxTranslate() - swiper.minTranslate();
  1490. var progress = swiper.progress;
  1491. var isBeginning = swiper.isBeginning;
  1492. var isEnd = swiper.isEnd;
  1493. var wasBeginning = isBeginning;
  1494. var wasEnd = isEnd;
  1495. if (translatesDiff === 0) {
  1496. progress = 0;
  1497. isBeginning = true;
  1498. isEnd = true;
  1499. } else {
  1500. progress = (translate - swiper.minTranslate()) / (translatesDiff);
  1501. isBeginning = progress <= 0;
  1502. isEnd = progress >= 1;
  1503. }
  1504. Utils.extend(swiper, {
  1505. progress: progress,
  1506. isBeginning: isBeginning,
  1507. isEnd: isEnd,
  1508. });
  1509. if (params.watchSlidesProgress || params.watchSlidesVisibility) { swiper.updateSlidesProgress(translate); }
  1510. if (isBeginning && !wasBeginning) {
  1511. swiper.emit('reachBeginning toEdge');
  1512. }
  1513. if (isEnd && !wasEnd) {
  1514. swiper.emit('reachEnd toEdge');
  1515. }
  1516. if ((wasBeginning && !isBeginning) || (wasEnd && !isEnd)) {
  1517. swiper.emit('fromEdge');
  1518. }
  1519. swiper.emit('progress', progress);
  1520. }
  1521. function updateSlidesClasses () {
  1522. var swiper = this;
  1523. var slides = swiper.slides;
  1524. var params = swiper.params;
  1525. var $wrapperEl = swiper.$wrapperEl;
  1526. var activeIndex = swiper.activeIndex;
  1527. var realIndex = swiper.realIndex;
  1528. var isVirtual = swiper.virtual && params.virtual.enabled;
  1529. slides.removeClass(((params.slideActiveClass) + " " + (params.slideNextClass) + " " + (params.slidePrevClass) + " " + (params.slideDuplicateActiveClass) + " " + (params.slideDuplicateNextClass) + " " + (params.slideDuplicatePrevClass)));
  1530. var activeSlide;
  1531. if (isVirtual) {
  1532. activeSlide = swiper.$wrapperEl.find(("." + (params.slideClass) + "[data-swiper-slide-index=\"" + activeIndex + "\"]"));
  1533. } else {
  1534. activeSlide = slides.eq(activeIndex);
  1535. }
  1536. // Active classes
  1537. activeSlide.addClass(params.slideActiveClass);
  1538. if (params.loop) {
  1539. // Duplicate to all looped slides
  1540. if (activeSlide.hasClass(params.slideDuplicateClass)) {
  1541. $wrapperEl
  1542. .children(("." + (params.slideClass) + ":not(." + (params.slideDuplicateClass) + ")[data-swiper-slide-index=\"" + realIndex + "\"]"))
  1543. .addClass(params.slideDuplicateActiveClass);
  1544. } else {
  1545. $wrapperEl
  1546. .children(("." + (params.slideClass) + "." + (params.slideDuplicateClass) + "[data-swiper-slide-index=\"" + realIndex + "\"]"))
  1547. .addClass(params.slideDuplicateActiveClass);
  1548. }
  1549. }
  1550. // Next Slide
  1551. var nextSlide = activeSlide.nextAll(("." + (params.slideClass))).eq(0).addClass(params.slideNextClass);
  1552. if (params.loop && nextSlide.length === 0) {
  1553. nextSlide = slides.eq(0);
  1554. nextSlide.addClass(params.slideNextClass);
  1555. }
  1556. // Prev Slide
  1557. var prevSlide = activeSlide.prevAll(("." + (params.slideClass))).eq(0).addClass(params.slidePrevClass);
  1558. if (params.loop && prevSlide.length === 0) {
  1559. prevSlide = slides.eq(-1);
  1560. prevSlide.addClass(params.slidePrevClass);
  1561. }
  1562. if (params.loop) {
  1563. // Duplicate to all looped slides
  1564. if (nextSlide.hasClass(params.slideDuplicateClass)) {
  1565. $wrapperEl
  1566. .children(("." + (params.slideClass) + ":not(." + (params.slideDuplicateClass) + ")[data-swiper-slide-index=\"" + (nextSlide.attr('data-swiper-slide-index')) + "\"]"))
  1567. .addClass(params.slideDuplicateNextClass);
  1568. } else {
  1569. $wrapperEl
  1570. .children(("." + (params.slideClass) + "." + (params.slideDuplicateClass) + "[data-swiper-slide-index=\"" + (nextSlide.attr('data-swiper-slide-index')) + "\"]"))
  1571. .addClass(params.slideDuplicateNextClass);
  1572. }
  1573. if (prevSlide.hasClass(params.slideDuplicateClass)) {
  1574. $wrapperEl
  1575. .children(("." + (params.slideClass) + ":not(." + (params.slideDuplicateClass) + ")[data-swiper-slide-index=\"" + (prevSlide.attr('data-swiper-slide-index')) + "\"]"))
  1576. .addClass(params.slideDuplicatePrevClass);
  1577. } else {
  1578. $wrapperEl
  1579. .children(("." + (params.slideClass) + "." + (params.slideDuplicateClass) + "[data-swiper-slide-index=\"" + (prevSlide.attr('data-swiper-slide-index')) + "\"]"))
  1580. .addClass(params.slideDuplicatePrevClass);
  1581. }
  1582. }
  1583. }
  1584. function updateActiveIndex (newActiveIndex) {
  1585. var swiper = this;
  1586. var translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate;
  1587. var slidesGrid = swiper.slidesGrid;
  1588. var snapGrid = swiper.snapGrid;
  1589. var params = swiper.params;
  1590. var previousIndex = swiper.activeIndex;
  1591. var previousRealIndex = swiper.realIndex;
  1592. var previousSnapIndex = swiper.snapIndex;
  1593. var activeIndex = newActiveIndex;
  1594. var snapIndex;
  1595. if (typeof activeIndex === 'undefined') {
  1596. for (var i = 0; i < slidesGrid.length; i += 1) {
  1597. if (typeof slidesGrid[i + 1] !== 'undefined') {
  1598. if (translate >= slidesGrid[i] && translate < slidesGrid[i + 1] - ((slidesGrid[i + 1] - slidesGrid[i]) / 2)) {
  1599. activeIndex = i;
  1600. } else if (translate >= slidesGrid[i] && translate < slidesGrid[i + 1]) {
  1601. activeIndex = i + 1;
  1602. }
  1603. } else if (translate >= slidesGrid[i]) {
  1604. activeIndex = i;
  1605. }
  1606. }
  1607. // Normalize slideIndex
  1608. if (params.normalizeSlideIndex) {
  1609. if (activeIndex < 0 || typeof activeIndex === 'undefined') { activeIndex = 0; }
  1610. }
  1611. }
  1612. if (snapGrid.indexOf(translate) >= 0) {
  1613. snapIndex = snapGrid.indexOf(translate);
  1614. } else {
  1615. snapIndex = Math.floor(activeIndex / params.slidesPerGroup);
  1616. }
  1617. if (snapIndex >= snapGrid.length) { snapIndex = snapGrid.length - 1; }
  1618. if (activeIndex === previousIndex) {
  1619. if (snapIndex !== previousSnapIndex) {
  1620. swiper.snapIndex = snapIndex;
  1621. swiper.emit('snapIndexChange');
  1622. }
  1623. return;
  1624. }
  1625. // Get real index
  1626. var realIndex = parseInt(swiper.slides.eq(activeIndex).attr('data-swiper-slide-index') || activeIndex, 10);
  1627. Utils.extend(swiper, {
  1628. snapIndex: snapIndex,
  1629. realIndex: realIndex,
  1630. previousIndex: previousIndex,
  1631. activeIndex: activeIndex,
  1632. });
  1633. swiper.emit('activeIndexChange');
  1634. swiper.emit('snapIndexChange');
  1635. if (previousRealIndex !== realIndex) {
  1636. swiper.emit('realIndexChange');
  1637. }
  1638. swiper.emit('slideChange');
  1639. }
  1640. function updateClickedSlide (e) {
  1641. var swiper = this;
  1642. var params = swiper.params;
  1643. var slide = $(e.target).closest(("." + (params.slideClass)))[0];
  1644. var slideFound = false;
  1645. if (slide) {
  1646. for (var i = 0; i < swiper.slides.length; i += 1) {
  1647. if (swiper.slides[i] === slide) { slideFound = true; }
  1648. }
  1649. }
  1650. if (slide && slideFound) {
  1651. swiper.clickedSlide = slide;
  1652. if (swiper.virtual && swiper.params.virtual.enabled) {
  1653. swiper.clickedIndex = parseInt($(slide).attr('data-swiper-slide-index'), 10);
  1654. } else {
  1655. swiper.clickedIndex = $(slide).index();
  1656. }
  1657. } else {
  1658. swiper.clickedSlide = undefined;
  1659. swiper.clickedIndex = undefined;
  1660. return;
  1661. }
  1662. if (params.slideToClickedSlide && swiper.clickedIndex !== undefined && swiper.clickedIndex !== swiper.activeIndex) {
  1663. swiper.slideToClickedSlide();
  1664. }
  1665. }
  1666. var update = {
  1667. updateSize: updateSize,
  1668. updateSlides: updateSlides,
  1669. updateAutoHeight: updateAutoHeight,
  1670. updateSlidesOffset: updateSlidesOffset,
  1671. updateSlidesProgress: updateSlidesProgress,
  1672. updateProgress: updateProgress,
  1673. updateSlidesClasses: updateSlidesClasses,
  1674. updateActiveIndex: updateActiveIndex,
  1675. updateClickedSlide: updateClickedSlide,
  1676. };
  1677. function getTranslate (axis) {
  1678. if ( axis === void 0 ) axis = this.isHorizontal() ? 'x' : 'y';
  1679. var swiper = this;
  1680. var params = swiper.params;
  1681. var rtl = swiper.rtlTranslate;
  1682. var translate = swiper.translate;
  1683. var $wrapperEl = swiper.$wrapperEl;
  1684. if (params.virtualTranslate) {
  1685. return rtl ? -translate : translate;
  1686. }
  1687. var currentTranslate = Utils.getTranslate($wrapperEl[0], axis);
  1688. if (rtl) { currentTranslate = -currentTranslate; }
  1689. return currentTranslate || 0;
  1690. }
  1691. function setTranslate (translate, byController) {
  1692. var swiper = this;
  1693. var rtl = swiper.rtlTranslate;
  1694. var params = swiper.params;
  1695. var $wrapperEl = swiper.$wrapperEl;
  1696. var progress = swiper.progress;
  1697. var x = 0;
  1698. var y = 0;
  1699. var z = 0;
  1700. if (swiper.isHorizontal()) {
  1701. x = rtl ? -translate : translate;
  1702. } else {
  1703. y = translate;
  1704. }
  1705. if (params.roundLengths) {
  1706. x = Math.floor(x);
  1707. y = Math.floor(y);
  1708. }
  1709. if (!params.virtualTranslate) {
  1710. if (Support.transforms3d) { $wrapperEl.transform(("translate3d(" + x + "px, " + y + "px, " + z + "px)")); }
  1711. else { $wrapperEl.transform(("translate(" + x + "px, " + y + "px)")); }
  1712. }
  1713. swiper.previousTranslate = swiper.translate;
  1714. swiper.translate = swiper.isHorizontal() ? x : y;
  1715. // Check if we need to update progress
  1716. var newProgress;
  1717. var translatesDiff = swiper.maxTranslate() - swiper.minTranslate();
  1718. if (translatesDiff === 0) {
  1719. newProgress = 0;
  1720. } else {
  1721. newProgress = (translate - swiper.minTranslate()) / (translatesDiff);
  1722. }
  1723. if (newProgress !== progress) {
  1724. swiper.updateProgress(translate);
  1725. }
  1726. swiper.emit('setTranslate', swiper.translate, byController);
  1727. }
  1728. function minTranslate () {
  1729. return (-this.snapGrid[0]);
  1730. }
  1731. function maxTranslate () {
  1732. return (-this.snapGrid[this.snapGrid.length - 1]);
  1733. }
  1734. var translate = {
  1735. getTranslate: getTranslate,
  1736. setTranslate: setTranslate,
  1737. minTranslate: minTranslate,
  1738. maxTranslate: maxTranslate,
  1739. };
  1740. function setTransition (duration, byController) {
  1741. var swiper = this;
  1742. swiper.$wrapperEl.transition(duration);
  1743. swiper.emit('setTransition', duration, byController);
  1744. }
  1745. function transitionStart (runCallbacks, direction) {
  1746. if ( runCallbacks === void 0 ) runCallbacks = true;
  1747. var swiper = this;
  1748. var activeIndex = swiper.activeIndex;
  1749. var params = swiper.params;
  1750. var previousIndex = swiper.previousIndex;
  1751. if (params.autoHeight) {
  1752. swiper.updateAutoHeight();
  1753. }
  1754. var dir = direction;
  1755. if (!dir) {
  1756. if (activeIndex > previousIndex) { dir = 'next'; }
  1757. else if (activeIndex < previousIndex) { dir = 'prev'; }
  1758. else { dir = 'reset'; }
  1759. }
  1760. swiper.emit('transitionStart');
  1761. if (runCallbacks && activeIndex !== previousIndex) {
  1762. if (dir === 'reset') {
  1763. swiper.emit('slideResetTransitionStart');
  1764. return;
  1765. }
  1766. swiper.emit('slideChangeTransitionStart');
  1767. if (dir === 'next') {
  1768. swiper.emit('slideNextTransitionStart');
  1769. } else {
  1770. swiper.emit('slidePrevTransitionStart');
  1771. }
  1772. }
  1773. }
  1774. function transitionEnd$1 (runCallbacks, direction) {
  1775. if ( runCallbacks === void 0 ) runCallbacks = true;
  1776. var swiper = this;
  1777. var activeIndex = swiper.activeIndex;
  1778. var previousIndex = swiper.previousIndex;
  1779. swiper.animating = false;
  1780. swiper.setTransition(0);
  1781. var dir = direction;
  1782. if (!dir) {
  1783. if (activeIndex > previousIndex) { dir = 'next'; }
  1784. else if (activeIndex < previousIndex) { dir = 'prev'; }
  1785. else { dir = 'reset'; }
  1786. }
  1787. swiper.emit('transitionEnd');
  1788. if (runCallbacks && activeIndex !== previousIndex) {
  1789. if (dir === 'reset') {
  1790. swiper.emit('slideResetTransitionEnd');
  1791. return;
  1792. }
  1793. swiper.emit('slideChangeTransitionEnd');
  1794. if (dir === 'next') {
  1795. swiper.emit('slideNextTransitionEnd');
  1796. } else {
  1797. swiper.emit('slidePrevTransitionEnd');
  1798. }
  1799. }
  1800. }
  1801. var transition$1 = {
  1802. setTransition: setTransition,
  1803. transitionStart: transitionStart,
  1804. transitionEnd: transitionEnd$1,
  1805. };
  1806. function slideTo (index, speed, runCallbacks, internal) {
  1807. if ( index === void 0 ) index = 0;
  1808. if ( speed === void 0 ) speed = this.params.speed;
  1809. if ( runCallbacks === void 0 ) runCallbacks = true;
  1810. var swiper = this;
  1811. var slideIndex = index;
  1812. if (slideIndex < 0) { slideIndex = 0; }
  1813. var params = swiper.params;
  1814. var snapGrid = swiper.snapGrid;
  1815. var slidesGrid = swiper.slidesGrid;
  1816. var previousIndex = swiper.previousIndex;
  1817. var activeIndex = swiper.activeIndex;
  1818. var rtl = swiper.rtlTranslate;
  1819. if (swiper.animating && params.preventIntercationOnTransition) {
  1820. return false;
  1821. }
  1822. var snapIndex = Math.floor(slideIndex / params.slidesPerGroup);
  1823. if (snapIndex >= snapGrid.length) { snapIndex = snapGrid.length - 1; }
  1824. if ((activeIndex || params.initialSlide || 0) === (previousIndex || 0) && runCallbacks) {
  1825. swiper.emit('beforeSlideChangeStart');
  1826. }
  1827. var translate = -snapGrid[snapIndex];
  1828. // Update progress
  1829. swiper.updateProgress(translate);
  1830. // Normalize slideIndex
  1831. if (params.normalizeSlideIndex) {
  1832. for (var i = 0; i < slidesGrid.length; i += 1) {
  1833. if (-Math.floor(translate * 100) >= Math.floor(slidesGrid[i] * 100)) {
  1834. slideIndex = i;
  1835. }
  1836. }
  1837. }
  1838. // Directions locks
  1839. if (swiper.initialized && slideIndex !== activeIndex) {
  1840. if (!swiper.allowSlideNext && translate < swiper.translate && translate < swiper.minTranslate()) {
  1841. return false;
  1842. }
  1843. if (!swiper.allowSlidePrev && translate > swiper.translate && translate > swiper.maxTranslate()) {
  1844. if ((activeIndex || 0) !== slideIndex) { return false; }
  1845. }
  1846. }
  1847. var direction;
  1848. if (slideIndex > activeIndex) { direction = 'next'; }
  1849. else if (slideIndex < activeIndex) { direction = 'prev'; }
  1850. else { direction = 'reset'; }
  1851. // Update Index
  1852. if ((rtl && -translate === swiper.translate) || (!rtl && translate === swiper.translate)) {
  1853. swiper.updateActiveIndex(slideIndex);
  1854. // Update Height
  1855. if (params.autoHeight) {
  1856. swiper.updateAutoHeight();
  1857. }
  1858. swiper.updateSlidesClasses();
  1859. if (params.effect !== 'slide') {
  1860. swiper.setTranslate(translate);
  1861. }
  1862. if (direction !== 'reset') {
  1863. swiper.transitionStart(runCallbacks, direction);
  1864. swiper.transitionEnd(runCallbacks, direction);
  1865. }
  1866. return false;
  1867. }
  1868. if (speed === 0 || !Support.transition) {
  1869. swiper.setTransition(0);
  1870. swiper.setTranslate(translate);
  1871. swiper.updateActiveIndex(slideIndex);
  1872. swiper.updateSlidesClasses();
  1873. swiper.emit('beforeTransitionStart', speed, internal);
  1874. swiper.transitionStart(runCallbacks, direction);
  1875. swiper.transitionEnd(runCallbacks, direction);
  1876. } else {
  1877. swiper.setTransition(speed);
  1878. swiper.setTranslate(translate);
  1879. swiper.updateActiveIndex(slideIndex);
  1880. swiper.updateSlidesClasses();
  1881. swiper.emit('beforeTransitionStart', speed, internal);
  1882. swiper.transitionStart(runCallbacks, direction);
  1883. if (!swiper.animating) {
  1884. swiper.animating = true;
  1885. if (!swiper.onSlideToWrapperTransitionEnd) {
  1886. swiper.onSlideToWrapperTransitionEnd = function transitionEnd(e) {
  1887. if (!swiper || swiper.destroyed) { return; }
  1888. if (e.target !== this) { return; }
  1889. swiper.$wrapperEl[0].removeEventListener('transitionend', swiper.onSlideToWrapperTransitionEnd);
  1890. swiper.$wrapperEl[0].removeEventListener('webkitTransitionEnd', swiper.onSlideToWrapperTransitionEnd);
  1891. swiper.transitionEnd(runCallbacks, direction);
  1892. };
  1893. }
  1894. swiper.$wrapperEl[0].addEventListener('transitionend', swiper.onSlideToWrapperTransitionEnd);
  1895. swiper.$wrapperEl[0].addEventListener('webkitTransitionEnd', swiper.onSlideToWrapperTransitionEnd);
  1896. }
  1897. }
  1898. return true;
  1899. }
  1900. function slideToLoop (index, speed, runCallbacks, internal) {
  1901. if ( index === void 0 ) index = 0;
  1902. if ( speed === void 0 ) speed = this.params.speed;
  1903. if ( runCallbacks === void 0 ) runCallbacks = true;
  1904. var swiper = this;
  1905. var newIndex = index;
  1906. if (swiper.params.loop) {
  1907. newIndex += swiper.loopedSlides;
  1908. }
  1909. return swiper.slideTo(newIndex, speed, runCallbacks, internal);
  1910. }
  1911. /* eslint no-unused-vars: "off" */
  1912. function slideNext (speed, runCallbacks, internal) {
  1913. if ( speed === void 0 ) speed = this.params.speed;
  1914. if ( runCallbacks === void 0 ) runCallbacks = true;
  1915. var swiper = this;
  1916. var params = swiper.params;
  1917. var animating = swiper.animating;
  1918. if (params.loop) {
  1919. if (animating) { return false; }
  1920. swiper.loopFix();
  1921. // eslint-disable-next-line
  1922. swiper._clientLeft = swiper.$wrapperEl[0].clientLeft;
  1923. return swiper.slideTo(swiper.activeIndex + params.slidesPerGroup, speed, runCallbacks, internal);
  1924. }
  1925. return swiper.slideTo(swiper.activeIndex + params.slidesPerGroup, speed, runCallbacks, internal);
  1926. }
  1927. /* eslint no-unused-vars: "off" */
  1928. function slidePrev (speed, runCallbacks, internal) {
  1929. if ( speed === void 0 ) speed = this.params.speed;
  1930. if ( runCallbacks === void 0 ) runCallbacks = true;
  1931. var swiper = this;
  1932. var params = swiper.params;
  1933. var animating = swiper.animating;
  1934. var snapGrid = swiper.snapGrid;
  1935. var slidesGrid = swiper.slidesGrid;
  1936. var rtlTranslate = swiper.rtlTranslate;
  1937. if (params.loop) {
  1938. if (animating) { return false; }
  1939. swiper.loopFix();
  1940. // eslint-disable-next-line
  1941. swiper._clientLeft = swiper.$wrapperEl[0].clientLeft;
  1942. }
  1943. var translate = rtlTranslate ? swiper.translate : -swiper.translate;
  1944. function normalize(val) {
  1945. if (val < 0) { return -Math.floor(Math.abs(val)); }
  1946. return Math.floor(val);
  1947. }
  1948. var normalizedTranslate = normalize(translate);
  1949. var normalizedSnapGrid = snapGrid.map(function (val) { return normalize(val); });
  1950. var normalizedSlidesGrid = slidesGrid.map(function (val) { return normalize(val); });
  1951. var currentSnap = snapGrid[normalizedSnapGrid.indexOf(normalizedTranslate)];
  1952. var prevSnap = snapGrid[normalizedSnapGrid.indexOf(normalizedTranslate) - 1];
  1953. var prevIndex;
  1954. if (typeof prevSnap !== 'undefined') {
  1955. prevIndex = slidesGrid.indexOf(prevSnap);
  1956. if (prevIndex < 0) { prevIndex = swiper.activeIndex - 1; }
  1957. }
  1958. return swiper.slideTo(prevIndex, speed, runCallbacks, internal);
  1959. }
  1960. /* eslint no-unused-vars: "off" */
  1961. function slideReset (speed, runCallbacks, internal) {
  1962. if ( speed === void 0 ) speed = this.params.speed;
  1963. if ( runCallbacks === void 0 ) runCallbacks = true;
  1964. var swiper = this;
  1965. return swiper.slideTo(swiper.activeIndex, speed, runCallbacks, internal);
  1966. }
  1967. /* eslint no-unused-vars: "off" */
  1968. function slideToClosest (speed, runCallbacks, internal) {
  1969. if ( speed === void 0 ) speed = this.params.speed;
  1970. if ( runCallbacks === void 0 ) runCallbacks = true;
  1971. var swiper = this;
  1972. var index = swiper.activeIndex;
  1973. var snapIndex = Math.floor(index / swiper.params.slidesPerGroup);
  1974. if (snapIndex < swiper.snapGrid.length - 1) {
  1975. var translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate;
  1976. var currentSnap = swiper.snapGrid[snapIndex];
  1977. var nextSnap = swiper.snapGrid[snapIndex + 1];
  1978. if ((translate - currentSnap) > (nextSnap - currentSnap) / 2) {
  1979. index = swiper.params.slidesPerGroup;
  1980. }
  1981. }
  1982. return swiper.slideTo(index, speed, runCallbacks, internal);
  1983. }
  1984. function slideToClickedSlide () {
  1985. var swiper = this;
  1986. var params = swiper.params;
  1987. var $wrapperEl = swiper.$wrapperEl;
  1988. var slidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : params.slidesPerView;
  1989. var slideToIndex = swiper.clickedIndex;
  1990. var realIndex;
  1991. if (params.loop) {
  1992. if (swiper.animating) { return; }
  1993. realIndex = parseInt($(swiper.clickedSlide).attr('data-swiper-slide-index'), 10);
  1994. if (params.centeredSlides) {
  1995. if (
  1996. (slideToIndex < swiper.loopedSlides - (slidesPerView / 2)) ||
  1997. (slideToIndex > (swiper.slides.length - swiper.loopedSlides) + (slidesPerView / 2))
  1998. ) {
  1999. swiper.loopFix();
  2000. slideToIndex = $wrapperEl
  2001. .children(("." + (params.slideClass) + "[data-swiper-slide-index=\"" + realIndex + "\"]:not(." + (params.slideDuplicateClass) + ")"))
  2002. .eq(0)
  2003. .index();
  2004. Utils.nextTick(function () {
  2005. swiper.slideTo(slideToIndex);
  2006. });
  2007. } else {
  2008. swiper.slideTo(slideToIndex);
  2009. }
  2010. } else if (slideToIndex > swiper.slides.length - slidesPerView) {
  2011. swiper.loopFix();
  2012. slideToIndex = $wrapperEl
  2013. .children(("." + (params.slideClass) + "[data-swiper-slide-index=\"" + realIndex + "\"]:not(." + (params.slideDuplicateClass) + ")"))
  2014. .eq(0)
  2015. .index();
  2016. Utils.nextTick(function () {
  2017. swiper.slideTo(slideToIndex);
  2018. });
  2019. } else {
  2020. swiper.slideTo(slideToIndex);
  2021. }
  2022. } else {
  2023. swiper.slideTo(slideToIndex);
  2024. }
  2025. }
  2026. var slide = {
  2027. slideTo: slideTo,
  2028. slideToLoop: slideToLoop,
  2029. slideNext: slideNext,
  2030. slidePrev: slidePrev,
  2031. slideReset: slideReset,
  2032. slideToClosest: slideToClosest,
  2033. slideToClickedSlide: slideToClickedSlide,
  2034. };
  2035. function loopCreate () {
  2036. var swiper = this;
  2037. var params = swiper.params;
  2038. var $wrapperEl = swiper.$wrapperEl;
  2039. // Remove duplicated slides
  2040. $wrapperEl.children(("." + (params.slideClass) + "." + (params.slideDuplicateClass))).remove();
  2041. var slides = $wrapperEl.children(("." + (params.slideClass)));
  2042. if (params.loopFillGroupWithBlank) {
  2043. var blankSlidesNum = params.slidesPerGroup - (slides.length % params.slidesPerGroup);
  2044. if (blankSlidesNum !== params.slidesPerGroup) {
  2045. for (var i = 0; i < blankSlidesNum; i += 1) {
  2046. var blankNode = $(doc.createElement('div')).addClass(((params.slideClass) + " " + (params.slideBlankClass)));
  2047. $wrapperEl.append(blankNode);
  2048. }
  2049. slides = $wrapperEl.children(("." + (params.slideClass)));
  2050. }
  2051. }
  2052. if (params.slidesPerView === 'auto' && !params.loopedSlides) { params.loopedSlides = slides.length; }
  2053. swiper.loopedSlides = parseInt(params.loopedSlides || params.slidesPerView, 10);
  2054. swiper.loopedSlides += params.loopAdditionalSlides;
  2055. if (swiper.loopedSlides > slides.length) {
  2056. swiper.loopedSlides = slides.length;
  2057. }
  2058. var prependSlides = [];
  2059. var appendSlides = [];
  2060. slides.each(function (index, el) {
  2061. var slide = $(el);
  2062. if (index < swiper.loopedSlides) { appendSlides.push(el); }
  2063. if (index < slides.length && index >= slides.length - swiper.loopedSlides) { prependSlides.push(el); }
  2064. slide.attr('data-swiper-slide-index', index);
  2065. });
  2066. for (var i$1 = 0; i$1 < appendSlides.length; i$1 += 1) {
  2067. $wrapperEl.append($(appendSlides[i$1].cloneNode(true)).addClass(params.slideDuplicateClass));
  2068. }
  2069. for (var i$2 = prependSlides.length - 1; i$2 >= 0; i$2 -= 1) {
  2070. $wrapperEl.prepend($(prependSlides[i$2].cloneNode(true)).addClass(params.slideDuplicateClass));
  2071. }
  2072. }
  2073. function loopFix () {
  2074. var swiper = this;
  2075. var params = swiper.params;
  2076. var activeIndex = swiper.activeIndex;
  2077. var slides = swiper.slides;
  2078. var loopedSlides = swiper.loopedSlides;
  2079. var allowSlidePrev = swiper.allowSlidePrev;
  2080. var allowSlideNext = swiper.allowSlideNext;
  2081. var snapGrid = swiper.snapGrid;
  2082. var rtl = swiper.rtlTranslate;
  2083. var newIndex;
  2084. swiper.allowSlidePrev = true;
  2085. swiper.allowSlideNext = true;
  2086. var snapTranslate = -snapGrid[activeIndex];
  2087. var diff = snapTranslate - swiper.getTranslate();
  2088. // Fix For Negative Oversliding
  2089. if (activeIndex < loopedSlides) {
  2090. newIndex = (slides.length - (loopedSlides * 3)) + activeIndex;
  2091. newIndex += loopedSlides;
  2092. var slideChanged = swiper.slideTo(newIndex, 0, false, true);
  2093. if (slideChanged && diff !== 0) {
  2094. swiper.setTranslate((rtl ? -swiper.translate : swiper.translate) - diff);
  2095. }
  2096. } else if ((params.slidesPerView === 'auto' && activeIndex >= loopedSlides * 2) || (activeIndex >= slides.length - loopedSlides)) {
  2097. // Fix For Positive Oversliding
  2098. newIndex = -slides.length + activeIndex + loopedSlides;
  2099. newIndex += loopedSlides;
  2100. var slideChanged$1 = swiper.slideTo(newIndex, 0, false, true);
  2101. if (slideChanged$1 && diff !== 0) {
  2102. swiper.setTranslate((rtl ? -swiper.translate : swiper.translate) - diff);
  2103. }
  2104. }
  2105. swiper.allowSlidePrev = allowSlidePrev;
  2106. swiper.allowSlideNext = allowSlideNext;
  2107. }
  2108. function loopDestroy () {
  2109. var swiper = this;
  2110. var $wrapperEl = swiper.$wrapperEl;
  2111. var params = swiper.params;
  2112. var slides = swiper.slides;
  2113. $wrapperEl.children(("." + (params.slideClass) + "." + (params.slideDuplicateClass))).remove();
  2114. slides.removeAttr('data-swiper-slide-index');
  2115. }
  2116. var loop = {
  2117. loopCreate: loopCreate,
  2118. loopFix: loopFix,
  2119. loopDestroy: loopDestroy,
  2120. };
  2121. function setGrabCursor (moving) {
  2122. var swiper = this;
  2123. if (Support.touch || !swiper.params.simulateTouch || (swiper.params.watchOverflow && swiper.isLocked)) { return; }
  2124. var el = swiper.el;
  2125. el.style.cursor = 'move';
  2126. el.style.cursor = moving ? '-webkit-grabbing' : '-webkit-grab';
  2127. el.style.cursor = moving ? '-moz-grabbin' : '-moz-grab';
  2128. el.style.cursor = moving ? 'grabbing' : 'grab';
  2129. }
  2130. function unsetGrabCursor () {
  2131. var swiper = this;
  2132. if (Support.touch || (swiper.params.watchOverflow && swiper.isLocked)) { return; }
  2133. swiper.el.style.cursor = '';
  2134. }
  2135. var grabCursor = {
  2136. setGrabCursor: setGrabCursor,
  2137. unsetGrabCursor: unsetGrabCursor,
  2138. };
  2139. function appendSlide (slides) {
  2140. var swiper = this;
  2141. var $wrapperEl = swiper.$wrapperEl;
  2142. var params = swiper.params;
  2143. if (params.loop) {
  2144. swiper.loopDestroy();
  2145. }
  2146. if (typeof slides === 'object' && 'length' in slides) {
  2147. for (var i = 0; i < slides.length; i += 1) {
  2148. if (slides[i]) { $wrapperEl.append(slides[i]); }
  2149. }
  2150. } else {
  2151. $wrapperEl.append(slides);
  2152. }
  2153. if (params.loop) {
  2154. swiper.loopCreate();
  2155. }
  2156. if (!(params.observer && Support.observer)) {
  2157. swiper.update();
  2158. }
  2159. }
  2160. function prependSlide (slides) {
  2161. var swiper = this;
  2162. var params = swiper.params;
  2163. var $wrapperEl = swiper.$wrapperEl;
  2164. var activeIndex = swiper.activeIndex;
  2165. if (params.loop) {
  2166. swiper.loopDestroy();
  2167. }
  2168. var newActiveIndex = activeIndex + 1;
  2169. if (typeof slides === 'object' && 'length' in slides) {
  2170. for (var i = 0; i < slides.length; i += 1) {
  2171. if (slides[i]) { $wrapperEl.prepend(slides[i]); }
  2172. }
  2173. newActiveIndex = activeIndex + slides.length;
  2174. } else {
  2175. $wrapperEl.prepend(slides);
  2176. }
  2177. if (params.loop) {
  2178. swiper.loopCreate();
  2179. }
  2180. if (!(params.observer && Support.observer)) {
  2181. swiper.update();
  2182. }
  2183. swiper.slideTo(newActiveIndex, 0, false);
  2184. }
  2185. function addSlide (index, slides) {
  2186. var swiper = this;
  2187. var $wrapperEl = swiper.$wrapperEl;
  2188. var params = swiper.params;
  2189. var activeIndex = swiper.activeIndex;
  2190. var activeIndexBuffer = activeIndex;
  2191. if (params.loop) {
  2192. activeIndexBuffer -= swiper.loopedSlides;
  2193. swiper.loopDestroy();
  2194. swiper.slides = $wrapperEl.children(("." + (params.slideClass)));
  2195. }
  2196. var baseLength = swiper.slides.length;
  2197. if (index <= 0) {
  2198. swiper.prependSlide(slides);
  2199. return;
  2200. } else if (index >= baseLength) {
  2201. swiper.appendSlide(slides);
  2202. return;
  2203. }
  2204. var newActiveIndex = activeIndexBuffer > index ? activeIndexBuffer + 1 : activeIndexBuffer;
  2205. var slidesBuffer = [];
  2206. for (var i = baseLength - 1; i >= index; i -= 1) {
  2207. var currentSlide = swiper.slides.eq(i);
  2208. currentSlide.remove();
  2209. slidesBuffer.unshift(currentSlide);
  2210. }
  2211. if (typeof slides === 'object' && 'length' in slides) {
  2212. for (var i$1 = 0; i$1 < slides.length; i$1 += 1) {
  2213. if (slides[i$1]) { $wrapperEl.append(slides[i$1]); }
  2214. }
  2215. newActiveIndex = activeIndexBuffer > index ? activeIndexBuffer + slides.length : activeIndexBuffer;
  2216. } else {
  2217. $wrapperEl.append(slides);
  2218. }
  2219. for (var i$2 = 0; i$2 < slidesBuffer.length; i$2 += 1) {
  2220. $wrapperEl.append(slidesBuffer[i$2]);
  2221. }
  2222. if (params.loop) {
  2223. swiper.loopCreate();
  2224. }
  2225. if (!(params.observer && Support.observer)) {
  2226. swiper.update();
  2227. }
  2228. if (params.loop) {
  2229. swiper.slideTo(newActiveIndex + swiper.loopedSlides, 0, false);
  2230. } else {
  2231. swiper.slideTo(newActiveIndex, 0, false);
  2232. }
  2233. }
  2234. function removeSlide (slidesIndexes) {
  2235. var swiper = this;
  2236. var params = swiper.params;
  2237. var $wrapperEl = swiper.$wrapperEl;
  2238. var activeIndex = swiper.activeIndex;
  2239. var activeIndexBuffer = activeIndex;
  2240. if (params.loop) {
  2241. activeIndexBuffer -= swiper.loopedSlides;
  2242. swiper.loopDestroy();
  2243. swiper.slides = $wrapperEl.children(("." + (params.slideClass)));
  2244. }
  2245. var newActiveIndex = activeIndexBuffer;
  2246. var indexToRemove;
  2247. if (typeof slidesIndexes === 'object' && 'length' in slidesIndexes) {
  2248. for (var i = 0; i < slidesIndexes.length; i += 1) {
  2249. indexToRemove = slidesIndexes[i];
  2250. if (swiper.slides[indexToRemove]) { swiper.slides.eq(indexToRemove).remove(); }
  2251. if (indexToRemove < newActiveIndex) { newActiveIndex -= 1; }
  2252. }
  2253. newActiveIndex = Math.max(newActiveIndex, 0);
  2254. } else {
  2255. indexToRemove = slidesIndexes;
  2256. if (swiper.slides[indexToRemove]) { swiper.slides.eq(indexToRemove).remove(); }
  2257. if (indexToRemove < newActiveIndex) { newActiveIndex -= 1; }
  2258. newActiveIndex = Math.max(newActiveIndex, 0);
  2259. }
  2260. if (params.loop) {
  2261. swiper.loopCreate();
  2262. }
  2263. if (!(params.observer && Support.observer)) {
  2264. swiper.update();
  2265. }
  2266. if (params.loop) {
  2267. swiper.slideTo(newActiveIndex + swiper.loopedSlides, 0, false);
  2268. } else {
  2269. swiper.slideTo(newActiveIndex, 0, false);
  2270. }
  2271. }
  2272. function removeAllSlides () {
  2273. var swiper = this;
  2274. var slidesIndexes = [];
  2275. for (var i = 0; i < swiper.slides.length; i += 1) {
  2276. slidesIndexes.push(i);
  2277. }
  2278. swiper.removeSlide(slidesIndexes);
  2279. }
  2280. var manipulation = {
  2281. appendSlide: appendSlide,
  2282. prependSlide: prependSlide,
  2283. addSlide: addSlide,
  2284. removeSlide: removeSlide,
  2285. removeAllSlides: removeAllSlides,
  2286. };
  2287. var Device = (function Device() {
  2288. var ua = win.navigator.userAgent;
  2289. var device = {
  2290. ios: false,
  2291. android: false,
  2292. androidChrome: false,
  2293. desktop: false,
  2294. windows: false,
  2295. iphone: false,
  2296. ipod: false,
  2297. ipad: false,
  2298. cordova: win.cordova || win.phonegap,
  2299. phonegap: win.cordova || win.phonegap,
  2300. };
  2301. var windows = ua.match(/(Windows Phone);?[\s\/]+([\d.]+)?/); // eslint-disable-line
  2302. var android = ua.match(/(Android);?[\s\/]+([\d.]+)?/); // eslint-disable-line
  2303. var ipad = ua.match(/(iPad).*OS\s([\d_]+)/);
  2304. var ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/);
  2305. var iphone = !ipad && ua.match(/(iPhone\sOS|iOS)\s([\d_]+)/);
  2306. // Windows
  2307. if (windows) {
  2308. device.os = 'windows';
  2309. device.osVersion = windows[2];
  2310. device.windows = true;
  2311. }
  2312. // Android
  2313. if (android && !windows) {
  2314. device.os = 'android';
  2315. device.osVersion = android[2];
  2316. device.android = true;
  2317. device.androidChrome = ua.toLowerCase().indexOf('chrome') >= 0;
  2318. }
  2319. if (ipad || iphone || ipod) {
  2320. device.os = 'ios';
  2321. device.ios = true;
  2322. }
  2323. // iOS
  2324. if (iphone && !ipod) {
  2325. device.osVersion = iphone[2].replace(/_/g, '.');
  2326. device.iphone = true;
  2327. }
  2328. if (ipad) {
  2329. device.osVersion = ipad[2].replace(/_/g, '.');
  2330. device.ipad = true;
  2331. }
  2332. if (ipod) {
  2333. device.osVersion = ipod[3] ? ipod[3].replace(/_/g, '.') : null;
  2334. device.iphone = true;
  2335. }
  2336. // iOS 8+ changed UA
  2337. if (device.ios && device.osVersion && ua.indexOf('Version/') >= 0) {
  2338. if (device.osVersion.split('.')[0] === '10') {
  2339. device.osVersion = ua.toLowerCase().split('version/')[1].split(' ')[0];
  2340. }
  2341. }
  2342. // Desktop
  2343. device.desktop = !(device.os || device.android || device.webView);
  2344. // Webview
  2345. device.webView = (iphone || ipad || ipod) && ua.match(/.*AppleWebKit(?!.*Safari)/i);
  2346. // Minimal UI
  2347. if (device.os && device.os === 'ios') {
  2348. var osVersionArr = device.osVersion.split('.');
  2349. var metaViewport = doc.querySelector('meta[name="viewport"]');
  2350. device.minimalUi =
  2351. !device.webView &&
  2352. (ipod || iphone) &&
  2353. (osVersionArr[0] * 1 === 7 ? osVersionArr[1] * 1 >= 1 : osVersionArr[0] * 1 > 7) &&
  2354. metaViewport && metaViewport.getAttribute('content').indexOf('minimal-ui') >= 0;
  2355. }
  2356. // Pixel Ratio
  2357. device.pixelRatio = win.devicePixelRatio || 1;
  2358. // Export object
  2359. return device;
  2360. }());
  2361. function onTouchStart (event) {
  2362. var swiper = this;
  2363. var data = swiper.touchEventsData;
  2364. var params = swiper.params;
  2365. var touches = swiper.touches;
  2366. if (swiper.animating && params.preventIntercationOnTransition) {
  2367. return;
  2368. }
  2369. var e = event;
  2370. if (e.originalEvent) { e = e.originalEvent; }
  2371. data.isTouchEvent = e.type === 'touchstart';
  2372. if (!data.isTouchEvent && 'which' in e && e.which === 3) { return; }
  2373. if (data.isTouched && data.isMoved) { return; }
  2374. if (params.noSwiping && $(e.target).closest(params.noSwipingSelector ? params.noSwipingSelector : ("." + (params.noSwipingClass)))[0]) {
  2375. swiper.allowClick = true;
  2376. return;
  2377. }
  2378. if (params.swipeHandler) {
  2379. if (!$(e).closest(params.swipeHandler)[0]) { return; }
  2380. }
  2381. touches.currentX = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX;
  2382. touches.currentY = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY;
  2383. var startX = touches.currentX;
  2384. var startY = touches.currentY;
  2385. // Do NOT start if iOS edge swipe is detected. Otherwise iOS app (UIWebView) cannot swipe-to-go-back anymore
  2386. if (
  2387. Device.ios &&
  2388. !Device.cordova &&
  2389. params.iOSEdgeSwipeDetection &&
  2390. ((startX <= params.iOSEdgeSwipeThreshold) ||
  2391. (startX >= win.screen.width - params.iOSEdgeSwipeThreshold))
  2392. ) {
  2393. return;
  2394. }
  2395. Utils.extend(data, {
  2396. isTouched: true,
  2397. isMoved: false,
  2398. allowTouchCallbacks: true,
  2399. isScrolling: undefined,
  2400. startMoving: undefined,
  2401. });
  2402. touches.startX = startX;
  2403. touches.startY = startY;
  2404. data.touchStartTime = Utils.now();
  2405. swiper.allowClick = true;
  2406. swiper.updateSize();
  2407. swiper.swipeDirection = undefined;
  2408. if (params.threshold > 0) { data.allowThresholdMove = false; }
  2409. if (e.type !== 'touchstart') {
  2410. var preventDefault = true;
  2411. if ($(e.target).is(data.formElements)) { preventDefault = false; }
  2412. if (
  2413. doc.activeElement &&
  2414. $(doc.activeElement).is(data.formElements) &&
  2415. doc.activeElement !== e.target
  2416. ) {
  2417. doc.activeElement.blur();
  2418. }
  2419. if (preventDefault && swiper.allowTouchMove) {
  2420. e.preventDefault();
  2421. }
  2422. }
  2423. swiper.emit('touchStart', e);
  2424. }
  2425. function onTouchMove (event) {
  2426. var swiper = this;
  2427. var data = swiper.touchEventsData;
  2428. var params = swiper.params;
  2429. var touches = swiper.touches;
  2430. var rtl = swiper.rtlTranslate;
  2431. var e = event;
  2432. if (e.originalEvent) { e = e.originalEvent; }
  2433. if (!data.isTouched) {
  2434. if (data.startMoving && data.isScrolling) {
  2435. swiper.emit('touchMoveOpposite', e);
  2436. }
  2437. return;
  2438. }
  2439. if (data.isTouchEvent && e.type === 'mousemove') { return; }
  2440. var pageX = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX;
  2441. var pageY = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY;
  2442. if (e.preventedByNestedSwiper) {
  2443. touches.startX = pageX;
  2444. touches.startY = pageY;
  2445. return;
  2446. }
  2447. if (!swiper.allowTouchMove) {
  2448. // isMoved = true;
  2449. swiper.allowClick = false;
  2450. if (data.isTouched) {
  2451. Utils.extend(touches, {
  2452. startX: pageX,
  2453. startY: pageY,
  2454. currentX: pageX,
  2455. currentY: pageY,
  2456. });
  2457. data.touchStartTime = Utils.now();
  2458. }
  2459. return;
  2460. }
  2461. if (data.isTouchEvent && params.touchReleaseOnEdges && !params.loop) {
  2462. if (swiper.isVertical()) {
  2463. // Vertical
  2464. if (
  2465. (pageY < touches.startY && swiper.translate <= swiper.maxTranslate()) ||
  2466. (pageY > touches.startY && swiper.translate >= swiper.minTranslate())
  2467. ) {
  2468. data.isTouched = false;
  2469. data.isMoved = false;
  2470. return;
  2471. }
  2472. } else if (
  2473. (pageX < touches.startX && swiper.translate <= swiper.maxTranslate()) ||
  2474. (pageX > touches.startX && swiper.translate >= swiper.minTranslate())
  2475. ) {
  2476. return;
  2477. }
  2478. }
  2479. if (data.isTouchEvent && doc.activeElement) {
  2480. if (e.target === doc.activeElement && $(e.target).is(data.formElements)) {
  2481. data.isMoved = true;
  2482. swiper.allowClick = false;
  2483. return;
  2484. }
  2485. }
  2486. if (data.allowTouchCallbacks) {
  2487. swiper.emit('touchMove', e);
  2488. }
  2489. if (e.targetTouches && e.targetTouches.length > 1) { return; }
  2490. touches.currentX = pageX;
  2491. touches.currentY = pageY;
  2492. var diffX = touches.currentX - touches.startX;
  2493. var diffY = touches.currentY - touches.startY;
  2494. if (typeof data.isScrolling === 'undefined') {
  2495. var touchAngle;
  2496. if ((swiper.isHorizontal() && touches.currentY === touches.startY) || (swiper.isVertical() && touches.currentX === touches.startX)) {
  2497. data.isScrolling = false;
  2498. } else {
  2499. // eslint-disable-next-line
  2500. if ((diffX * diffX) + (diffY * diffY) >= 25) {
  2501. touchAngle = (Math.atan2(Math.abs(diffY), Math.abs(diffX)) * 180) / Math.PI;
  2502. data.isScrolling = swiper.isHorizontal() ? touchAngle > params.touchAngle : (90 - touchAngle > params.touchAngle);
  2503. }
  2504. }
  2505. }
  2506. if (data.isScrolling) {
  2507. swiper.emit('touchMoveOpposite', e);
  2508. }
  2509. if (typeof startMoving === 'undefined') {
  2510. if (touches.currentX !== touches.startX || touches.currentY !== touches.startY) {
  2511. data.startMoving = true;
  2512. }
  2513. }
  2514. if (data.isScrolling) {
  2515. data.isTouched = false;
  2516. return;
  2517. }
  2518. if (!data.startMoving) {
  2519. return;
  2520. }
  2521. swiper.allowClick = false;
  2522. e.preventDefault();
  2523. if (params.touchMoveStopPropagation && !params.nested) {
  2524. e.stopPropagation();
  2525. }
  2526. if (!data.isMoved) {
  2527. if (params.loop) {
  2528. swiper.loopFix();
  2529. }
  2530. data.startTranslate = swiper.getTranslate();
  2531. swiper.setTransition(0);
  2532. if (swiper.animating) {
  2533. swiper.$wrapperEl.trigger('webkitTransitionEnd transitionend');
  2534. }
  2535. data.allowMomentumBounce = false;
  2536. // Grab Cursor
  2537. if (params.grabCursor && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) {
  2538. swiper.setGrabCursor(true);
  2539. }
  2540. swiper.emit('sliderFirstMove', e);
  2541. }
  2542. swiper.emit('sliderMove', e);
  2543. data.isMoved = true;
  2544. var diff = swiper.isHorizontal() ? diffX : diffY;
  2545. touches.diff = diff;
  2546. diff *= params.touchRatio;
  2547. if (rtl) { diff = -diff; }
  2548. swiper.swipeDirection = diff > 0 ? 'prev' : 'next';
  2549. data.currentTranslate = diff + data.startTranslate;
  2550. var disableParentSwiper = true;
  2551. var resistanceRatio = params.resistanceRatio;
  2552. if (params.touchReleaseOnEdges) {
  2553. resistanceRatio = 0;
  2554. }
  2555. if ((diff > 0 && data.currentTranslate > swiper.minTranslate())) {
  2556. disableParentSwiper = false;
  2557. if (params.resistance) { data.currentTranslate = (swiper.minTranslate() - 1) + (Math.pow( (-swiper.minTranslate() + data.startTranslate + diff), resistanceRatio )); }
  2558. } else if (diff < 0 && data.currentTranslate < swiper.maxTranslate()) {
  2559. disableParentSwiper = false;
  2560. if (params.resistance) { data.currentTranslate = (swiper.maxTranslate() + 1) - (Math.pow( (swiper.maxTranslate() - data.startTranslate - diff), resistanceRatio )); }
  2561. }
  2562. if (disableParentSwiper) {
  2563. e.preventedByNestedSwiper = true;
  2564. }
  2565. // Directions locks
  2566. if (!swiper.allowSlideNext && swiper.swipeDirection === 'next' && data.currentTranslate < data.startTranslate) {
  2567. data.currentTranslate = data.startTranslate;
  2568. }
  2569. if (!swiper.allowSlidePrev && swiper.swipeDirection === 'prev' && data.currentTranslate > data.startTranslate) {
  2570. data.currentTranslate = data.startTranslate;
  2571. }
  2572. // Threshold
  2573. if (params.threshold > 0) {
  2574. if (Math.abs(diff) > params.threshold || data.allowThresholdMove) {
  2575. if (!data.allowThresholdMove) {
  2576. data.allowThresholdMove = true;
  2577. touches.startX = touches.currentX;
  2578. touches.startY = touches.currentY;
  2579. data.currentTranslate = data.startTranslate;
  2580. touches.diff = swiper.isHorizontal() ? touches.currentX - touches.startX : touches.currentY - touches.startY;
  2581. return;
  2582. }
  2583. } else {
  2584. data.currentTranslate = data.startTranslate;
  2585. return;
  2586. }
  2587. }
  2588. if (!params.followFinger) { return; }
  2589. // Update active index in free mode
  2590. if (params.freeMode || params.watchSlidesProgress || params.watchSlidesVisibility) {
  2591. swiper.updateActiveIndex();
  2592. swiper.updateSlidesClasses();
  2593. }
  2594. if (params.freeMode) {
  2595. // Velocity
  2596. if (data.velocities.length === 0) {
  2597. data.velocities.push({
  2598. position: touches[swiper.isHorizontal() ? 'startX' : 'startY'],
  2599. time: data.touchStartTime,
  2600. });
  2601. }
  2602. data.velocities.push({
  2603. position: touches[swiper.isHorizontal() ? 'currentX' : 'currentY'],
  2604. time: Utils.now(),
  2605. });
  2606. }
  2607. // Update progress
  2608. swiper.updateProgress(data.currentTranslate);
  2609. // Update translate
  2610. swiper.setTranslate(data.currentTranslate);
  2611. }
  2612. function onTouchEnd (event) {
  2613. var swiper = this;
  2614. var data = swiper.touchEventsData;
  2615. var params = swiper.params;
  2616. var touches = swiper.touches;
  2617. var rtl = swiper.rtlTranslate;
  2618. var $wrapperEl = swiper.$wrapperEl;
  2619. var slidesGrid = swiper.slidesGrid;
  2620. var snapGrid = swiper.snapGrid;
  2621. var e = event;
  2622. if (e.originalEvent) { e = e.originalEvent; }
  2623. if (data.allowTouchCallbacks) {
  2624. swiper.emit('touchEnd', e);
  2625. }
  2626. data.allowTouchCallbacks = false;
  2627. if (!data.isTouched) {
  2628. if (data.isMoved && params.grabCursor) {
  2629. swiper.setGrabCursor(false);
  2630. }
  2631. data.isMoved = false;
  2632. data.startMoving = false;
  2633. return;
  2634. }
  2635. // Return Grab Cursor
  2636. if (params.grabCursor && data.isMoved && data.isTouched && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) {
  2637. swiper.setGrabCursor(false);
  2638. }
  2639. // Time diff
  2640. var touchEndTime = Utils.now();
  2641. var timeDiff = touchEndTime - data.touchStartTime;
  2642. // Tap, doubleTap, Click
  2643. if (swiper.allowClick) {
  2644. swiper.updateClickedSlide(e);
  2645. swiper.emit('tap', e);
  2646. if (timeDiff < 300 && (touchEndTime - data.lastClickTime) > 300) {
  2647. if (data.clickTimeout) { clearTimeout(data.clickTimeout); }
  2648. data.clickTimeout = Utils.nextTick(function () {
  2649. if (!swiper || swiper.destroyed) { return; }
  2650. swiper.emit('click', e);
  2651. }, 300);
  2652. }
  2653. if (timeDiff < 300 && (touchEndTime - data.lastClickTime) < 300) {
  2654. if (data.clickTimeout) { clearTimeout(data.clickTimeout); }
  2655. swiper.emit('doubleTap', e);
  2656. }
  2657. }
  2658. data.lastClickTime = Utils.now();
  2659. Utils.nextTick(function () {
  2660. if (!swiper.destroyed) { swiper.allowClick = true; }
  2661. });
  2662. if (!data.isTouched || !data.isMoved || !swiper.swipeDirection || touches.diff === 0 || data.currentTranslate === data.startTranslate) {
  2663. data.isTouched = false;
  2664. data.isMoved = false;
  2665. data.startMoving = false;
  2666. return;
  2667. }
  2668. data.isTouched = false;
  2669. data.isMoved = false;
  2670. data.startMoving = false;
  2671. var currentPos;
  2672. if (params.followFinger) {
  2673. currentPos = rtl ? swiper.translate : -swiper.translate;
  2674. } else {
  2675. currentPos = -data.currentTranslate;
  2676. }
  2677. if (params.freeMode) {
  2678. if (currentPos < -swiper.minTranslate()) {
  2679. swiper.slideTo(swiper.activeIndex);
  2680. return;
  2681. } else if (currentPos > -swiper.maxTranslate()) {
  2682. if (swiper.slides.length < snapGrid.length) {
  2683. swiper.slideTo(snapGrid.length - 1);
  2684. } else {
  2685. swiper.slideTo(swiper.slides.length - 1);
  2686. }
  2687. return;
  2688. }
  2689. if (params.freeModeMomentum) {
  2690. if (data.velocities.length > 1) {
  2691. var lastMoveEvent = data.velocities.pop();
  2692. var velocityEvent = data.velocities.pop();
  2693. var distance = lastMoveEvent.position - velocityEvent.position;
  2694. var time = lastMoveEvent.time - velocityEvent.time;
  2695. swiper.velocity = distance / time;
  2696. swiper.velocity /= 2;
  2697. if (Math.abs(swiper.velocity) < params.freeModeMinimumVelocity) {
  2698. swiper.velocity = 0;
  2699. }
  2700. // this implies that the user stopped moving a finger then released.
  2701. // There would be no events with distance zero, so the last event is stale.
  2702. if (time > 150 || (Utils.now() - lastMoveEvent.time) > 300) {
  2703. swiper.velocity = 0;
  2704. }
  2705. } else {
  2706. swiper.velocity = 0;
  2707. }
  2708. swiper.velocity *= params.freeModeMomentumVelocityRatio;
  2709. data.velocities.length = 0;
  2710. var momentumDuration = 1000 * params.freeModeMomentumRatio;
  2711. var momentumDistance = swiper.velocity * momentumDuration;
  2712. var newPosition = swiper.translate + momentumDistance;
  2713. if (rtl) { newPosition = -newPosition; }
  2714. var doBounce = false;
  2715. var afterBouncePosition;
  2716. var bounceAmount = Math.abs(swiper.velocity) * 20 * params.freeModeMomentumBounceRatio;
  2717. var needsLoopFix;
  2718. if (newPosition < swiper.maxTranslate()) {
  2719. if (params.freeModeMomentumBounce) {
  2720. if (newPosition + swiper.maxTranslate() < -bounceAmount) {
  2721. newPosition = swiper.maxTranslate() - bounceAmount;
  2722. }
  2723. afterBouncePosition = swiper.maxTranslate();
  2724. doBounce = true;
  2725. data.allowMomentumBounce = true;
  2726. } else {
  2727. newPosition = swiper.maxTranslate();
  2728. }
  2729. if (params.loop && params.centeredSlides) { needsLoopFix = true; }
  2730. } else if (newPosition > swiper.minTranslate()) {
  2731. if (params.freeModeMomentumBounce) {
  2732. if (newPosition - swiper.minTranslate() > bounceAmount) {
  2733. newPosition = swiper.minTranslate() + bounceAmount;
  2734. }
  2735. afterBouncePosition = swiper.minTranslate();
  2736. doBounce = true;
  2737. data.allowMomentumBounce = true;
  2738. } else {
  2739. newPosition = swiper.minTranslate();
  2740. }
  2741. if (params.loop && params.centeredSlides) { needsLoopFix = true; }
  2742. } else if (params.freeModeSticky) {
  2743. var nextSlide;
  2744. for (var j = 0; j < snapGrid.length; j += 1) {
  2745. if (snapGrid[j] > -newPosition) {
  2746. nextSlide = j;
  2747. break;
  2748. }
  2749. }
  2750. if (Math.abs(snapGrid[nextSlide] - newPosition) < Math.abs(snapGrid[nextSlide - 1] - newPosition) || swiper.swipeDirection === 'next') {
  2751. newPosition = snapGrid[nextSlide];
  2752. } else {
  2753. newPosition = snapGrid[nextSlide - 1];
  2754. }
  2755. newPosition = -newPosition;
  2756. }
  2757. if (needsLoopFix) {
  2758. swiper.once('transitionEnd', function () {
  2759. swiper.loopFix();
  2760. });
  2761. }
  2762. // Fix duration
  2763. if (swiper.velocity !== 0) {
  2764. if (rtl) {
  2765. momentumDuration = Math.abs((-newPosition - swiper.translate) / swiper.velocity);
  2766. } else {
  2767. momentumDuration = Math.abs((newPosition - swiper.translate) / swiper.velocity);
  2768. }
  2769. } else if (params.freeModeSticky) {
  2770. swiper.slideToClosest();
  2771. return;
  2772. }
  2773. if (params.freeModeMomentumBounce && doBounce) {
  2774. swiper.updateProgress(afterBouncePosition);
  2775. swiper.setTransition(momentumDuration);
  2776. swiper.setTranslate(newPosition);
  2777. swiper.transitionStart(true, swiper.swipeDirection);
  2778. swiper.animating = true;
  2779. $wrapperEl.transitionEnd(function () {
  2780. if (!swiper || swiper.destroyed || !data.allowMomentumBounce) { return; }
  2781. swiper.emit('momentumBounce');
  2782. swiper.setTransition(params.speed);
  2783. swiper.setTranslate(afterBouncePosition);
  2784. $wrapperEl.transitionEnd(function () {
  2785. if (!swiper || swiper.destroyed) { return; }
  2786. swiper.transitionEnd();
  2787. });
  2788. });
  2789. } else if (swiper.velocity) {
  2790. swiper.updateProgress(newPosition);
  2791. swiper.setTransition(momentumDuration);
  2792. swiper.setTranslate(newPosition);
  2793. swiper.transitionStart(true, swiper.swipeDirection);
  2794. if (!swiper.animating) {
  2795. swiper.animating = true;
  2796. $wrapperEl.transitionEnd(function () {
  2797. if (!swiper || swiper.destroyed) { return; }
  2798. swiper.transitionEnd();
  2799. });
  2800. }
  2801. } else {
  2802. swiper.updateProgress(newPosition);
  2803. }
  2804. swiper.updateActiveIndex();
  2805. swiper.updateSlidesClasses();
  2806. } else if (params.freeModeSticky) {
  2807. swiper.slideToClosest();
  2808. return;
  2809. }
  2810. if (!params.freeModeMomentum || timeDiff >= params.longSwipesMs) {
  2811. swiper.updateProgress();
  2812. swiper.updateActiveIndex();
  2813. swiper.updateSlidesClasses();
  2814. }
  2815. return;
  2816. }
  2817. // Find current slide
  2818. var stopIndex = 0;
  2819. var groupSize = swiper.slidesSizesGrid[0];
  2820. for (var i = 0; i < slidesGrid.length; i += params.slidesPerGroup) {
  2821. if (typeof slidesGrid[i + params.slidesPerGroup] !== 'undefined') {
  2822. if (currentPos >= slidesGrid[i] && currentPos < slidesGrid[i + params.slidesPerGroup]) {
  2823. stopIndex = i;
  2824. groupSize = slidesGrid[i + params.slidesPerGroup] - slidesGrid[i];
  2825. }
  2826. } else if (currentPos >= slidesGrid[i]) {
  2827. stopIndex = i;
  2828. groupSize = slidesGrid[slidesGrid.length - 1] - slidesGrid[slidesGrid.length - 2];
  2829. }
  2830. }
  2831. // Find current slide size
  2832. var ratio = (currentPos - slidesGrid[stopIndex]) / groupSize;
  2833. if (timeDiff > params.longSwipesMs) {
  2834. // Long touches
  2835. if (!params.longSwipes) {
  2836. swiper.slideTo(swiper.activeIndex);
  2837. return;
  2838. }
  2839. if (swiper.swipeDirection === 'next') {
  2840. if (ratio >= params.longSwipesRatio) { swiper.slideTo(stopIndex + params.slidesPerGroup); }
  2841. else { swiper.slideTo(stopIndex); }
  2842. }
  2843. if (swiper.swipeDirection === 'prev') {
  2844. if (ratio > (1 - params.longSwipesRatio)) { swiper.slideTo(stopIndex + params.slidesPerGroup); }
  2845. else { swiper.slideTo(stopIndex); }
  2846. }
  2847. } else {
  2848. // Short swipes
  2849. if (!params.shortSwipes) {
  2850. swiper.slideTo(swiper.activeIndex);
  2851. return;
  2852. }
  2853. if (swiper.swipeDirection === 'next') {
  2854. swiper.slideTo(stopIndex + params.slidesPerGroup);
  2855. }
  2856. if (swiper.swipeDirection === 'prev') {
  2857. swiper.slideTo(stopIndex);
  2858. }
  2859. }
  2860. }
  2861. function onResize () {
  2862. var swiper = this;
  2863. var params = swiper.params;
  2864. var el = swiper.el;
  2865. if (el && el.offsetWidth === 0) { return; }
  2866. // Breakpoints
  2867. if (params.breakpoints) {
  2868. swiper.setBreakpoint();
  2869. }
  2870. // Save locks
  2871. var allowSlideNext = swiper.allowSlideNext;
  2872. var allowSlidePrev = swiper.allowSlidePrev;
  2873. var snapGrid = swiper.snapGrid;
  2874. // Disable locks on resize
  2875. swiper.allowSlideNext = true;
  2876. swiper.allowSlidePrev = true;
  2877. swiper.updateSize();
  2878. swiper.updateSlides();
  2879. if (params.freeMode) {
  2880. var newTranslate = Math.min(Math.max(swiper.translate, swiper.maxTranslate()), swiper.minTranslate());
  2881. swiper.setTranslate(newTranslate);
  2882. swiper.updateActiveIndex();
  2883. swiper.updateSlidesClasses();
  2884. if (params.autoHeight) {
  2885. swiper.updateAutoHeight();
  2886. }
  2887. } else {
  2888. swiper.updateSlidesClasses();
  2889. if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !swiper.params.centeredSlides) {
  2890. swiper.slideTo(swiper.slides.length - 1, 0, false, true);
  2891. } else {
  2892. swiper.slideTo(swiper.activeIndex, 0, false, true);
  2893. }
  2894. }
  2895. // Return locks after resize
  2896. swiper.allowSlidePrev = allowSlidePrev;
  2897. swiper.allowSlideNext = allowSlideNext;
  2898. if (swiper.params.watchOverflow && snapGrid !== swiper.snapGrid) {
  2899. swiper.checkOverflow();
  2900. }
  2901. }
  2902. function onClick (e) {
  2903. var swiper = this;
  2904. if (!swiper.allowClick) {
  2905. if (swiper.params.preventClicks) { e.preventDefault(); }
  2906. if (swiper.params.preventClicksPropagation && swiper.animating) {
  2907. e.stopPropagation();
  2908. e.stopImmediatePropagation();
  2909. }
  2910. }
  2911. }
  2912. function attachEvents() {
  2913. var swiper = this;
  2914. var params = swiper.params;
  2915. var touchEvents = swiper.touchEvents;
  2916. var el = swiper.el;
  2917. var wrapperEl = swiper.wrapperEl;
  2918. {
  2919. swiper.onTouchStart = onTouchStart.bind(swiper);
  2920. swiper.onTouchMove = onTouchMove.bind(swiper);
  2921. swiper.onTouchEnd = onTouchEnd.bind(swiper);
  2922. }
  2923. swiper.onClick = onClick.bind(swiper);
  2924. var target = params.touchEventsTarget === 'container' ? el : wrapperEl;
  2925. var capture = !!params.nested;
  2926. // Touch Events
  2927. {
  2928. if (!Support.touch && (Support.pointerEvents || Support.prefixedPointerEvents)) {
  2929. target.addEventListener(touchEvents.start, swiper.onTouchStart, false);
  2930. doc.addEventListener(touchEvents.move, swiper.onTouchMove, capture);
  2931. doc.addEventListener(touchEvents.end, swiper.onTouchEnd, false);
  2932. } else {
  2933. if (Support.touch) {
  2934. var passiveListener = touchEvents.start === 'touchstart' && Support.passiveListener && params.passiveListeners ? { passive: true, capture: false } : false;
  2935. target.addEventListener(touchEvents.start, swiper.onTouchStart, passiveListener);
  2936. target.addEventListener(touchEvents.move, swiper.onTouchMove, Support.passiveListener ? { passive: false, capture: capture } : capture);
  2937. target.addEventListener(touchEvents.end, swiper.onTouchEnd, passiveListener);
  2938. }
  2939. if ((params.simulateTouch && !Device.ios && !Device.android) || (params.simulateTouch && !Support.touch && Device.ios)) {
  2940. target.addEventListener('mousedown', swiper.onTouchStart, false);
  2941. doc.addEventListener('mousemove', swiper.onTouchMove, capture);
  2942. doc.addEventListener('mouseup', swiper.onTouchEnd, false);
  2943. }
  2944. }
  2945. // Prevent Links Clicks
  2946. if (params.preventClicks || params.preventClicksPropagation) {
  2947. target.addEventListener('click', swiper.onClick, true);
  2948. }
  2949. }
  2950. // Resize handler
  2951. swiper.on((Device.ios || Device.android ? 'resize orientationchange observerUpdate' : 'resize observerUpdate'), onResize, true);
  2952. }
  2953. function detachEvents() {
  2954. var swiper = this;
  2955. var params = swiper.params;
  2956. var touchEvents = swiper.touchEvents;
  2957. var el = swiper.el;
  2958. var wrapperEl = swiper.wrapperEl;
  2959. var target = params.touchEventsTarget === 'container' ? el : wrapperEl;
  2960. var capture = !!params.nested;
  2961. // Touch Events
  2962. {
  2963. if (!Support.touch && (Support.pointerEvents || Support.prefixedPointerEvents)) {
  2964. target.removeEventListener(touchEvents.start, swiper.onTouchStart, false);
  2965. doc.removeEventListener(touchEvents.move, swiper.onTouchMove, capture);
  2966. doc.removeEventListener(touchEvents.end, swiper.onTouchEnd, false);
  2967. } else {
  2968. if (Support.touch) {
  2969. var passiveListener = touchEvents.start === 'onTouchStart' && Support.passiveListener && params.passiveListeners ? { passive: true, capture: false } : false;
  2970. target.removeEventListener(touchEvents.start, swiper.onTouchStart, passiveListener);
  2971. target.removeEventListener(touchEvents.move, swiper.onTouchMove, capture);
  2972. target.removeEventListener(touchEvents.end, swiper.onTouchEnd, passiveListener);
  2973. }
  2974. if ((params.simulateTouch && !Device.ios && !Device.android) || (params.simulateTouch && !Support.touch && Device.ios)) {
  2975. target.removeEventListener('mousedown', swiper.onTouchStart, false);
  2976. doc.removeEventListener('mousemove', swiper.onTouchMove, capture);
  2977. doc.removeEventListener('mouseup', swiper.onTouchEnd, false);
  2978. }
  2979. }
  2980. // Prevent Links Clicks
  2981. if (params.preventClicks || params.preventClicksPropagation) {
  2982. target.removeEventListener('click', swiper.onClick, true);
  2983. }
  2984. }
  2985. // Resize handler
  2986. swiper.off((Device.ios || Device.android ? 'resize orientationchange observerUpdate' : 'resize observerUpdate'), onResize);
  2987. }
  2988. var events = {
  2989. attachEvents: attachEvents,
  2990. detachEvents: detachEvents,
  2991. };
  2992. function setBreakpoint () {
  2993. var swiper = this;
  2994. var activeIndex = swiper.activeIndex;
  2995. var initialized = swiper.initialized;
  2996. var loopedSlides = swiper.loopedSlides; if ( loopedSlides === void 0 ) loopedSlides = 0;
  2997. var params = swiper.params;
  2998. var breakpoints = params.breakpoints;
  2999. if (!breakpoints || (breakpoints && Object.keys(breakpoints).length === 0)) { return; }
  3000. // Set breakpoint for window width and update parameters
  3001. var breakpoint = swiper.getBreakpoint(breakpoints);
  3002. if (breakpoint && swiper.currentBreakpoint !== breakpoint) {
  3003. var breakPointsParams = breakpoint in breakpoints ? breakpoints[breakpoint] : swiper.originalParams;
  3004. var needsReLoop = params.loop && (breakPointsParams.slidesPerView !== params.slidesPerView);
  3005. Utils.extend(swiper.params, breakPointsParams);
  3006. Utils.extend(swiper, {
  3007. allowTouchMove: swiper.params.allowTouchMove,
  3008. allowSlideNext: swiper.params.allowSlideNext,
  3009. allowSlidePrev: swiper.params.allowSlidePrev,
  3010. });
  3011. swiper.currentBreakpoint = breakpoint;
  3012. if (needsReLoop && initialized) {
  3013. swiper.loopDestroy();
  3014. swiper.loopCreate();
  3015. swiper.updateSlides();
  3016. swiper.slideTo((activeIndex - loopedSlides) + swiper.loopedSlides, 0, false);
  3017. }
  3018. swiper.emit('breakpoint', breakPointsParams);
  3019. }
  3020. }
  3021. function getBreakpoint (breakpoints) {
  3022. // Get breakpoint for window width
  3023. if (!breakpoints) { return undefined; }
  3024. var breakpoint = false;
  3025. var points = [];
  3026. Object.keys(breakpoints).forEach(function (point) {
  3027. points.push(point);
  3028. });
  3029. points.sort(function (a, b) { return parseInt(a, 10) - parseInt(b, 10); });
  3030. for (var i = 0; i < points.length; i += 1) {
  3031. var point = points[i];
  3032. if (point >= win.innerWidth && !breakpoint) {
  3033. breakpoint = point;
  3034. }
  3035. }
  3036. return breakpoint || 'max';
  3037. }
  3038. var breakpoints = { setBreakpoint: setBreakpoint, getBreakpoint: getBreakpoint };
  3039. var Browser = (function Browser() {
  3040. function isSafari() {
  3041. var ua = win.navigator.userAgent.toLowerCase();
  3042. return (ua.indexOf('safari') >= 0 && ua.indexOf('chrome') < 0 && ua.indexOf('android') < 0);
  3043. }
  3044. return {
  3045. isIE: !!win.navigator.userAgent.match(/Trident/g) || !!win.navigator.userAgent.match(/MSIE/g),
  3046. isSafari: isSafari(),
  3047. isUiWebView: /(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(win.navigator.userAgent),
  3048. };
  3049. }());
  3050. function addClasses () {
  3051. var swiper = this;
  3052. var classNames = swiper.classNames;
  3053. var params = swiper.params;
  3054. var rtl = swiper.rtl;
  3055. var $el = swiper.$el;
  3056. var suffixes = [];
  3057. suffixes.push(params.direction);
  3058. if (params.freeMode) {
  3059. suffixes.push('free-mode');
  3060. }
  3061. if (!Support.flexbox) {
  3062. suffixes.push('no-flexbox');
  3063. }
  3064. if (params.autoHeight) {
  3065. suffixes.push('autoheight');
  3066. }
  3067. if (rtl) {
  3068. suffixes.push('rtl');
  3069. }
  3070. if (params.slidesPerColumn > 1) {
  3071. suffixes.push('multirow');
  3072. }
  3073. if (Device.android) {
  3074. suffixes.push('android');
  3075. }
  3076. if (Device.ios) {
  3077. suffixes.push('ios');
  3078. }
  3079. // WP8 Touch Events Fix
  3080. if (Browser.isIE && (Support.pointerEvents || Support.prefixedPointerEvents)) {
  3081. suffixes.push(("wp8-" + (params.direction)));
  3082. }
  3083. suffixes.forEach(function (suffix) {
  3084. classNames.push(params.containerModifierClass + suffix);
  3085. });
  3086. $el.addClass(classNames.join(' '));
  3087. }
  3088. function removeClasses () {
  3089. var swiper = this;
  3090. var $el = swiper.$el;
  3091. var classNames = swiper.classNames;
  3092. $el.removeClass(classNames.join(' '));
  3093. }
  3094. var classes = { addClasses: addClasses, removeClasses: removeClasses };
  3095. function loadImage (imageEl, src, srcset, sizes, checkForComplete, callback) {
  3096. var image;
  3097. function onReady() {
  3098. if (callback) { callback(); }
  3099. }
  3100. if (!imageEl.complete || !checkForComplete) {
  3101. if (src) {
  3102. image = new win.Image();
  3103. image.onload = onReady;
  3104. image.onerror = onReady;
  3105. if (sizes) {
  3106. image.sizes = sizes;
  3107. }
  3108. if (srcset) {
  3109. image.srcset = srcset;
  3110. }
  3111. if (src) {
  3112. image.src = src;
  3113. }
  3114. } else {
  3115. onReady();
  3116. }
  3117. } else {
  3118. // image already loaded...
  3119. onReady();
  3120. }
  3121. }
  3122. function preloadImages () {
  3123. var swiper = this;
  3124. swiper.imagesToLoad = swiper.$el.find('img');
  3125. function onReady() {
  3126. if (typeof swiper === 'undefined' || swiper === null || !swiper || swiper.destroyed) { return; }
  3127. if (swiper.imagesLoaded !== undefined) { swiper.imagesLoaded += 1; }
  3128. if (swiper.imagesLoaded === swiper.imagesToLoad.length) {
  3129. if (swiper.params.updateOnImagesReady) { swiper.update(); }
  3130. swiper.emit('imagesReady');
  3131. }
  3132. }
  3133. for (var i = 0; i < swiper.imagesToLoad.length; i += 1) {
  3134. var imageEl = swiper.imagesToLoad[i];
  3135. swiper.loadImage(
  3136. imageEl,
  3137. imageEl.currentSrc || imageEl.getAttribute('src'),
  3138. imageEl.srcset || imageEl.getAttribute('srcset'),
  3139. imageEl.sizes || imageEl.getAttribute('sizes'),
  3140. true,
  3141. onReady
  3142. );
  3143. }
  3144. }
  3145. var images = {
  3146. loadImage: loadImage,
  3147. preloadImages: preloadImages,
  3148. };
  3149. function checkOverflow() {
  3150. var swiper = this;
  3151. var wasLocked = swiper.isLocked;
  3152. swiper.isLocked = swiper.snapGrid.length === 1;
  3153. swiper.allowSlideNext = !swiper.isLocked;
  3154. swiper.allowSlidePrev = !swiper.isLocked;
  3155. // events
  3156. if (wasLocked !== swiper.isLocked) { swiper.emit(swiper.isLocked ? 'lock' : 'unlock'); }
  3157. if (wasLocked && wasLocked !== swiper.isLocked) {
  3158. swiper.isEnd = false;
  3159. swiper.navigation.update();
  3160. }
  3161. }
  3162. var checkOverflow$1 = { checkOverflow: checkOverflow };
  3163. var defaults = {
  3164. init: true,
  3165. direction: 'horizontal',
  3166. touchEventsTarget: 'container',
  3167. initialSlide: 0,
  3168. speed: 300,
  3169. //
  3170. preventIntercationOnTransition: false,
  3171. // To support iOS's swipe-to-go-back gesture (when being used in-app, with UIWebView).
  3172. iOSEdgeSwipeDetection: false,
  3173. iOSEdgeSwipeThreshold: 20,
  3174. // Free mode
  3175. freeMode: false,
  3176. freeModeMomentum: true,
  3177. freeModeMomentumRatio: 1,
  3178. freeModeMomentumBounce: true,
  3179. freeModeMomentumBounceRatio: 1,
  3180. freeModeMomentumVelocityRatio: 1,
  3181. freeModeSticky: false,
  3182. freeModeMinimumVelocity: 0.02,
  3183. // Autoheight
  3184. autoHeight: false,
  3185. // Set wrapper width
  3186. setWrapperSize: false,
  3187. // Virtual Translate
  3188. virtualTranslate: false,
  3189. // Effects
  3190. effect: 'slide', // 'slide' or 'fade' or 'cube' or 'coverflow' or 'flip'
  3191. // Breakpoints
  3192. breakpoints: undefined,
  3193. // Slides grid
  3194. spaceBetween: 0,
  3195. slidesPerView: 1,
  3196. slidesPerColumn: 1,
  3197. slidesPerColumnFill: 'column',
  3198. slidesPerGroup: 1,
  3199. centeredSlides: false,
  3200. slidesOffsetBefore: 0, // in px
  3201. slidesOffsetAfter: 0, // in px
  3202. normalizeSlideIndex: true,
  3203. // Disable swiper and hide navigation when container not overflow
  3204. watchOverflow: false,
  3205. // Round length
  3206. roundLengths: false,
  3207. // Touches
  3208. touchRatio: 1,
  3209. touchAngle: 45,
  3210. simulateTouch: true,
  3211. shortSwipes: true,
  3212. longSwipes: true,
  3213. longSwipesRatio: 0.5,
  3214. longSwipesMs: 300,
  3215. followFinger: true,
  3216. allowTouchMove: true,
  3217. threshold: 0,
  3218. touchMoveStopPropagation: true,
  3219. touchReleaseOnEdges: false,
  3220. // Unique Navigation Elements
  3221. uniqueNavElements: true,
  3222. // Resistance
  3223. resistance: true,
  3224. resistanceRatio: 0.85,
  3225. // Progress
  3226. watchSlidesProgress: false,
  3227. watchSlidesVisibility: false,
  3228. // Cursor
  3229. grabCursor: false,
  3230. // Clicks
  3231. preventClicks: true,
  3232. preventClicksPropagation: true,
  3233. slideToClickedSlide: false,
  3234. // Images
  3235. preloadImages: true,
  3236. updateOnImagesReady: true,
  3237. // loop
  3238. loop: false,
  3239. loopAdditionalSlides: 0,
  3240. loopedSlides: null,
  3241. loopFillGroupWithBlank: false,
  3242. // Swiping/no swiping
  3243. allowSlidePrev: true,
  3244. allowSlideNext: true,
  3245. swipeHandler: null, // '.swipe-handler',
  3246. noSwiping: true,
  3247. noSwipingClass: 'swiper-no-swiping',
  3248. noSwipingSelector: null,
  3249. // Passive Listeners
  3250. passiveListeners: true,
  3251. // NS
  3252. containerModifierClass: 'swiper-container-', // NEW
  3253. slideClass: 'swiper-slide',
  3254. slideBlankClass: 'swiper-slide-invisible-blank',
  3255. slideActiveClass: 'swiper-slide-active',
  3256. slideDuplicateActiveClass: 'swiper-slide-duplicate-active',
  3257. slideVisibleClass: 'swiper-slide-visible',
  3258. slideDuplicateClass: 'swiper-slide-duplicate',
  3259. slideNextClass: 'swiper-slide-next',
  3260. slideDuplicateNextClass: 'swiper-slide-duplicate-next',
  3261. slidePrevClass: 'swiper-slide-prev',
  3262. slideDuplicatePrevClass: 'swiper-slide-duplicate-prev',
  3263. wrapperClass: 'swiper-wrapper',
  3264. // Callbacks
  3265. runCallbacksOnInit: true,
  3266. };
  3267. var prototypes = {
  3268. update: update,
  3269. translate: translate,
  3270. transition: transition$1,
  3271. slide: slide,
  3272. loop: loop,
  3273. grabCursor: grabCursor,
  3274. manipulation: manipulation,
  3275. events: events,
  3276. breakpoints: breakpoints,
  3277. checkOverflow: checkOverflow$1,
  3278. classes: classes,
  3279. images: images,
  3280. };
  3281. var extendedDefaults = {};
  3282. var Swiper = (function (SwiperClass$$1) {
  3283. function Swiper() {
  3284. var assign;
  3285. var args = [], len = arguments.length;
  3286. while ( len-- ) args[ len ] = arguments[ len ];
  3287. var el;
  3288. var params;
  3289. if (args.length === 1 && args[0].constructor && args[0].constructor === Object) {
  3290. params = args[0];
  3291. } else {
  3292. (assign = args, el = assign[0], params = assign[1]);
  3293. }
  3294. if (!params) { params = {}; }
  3295. params = Utils.extend({}, params);
  3296. if (el && !params.el) { params.el = el; }
  3297. SwiperClass$$1.call(this, params);
  3298. Object.keys(prototypes).forEach(function (prototypeGroup) {
  3299. Object.keys(prototypes[prototypeGroup]).forEach(function (protoMethod) {
  3300. if (!Swiper.prototype[protoMethod]) {
  3301. Swiper.prototype[protoMethod] = prototypes[prototypeGroup][protoMethod];
  3302. }
  3303. });
  3304. });
  3305. // Swiper Instance
  3306. var swiper = this;
  3307. if (typeof swiper.modules === 'undefined') {
  3308. swiper.modules = {};
  3309. }
  3310. Object.keys(swiper.modules).forEach(function (moduleName) {
  3311. var module = swiper.modules[moduleName];
  3312. if (module.params) {
  3313. var moduleParamName = Object.keys(module.params)[0];
  3314. var moduleParams = module.params[moduleParamName];
  3315. if (typeof moduleParams !== 'object') { return; }
  3316. if (!(moduleParamName in params && 'enabled' in moduleParams)) { return; }
  3317. if (params[moduleParamName] === true) {
  3318. params[moduleParamName] = { enabled: true };
  3319. }
  3320. if (
  3321. typeof params[moduleParamName] === 'object' &&
  3322. !('enabled' in params[moduleParamName])
  3323. ) {
  3324. params[moduleParamName].enabled = true;
  3325. }
  3326. if (!params[moduleParamName]) { params[moduleParamName] = { enabled: false }; }
  3327. }
  3328. });
  3329. // Extend defaults with modules params
  3330. var swiperParams = Utils.extend({}, defaults);
  3331. swiper.useModulesParams(swiperParams);
  3332. // Extend defaults with passed params
  3333. swiper.params = Utils.extend({}, swiperParams, extendedDefaults, params);
  3334. swiper.originalParams = Utils.extend({}, swiper.params);
  3335. swiper.passedParams = Utils.extend({}, params);
  3336. // Save Dom lib
  3337. swiper.$ = $;
  3338. // Find el
  3339. var $el = $(swiper.params.el);
  3340. el = $el[0];
  3341. if (!el) {
  3342. return undefined;
  3343. }
  3344. if ($el.length > 1) {
  3345. var swipers = [];
  3346. $el.each(function (index, containerEl) {
  3347. var newParams = Utils.extend({}, params, { el: containerEl });
  3348. swipers.push(new Swiper(newParams));
  3349. });
  3350. return swipers;
  3351. }
  3352. el.swiper = swiper;
  3353. $el.data('swiper', swiper);
  3354. // Find Wrapper
  3355. var $wrapperEl = $el.children(("." + (swiper.params.wrapperClass)));
  3356. // Extend Swiper
  3357. Utils.extend(swiper, {
  3358. $el: $el,
  3359. el: el,
  3360. $wrapperEl: $wrapperEl,
  3361. wrapperEl: $wrapperEl[0],
  3362. // Classes
  3363. classNames: [],
  3364. // Slides
  3365. slides: $(),
  3366. slidesGrid: [],
  3367. snapGrid: [],
  3368. slidesSizesGrid: [],
  3369. // isDirection
  3370. isHorizontal: function isHorizontal() {
  3371. return swiper.params.direction === 'horizontal';
  3372. },
  3373. isVertical: function isVertical() {
  3374. return swiper.params.direction === 'vertical';
  3375. },
  3376. // RTL
  3377. rtl: (el.dir.toLowerCase() === 'rtl' || $el.css('direction') === 'rtl'),
  3378. rtlTranslate: swiper.params.direction === 'horizontal' && (el.dir.toLowerCase() === 'rtl' || $el.css('direction') === 'rtl'),
  3379. wrongRTL: $wrapperEl.css('display') === '-webkit-box',
  3380. // Indexes
  3381. activeIndex: 0,
  3382. realIndex: 0,
  3383. //
  3384. isBeginning: true,
  3385. isEnd: false,
  3386. // Props
  3387. translate: 0,
  3388. previousTranslate: 0,
  3389. progress: 0,
  3390. velocity: 0,
  3391. animating: false,
  3392. // Locks
  3393. allowSlideNext: swiper.params.allowSlideNext,
  3394. allowSlidePrev: swiper.params.allowSlidePrev,
  3395. // Touch Events
  3396. touchEvents: (function touchEvents() {
  3397. var touch = ['touchstart', 'touchmove', 'touchend'];
  3398. var desktop = ['mousedown', 'mousemove', 'mouseup'];
  3399. if (Support.pointerEvents) {
  3400. desktop = ['pointerdown', 'pointermove', 'pointerup'];
  3401. } else if (Support.prefixedPointerEvents) {
  3402. desktop = ['MSPointerDown', 'MSPointerMove', 'MSPointerUp'];
  3403. }
  3404. swiper.touchEventsTouch = {
  3405. start: touch[0],
  3406. move: touch[1],
  3407. end: touch[2],
  3408. };
  3409. swiper.touchEventsDesktop = {
  3410. start: desktop[0],
  3411. move: desktop[1],
  3412. end: desktop[2],
  3413. };
  3414. return Support.touch || !swiper.params.simulateTouch ? swiper.touchEventsTouch : swiper.touchEventsDesktop;
  3415. }()),
  3416. touchEventsData: {
  3417. isTouched: undefined,
  3418. isMoved: undefined,
  3419. allowTouchCallbacks: undefined,
  3420. touchStartTime: undefined,
  3421. isScrolling: undefined,
  3422. currentTranslate: undefined,
  3423. startTranslate: undefined,
  3424. allowThresholdMove: undefined,
  3425. // Form elements to match
  3426. formElements: 'input, select, option, textarea, button, video',
  3427. // Last click time
  3428. lastClickTime: Utils.now(),
  3429. clickTimeout: undefined,
  3430. // Velocities
  3431. velocities: [],
  3432. allowMomentumBounce: undefined,
  3433. isTouchEvent: undefined,
  3434. startMoving: undefined,
  3435. },
  3436. // Clicks
  3437. allowClick: true,
  3438. // Touches
  3439. allowTouchMove: swiper.params.allowTouchMove,
  3440. touches: {
  3441. startX: 0,
  3442. startY: 0,
  3443. currentX: 0,
  3444. currentY: 0,
  3445. diff: 0,
  3446. },
  3447. // Images
  3448. imagesToLoad: [],
  3449. imagesLoaded: 0,
  3450. });
  3451. // Install Modules
  3452. swiper.useModules();
  3453. // Init
  3454. if (swiper.params.init) {
  3455. swiper.init();
  3456. }
  3457. // Return app instance
  3458. return swiper;
  3459. }
  3460. if ( SwiperClass$$1 ) Swiper.__proto__ = SwiperClass$$1;
  3461. Swiper.prototype = Object.create( SwiperClass$$1 && SwiperClass$$1.prototype );
  3462. Swiper.prototype.constructor = Swiper;
  3463. var staticAccessors = { extendedDefaults: { configurable: true },defaults: { configurable: true },Class: { configurable: true },$: { configurable: true } };
  3464. Swiper.prototype.slidesPerViewDynamic = function slidesPerViewDynamic () {
  3465. var swiper = this;
  3466. var params = swiper.params;
  3467. var slides = swiper.slides;
  3468. var slidesGrid = swiper.slidesGrid;
  3469. var swiperSize = swiper.size;
  3470. var activeIndex = swiper.activeIndex;
  3471. var spv = 1;
  3472. if (params.centeredSlides) {
  3473. var slideSize = slides[activeIndex].swiperSlideSize;
  3474. var breakLoop;
  3475. for (var i = activeIndex + 1; i < slides.length; i += 1) {
  3476. if (slides[i] && !breakLoop) {
  3477. slideSize += slides[i].swiperSlideSize;
  3478. spv += 1;
  3479. if (slideSize > swiperSize) { breakLoop = true; }
  3480. }
  3481. }
  3482. for (var i$1 = activeIndex - 1; i$1 >= 0; i$1 -= 1) {
  3483. if (slides[i$1] && !breakLoop) {
  3484. slideSize += slides[i$1].swiperSlideSize;
  3485. spv += 1;
  3486. if (slideSize > swiperSize) { breakLoop = true; }
  3487. }
  3488. }
  3489. } else {
  3490. for (var i$2 = activeIndex + 1; i$2 < slides.length; i$2 += 1) {
  3491. if (slidesGrid[i$2] - slidesGrid[activeIndex] < swiperSize) {
  3492. spv += 1;
  3493. }
  3494. }
  3495. }
  3496. return spv;
  3497. };
  3498. Swiper.prototype.update = function update$$1 () {
  3499. var swiper = this;
  3500. if (!swiper || swiper.destroyed) { return; }
  3501. var snapGrid = swiper.snapGrid;
  3502. var params = swiper.params;
  3503. // Breakpoints
  3504. if (params.breakpoints) {
  3505. swiper.setBreakpoint();
  3506. }
  3507. swiper.updateSize();
  3508. swiper.updateSlides();
  3509. swiper.updateProgress();
  3510. swiper.updateSlidesClasses();
  3511. function setTranslate() {
  3512. var translateValue = swiper.rtlTranslate ? swiper.translate * -1 : swiper.translate;
  3513. var newTranslate = Math.min(Math.max(translateValue, swiper.maxTranslate()), swiper.minTranslate());
  3514. swiper.setTranslate(newTranslate);
  3515. swiper.updateActiveIndex();
  3516. swiper.updateSlidesClasses();
  3517. }
  3518. var translated;
  3519. if (swiper.params.freeMode) {
  3520. setTranslate();
  3521. if (swiper.params.autoHeight) {
  3522. swiper.updateAutoHeight();
  3523. }
  3524. } else {
  3525. if ((swiper.params.slidesPerView === 'auto' || swiper.params.slidesPerView > 1) && swiper.isEnd && !swiper.params.centeredSlides) {
  3526. translated = swiper.slideTo(swiper.slides.length - 1, 0, false, true);
  3527. } else {
  3528. translated = swiper.slideTo(swiper.activeIndex, 0, false, true);
  3529. }
  3530. if (!translated) {
  3531. setTranslate();
  3532. }
  3533. }
  3534. if (params.watchOverflow && snapGrid !== swiper.snapGrid) {
  3535. swiper.checkOverflow();
  3536. }
  3537. swiper.emit('update');
  3538. };
  3539. Swiper.prototype.init = function init () {
  3540. var swiper = this;
  3541. if (swiper.initialized) { return; }
  3542. swiper.emit('beforeInit');
  3543. // Set breakpoint
  3544. if (swiper.params.breakpoints) {
  3545. swiper.setBreakpoint();
  3546. }
  3547. // Add Classes
  3548. swiper.addClasses();
  3549. // Create loop
  3550. if (swiper.params.loop) {
  3551. swiper.loopCreate();
  3552. }
  3553. // Update size
  3554. swiper.updateSize();
  3555. // Update slides
  3556. swiper.updateSlides();
  3557. if (swiper.params.watchOverflow) {
  3558. swiper.checkOverflow();
  3559. }
  3560. // Set Grab Cursor
  3561. if (swiper.params.grabCursor) {
  3562. swiper.setGrabCursor();
  3563. }
  3564. if (swiper.params.preloadImages) {
  3565. swiper.preloadImages();
  3566. }
  3567. // Slide To Initial Slide
  3568. if (swiper.params.loop) {
  3569. swiper.slideTo(swiper.params.initialSlide + swiper.loopedSlides, 0, swiper.params.runCallbacksOnInit);
  3570. } else {
  3571. swiper.slideTo(swiper.params.initialSlide, 0, swiper.params.runCallbacksOnInit);
  3572. }
  3573. // Attach events
  3574. swiper.attachEvents();
  3575. // Init Flag
  3576. swiper.initialized = true;
  3577. // Emit
  3578. swiper.emit('init');
  3579. };
  3580. Swiper.prototype.destroy = function destroy (deleteInstance, cleanStyles) {
  3581. if ( deleteInstance === void 0 ) deleteInstance = true;
  3582. if ( cleanStyles === void 0 ) cleanStyles = true;
  3583. var swiper = this;
  3584. var params = swiper.params;
  3585. var $el = swiper.$el;
  3586. var $wrapperEl = swiper.$wrapperEl;
  3587. var slides = swiper.slides;
  3588. if (typeof swiper.params === 'undefined' || swiper.destroyed) {
  3589. return null;
  3590. }
  3591. swiper.emit('beforeDestroy');
  3592. // Init Flag
  3593. swiper.initialized = false;
  3594. // Detach events
  3595. swiper.detachEvents();
  3596. // Destroy loop
  3597. if (params.loop) {
  3598. swiper.loopDestroy();
  3599. }
  3600. // Cleanup styles
  3601. if (cleanStyles) {
  3602. swiper.removeClasses();
  3603. $el.removeAttr('style');
  3604. $wrapperEl.removeAttr('style');
  3605. if (slides && slides.length) {
  3606. slides
  3607. .removeClass([
  3608. params.slideVisibleClass,
  3609. params.slideActiveClass,
  3610. params.slideNextClass,
  3611. params.slidePrevClass ].join(' '))
  3612. .removeAttr('style')
  3613. .removeAttr('data-swiper-slide-index')
  3614. .removeAttr('data-swiper-column')
  3615. .removeAttr('data-swiper-row');
  3616. }
  3617. }
  3618. swiper.emit('destroy');
  3619. // Detach emitter events
  3620. Object.keys(swiper.eventsListeners).forEach(function (eventName) {
  3621. swiper.off(eventName);
  3622. });
  3623. if (deleteInstance !== false) {
  3624. swiper.$el[0].swiper = null;
  3625. swiper.$el.data('swiper', null);
  3626. Utils.deleteProps(swiper);
  3627. }
  3628. swiper.destroyed = true;
  3629. return null;
  3630. };
  3631. Swiper.extendDefaults = function extendDefaults (newDefaults) {
  3632. Utils.extend(extendedDefaults, newDefaults);
  3633. };
  3634. staticAccessors.extendedDefaults.get = function () {
  3635. return extendedDefaults;
  3636. };
  3637. staticAccessors.defaults.get = function () {
  3638. return defaults;
  3639. };
  3640. staticAccessors.Class.get = function () {
  3641. return SwiperClass$$1;
  3642. };
  3643. staticAccessors.$.get = function () {
  3644. return $;
  3645. };
  3646. Object.defineProperties( Swiper, staticAccessors );
  3647. return Swiper;
  3648. }(SwiperClass));
  3649. var Device$1 = {
  3650. name: 'device',
  3651. proto: {
  3652. device: Device,
  3653. },
  3654. static: {
  3655. device: Device,
  3656. },
  3657. };
  3658. var Support$1 = {
  3659. name: 'support',
  3660. proto: {
  3661. support: Support,
  3662. },
  3663. static: {
  3664. support: Support,
  3665. },
  3666. };
  3667. var Browser$1 = {
  3668. name: 'browser',
  3669. proto: {
  3670. browser: Browser,
  3671. },
  3672. static: {
  3673. browser: Browser,
  3674. },
  3675. };
  3676. var Resize = {
  3677. name: 'resize',
  3678. create: function create() {
  3679. var swiper = this;
  3680. Utils.extend(swiper, {
  3681. resize: {
  3682. resizeHandler: function resizeHandler() {
  3683. if (!swiper || swiper.destroyed || !swiper.initialized) { return; }
  3684. swiper.emit('beforeResize');
  3685. swiper.emit('resize');
  3686. },
  3687. orientationChangeHandler: function orientationChangeHandler() {
  3688. if (!swiper || swiper.destroyed || !swiper.initialized) { return; }
  3689. swiper.emit('orientationchange');
  3690. },
  3691. },
  3692. });
  3693. },
  3694. on: {
  3695. init: function init() {
  3696. var swiper = this;
  3697. // Emit resize
  3698. win.addEventListener('resize', swiper.resize.resizeHandler);
  3699. // Emit orientationchange
  3700. win.addEventListener('orientationchange', swiper.resize.orientationChangeHandler);
  3701. },
  3702. destroy: function destroy() {
  3703. var swiper = this;
  3704. win.removeEventListener('resize', swiper.resize.resizeHandler);
  3705. win.removeEventListener('orientationchange', swiper.resize.orientationChangeHandler);
  3706. },
  3707. },
  3708. };
  3709. var Observer = {
  3710. func: win.MutationObserver || win.WebkitMutationObserver,
  3711. attach: function attach(target, options) {
  3712. if ( options === void 0 ) options = {};
  3713. var swiper = this;
  3714. var ObserverFunc = Observer.func;
  3715. var observer = new ObserverFunc(function (mutations) {
  3716. mutations.forEach(function (mutation) {
  3717. swiper.emit('observerUpdate', mutation);
  3718. });
  3719. });
  3720. observer.observe(target, {
  3721. attributes: typeof options.attributes === 'undefined' ? true : options.attributes,
  3722. childList: typeof options.childList === 'undefined' ? true : options.childList,
  3723. characterData: typeof options.characterData === 'undefined' ? true : options.characterData,
  3724. });
  3725. swiper.observer.observers.push(observer);
  3726. },
  3727. init: function init() {
  3728. var swiper = this;
  3729. if (!Support.observer || !swiper.params.observer) { return; }
  3730. if (swiper.params.observeParents) {
  3731. var containerParents = swiper.$el.parents();
  3732. for (var i = 0; i < containerParents.length; i += 1) {
  3733. swiper.observer.attach(containerParents[i]);
  3734. }
  3735. }
  3736. // Observe container
  3737. swiper.observer.attach(swiper.$el[0], { childList: false });
  3738. // Observe wrapper
  3739. swiper.observer.attach(swiper.$wrapperEl[0], { attributes: false });
  3740. },
  3741. destroy: function destroy() {
  3742. var swiper = this;
  3743. swiper.observer.observers.forEach(function (observer) {
  3744. observer.disconnect();
  3745. });
  3746. swiper.observer.observers = [];
  3747. },
  3748. };
  3749. var Observer$1 = {
  3750. name: 'observer',
  3751. params: {
  3752. observer: false,
  3753. observeParents: false,
  3754. },
  3755. create: function create() {
  3756. var swiper = this;
  3757. Utils.extend(swiper, {
  3758. observer: {
  3759. init: Observer.init.bind(swiper),
  3760. attach: Observer.attach.bind(swiper),
  3761. destroy: Observer.destroy.bind(swiper),
  3762. observers: [],
  3763. },
  3764. });
  3765. },
  3766. on: {
  3767. init: function init() {
  3768. var swiper = this;
  3769. swiper.observer.init();
  3770. },
  3771. destroy: function destroy() {
  3772. var swiper = this;
  3773. swiper.observer.destroy();
  3774. },
  3775. },
  3776. };
  3777. var Virtual = {
  3778. update: function update(force) {
  3779. var swiper = this;
  3780. var ref = swiper.params;
  3781. var slidesPerView = ref.slidesPerView;
  3782. var slidesPerGroup = ref.slidesPerGroup;
  3783. var centeredSlides = ref.centeredSlides;
  3784. var ref$1 = swiper.virtual;
  3785. var previousFrom = ref$1.from;
  3786. var previousTo = ref$1.to;
  3787. var slides = ref$1.slides;
  3788. var previousSlidesGrid = ref$1.slidesGrid;
  3789. var renderSlide = ref$1.renderSlide;
  3790. var previousOffset = ref$1.offset;
  3791. swiper.updateActiveIndex();
  3792. var activeIndex = swiper.activeIndex || 0;
  3793. var offsetProp;
  3794. if (swiper.rtlTranslate) { offsetProp = 'right'; }
  3795. else { offsetProp = swiper.isHorizontal() ? 'left' : 'top'; }
  3796. var slidesAfter;
  3797. var slidesBefore;
  3798. if (centeredSlides) {
  3799. slidesAfter = Math.floor(slidesPerView / 2) + slidesPerGroup;
  3800. slidesBefore = Math.floor(slidesPerView / 2) + slidesPerGroup;
  3801. } else {
  3802. slidesAfter = slidesPerView + (slidesPerGroup - 1);
  3803. slidesBefore = slidesPerGroup;
  3804. }
  3805. var from = Math.max((activeIndex || 0) - slidesBefore, 0);
  3806. var to = Math.min((activeIndex || 0) + slidesAfter, slides.length - 1);
  3807. var offset = (swiper.slidesGrid[from] || 0) - (swiper.slidesGrid[0] || 0);
  3808. Utils.extend(swiper.virtual, {
  3809. from: from,
  3810. to: to,
  3811. offset: offset,
  3812. slidesGrid: swiper.slidesGrid,
  3813. });
  3814. function onRendered() {
  3815. swiper.updateSlides();
  3816. swiper.updateProgress();
  3817. swiper.updateSlidesClasses();
  3818. if (swiper.lazy && swiper.params.lazy.enabled) {
  3819. swiper.lazy.load();
  3820. }
  3821. }
  3822. if (previousFrom === from && previousTo === to && !force) {
  3823. if (swiper.slidesGrid !== previousSlidesGrid && offset !== previousOffset) {
  3824. swiper.slides.css(offsetProp, (offset + "px"));
  3825. }
  3826. swiper.updateProgress();
  3827. return;
  3828. }
  3829. if (swiper.params.virtual.renderExternal) {
  3830. swiper.params.virtual.renderExternal.call(swiper, {
  3831. offset: offset,
  3832. from: from,
  3833. to: to,
  3834. slides: (function getSlides() {
  3835. var slidesToRender = [];
  3836. for (var i = from; i <= to; i += 1) {
  3837. slidesToRender.push(slides[i]);
  3838. }
  3839. return slidesToRender;
  3840. }()),
  3841. });
  3842. onRendered();
  3843. return;
  3844. }
  3845. var prependIndexes = [];
  3846. var appendIndexes = [];
  3847. if (force) {
  3848. swiper.$wrapperEl.find(("." + (swiper.params.slideClass))).remove();
  3849. } else {
  3850. for (var i = previousFrom; i <= previousTo; i += 1) {
  3851. if (i < from || i > to) {
  3852. swiper.$wrapperEl.find(("." + (swiper.params.slideClass) + "[data-swiper-slide-index=\"" + i + "\"]")).remove();
  3853. }
  3854. }
  3855. }
  3856. for (var i$1 = 0; i$1 < slides.length; i$1 += 1) {
  3857. if (i$1 >= from && i$1 <= to) {
  3858. if (typeof previousTo === 'undefined' || force) {
  3859. appendIndexes.push(i$1);
  3860. } else {
  3861. if (i$1 > previousTo) { appendIndexes.push(i$1); }
  3862. if (i$1 < previousFrom) { prependIndexes.push(i$1); }
  3863. }
  3864. }
  3865. }
  3866. appendIndexes.forEach(function (index) {
  3867. swiper.$wrapperEl.append(renderSlide(slides[index], index));
  3868. });
  3869. prependIndexes.sort(function (a, b) { return a < b; }).forEach(function (index) {
  3870. swiper.$wrapperEl.prepend(renderSlide(slides[index], index));
  3871. });
  3872. swiper.$wrapperEl.children('.swiper-slide').css(offsetProp, (offset + "px"));
  3873. onRendered();
  3874. },
  3875. renderSlide: function renderSlide(slide, index) {
  3876. var swiper = this;
  3877. var params = swiper.params.virtual;
  3878. if (params.cache && swiper.virtual.cache[index]) {
  3879. return swiper.virtual.cache[index];
  3880. }
  3881. var $slideEl = params.renderSlide
  3882. ? $(params.renderSlide.call(swiper, slide, index))
  3883. : $(("<div class=\"" + (swiper.params.slideClass) + "\" data-swiper-slide-index=\"" + index + "\">" + slide + "</div>"));
  3884. if (!$slideEl.attr('data-swiper-slide-index')) { $slideEl.attr('data-swiper-slide-index', index); }
  3885. if (params.cache) { swiper.virtual.cache[index] = $slideEl; }
  3886. return $slideEl;
  3887. },
  3888. appendSlide: function appendSlide(slide) {
  3889. var swiper = this;
  3890. swiper.virtual.slides.push(slide);
  3891. swiper.virtual.update(true);
  3892. },
  3893. prependSlide: function prependSlide(slide) {
  3894. var swiper = this;
  3895. swiper.virtual.slides.unshift(slide);
  3896. if (swiper.params.virtual.cache) {
  3897. var cache = swiper.virtual.cache;
  3898. var newCache = {};
  3899. Object.keys(cache).forEach(function (cachedIndex) {
  3900. newCache[cachedIndex + 1] = cache[cachedIndex];
  3901. });
  3902. swiper.virtual.cache = newCache;
  3903. }
  3904. swiper.virtual.update(true);
  3905. swiper.slideNext(0);
  3906. },
  3907. };
  3908. var Virtual$1 = {
  3909. name: 'virtual',
  3910. params: {
  3911. virtual: {
  3912. enabled: false,
  3913. slides: [],
  3914. cache: true,
  3915. renderSlide: null,
  3916. renderExternal: null,
  3917. },
  3918. },
  3919. create: function create() {
  3920. var swiper = this;
  3921. Utils.extend(swiper, {
  3922. virtual: {
  3923. update: Virtual.update.bind(swiper),
  3924. appendSlide: Virtual.appendSlide.bind(swiper),
  3925. prependSlide: Virtual.prependSlide.bind(swiper),
  3926. renderSlide: Virtual.renderSlide.bind(swiper),
  3927. slides: swiper.params.virtual.slides,
  3928. cache: {},
  3929. },
  3930. });
  3931. },
  3932. on: {
  3933. beforeInit: function beforeInit() {
  3934. var swiper = this;
  3935. if (!swiper.params.virtual.enabled) { return; }
  3936. swiper.classNames.push(((swiper.params.containerModifierClass) + "virtual"));
  3937. var overwriteParams = {
  3938. watchSlidesProgress: true,
  3939. };
  3940. Utils.extend(swiper.params, overwriteParams);
  3941. Utils.extend(swiper.originalParams, overwriteParams);
  3942. swiper.virtual.update();
  3943. },
  3944. setTranslate: function setTranslate() {
  3945. var swiper = this;
  3946. if (!swiper.params.virtual.enabled) { return; }
  3947. swiper.virtual.update();
  3948. },
  3949. },
  3950. };
  3951. var Keyboard = {
  3952. handle: function handle(event) {
  3953. var swiper = this;
  3954. var rtl = swiper.rtlTranslate;
  3955. var e = event;
  3956. if (e.originalEvent) { e = e.originalEvent; } // jquery fix
  3957. var kc = e.keyCode || e.charCode;
  3958. // Directions locks
  3959. if (!swiper.allowSlideNext && ((swiper.isHorizontal() && kc === 39) || (swiper.isVertical() && kc === 40))) {
  3960. return false;
  3961. }
  3962. if (!swiper.allowSlidePrev && ((swiper.isHorizontal() && kc === 37) || (swiper.isVertical() && kc === 38))) {
  3963. return false;
  3964. }
  3965. if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey) {
  3966. return undefined;
  3967. }
  3968. if (doc.activeElement && doc.activeElement.nodeName && (doc.activeElement.nodeName.toLowerCase() === 'input' || doc.activeElement.nodeName.toLowerCase() === 'textarea')) {
  3969. return undefined;
  3970. }
  3971. if (swiper.params.keyboard.onlyInViewport && (kc === 37 || kc === 39 || kc === 38 || kc === 40)) {
  3972. var inView = false;
  3973. // Check that swiper should be inside of visible area of window
  3974. if (swiper.$el.parents(("." + (swiper.params.slideClass))).length > 0 && swiper.$el.parents(("." + (swiper.params.slideActiveClass))).length === 0) {
  3975. return undefined;
  3976. }
  3977. var windowWidth = win.innerWidth;
  3978. var windowHeight = win.innerHeight;
  3979. var swiperOffset = swiper.$el.offset();
  3980. if (rtl) { swiperOffset.left -= swiper.$el[0].scrollLeft; }
  3981. var swiperCoord = [
  3982. [swiperOffset.left, swiperOffset.top],
  3983. [swiperOffset.left + swiper.width, swiperOffset.top],
  3984. [swiperOffset.left, swiperOffset.top + swiper.height],
  3985. [swiperOffset.left + swiper.width, swiperOffset.top + swiper.height] ];
  3986. for (var i = 0; i < swiperCoord.length; i += 1) {
  3987. var point = swiperCoord[i];
  3988. if (
  3989. point[0] >= 0 && point[0] <= windowWidth &&
  3990. point[1] >= 0 && point[1] <= windowHeight
  3991. ) {
  3992. inView = true;
  3993. }
  3994. }
  3995. if (!inView) { return undefined; }
  3996. }
  3997. if (swiper.isHorizontal()) {
  3998. if (kc === 37 || kc === 39) {
  3999. if (e.preventDefault) { e.preventDefault(); }
  4000. else { e.returnValue = false; }
  4001. }
  4002. if ((kc === 39 && !rtl) || (kc === 37 && rtl)) { swiper.slideNext(); }
  4003. if ((kc === 37 && !rtl) || (kc === 39 && rtl)) { swiper.slidePrev(); }
  4004. } else {
  4005. if (kc === 38 || kc === 40) {
  4006. if (e.preventDefault) { e.preventDefault(); }
  4007. else { e.returnValue = false; }
  4008. }
  4009. if (kc === 40) { swiper.slideNext(); }
  4010. if (kc === 38) { swiper.slidePrev(); }
  4011. }
  4012. swiper.emit('keyPress', kc);
  4013. return undefined;
  4014. },
  4015. enable: function enable() {
  4016. var swiper = this;
  4017. if (swiper.keyboard.enabled) { return; }
  4018. $(doc).on('keydown', swiper.keyboard.handle);
  4019. swiper.keyboard.enabled = true;
  4020. },
  4021. disable: function disable() {
  4022. var swiper = this;
  4023. if (!swiper.keyboard.enabled) { return; }
  4024. $(doc).off('keydown', swiper.keyboard.handle);
  4025. swiper.keyboard.enabled = false;
  4026. },
  4027. };
  4028. var Keyboard$1 = {
  4029. name: 'keyboard',
  4030. params: {
  4031. keyboard: {
  4032. enabled: false,
  4033. onlyInViewport: true,
  4034. },
  4035. },
  4036. create: function create() {
  4037. var swiper = this;
  4038. Utils.extend(swiper, {
  4039. keyboard: {
  4040. enabled: false,
  4041. enable: Keyboard.enable.bind(swiper),
  4042. disable: Keyboard.disable.bind(swiper),
  4043. handle: Keyboard.handle.bind(swiper),
  4044. },
  4045. });
  4046. },
  4047. on: {
  4048. init: function init() {
  4049. var swiper = this;
  4050. if (swiper.params.keyboard.enabled) {
  4051. swiper.keyboard.enable();
  4052. }
  4053. },
  4054. destroy: function destroy() {
  4055. var swiper = this;
  4056. if (swiper.keyboard.enabled) {
  4057. swiper.keyboard.disable();
  4058. }
  4059. },
  4060. },
  4061. };
  4062. function isEventSupported() {
  4063. var eventName = 'onwheel';
  4064. var isSupported = eventName in doc;
  4065. if (!isSupported) {
  4066. var element = doc.createElement('div');
  4067. element.setAttribute(eventName, 'return;');
  4068. isSupported = typeof element[eventName] === 'function';
  4069. }
  4070. if (!isSupported &&
  4071. doc.implementation &&
  4072. doc.implementation.hasFeature &&
  4073. // always returns true in newer browsers as per the standard.
  4074. // @see http://dom.spec.whatwg.org/#dom-domimplementation-hasfeature
  4075. doc.implementation.hasFeature('', '') !== true
  4076. ) {
  4077. // This is the only way to test support for the `wheel` event in IE9+.
  4078. isSupported = doc.implementation.hasFeature('Events.wheel', '3.0');
  4079. }
  4080. return isSupported;
  4081. }
  4082. var Mousewheel = {
  4083. lastScrollTime: Utils.now(),
  4084. event: (function getEvent() {
  4085. if (win.navigator.userAgent.indexOf('firefox') > -1) { return 'DOMMouseScroll'; }
  4086. return isEventSupported() ? 'wheel' : 'mousewheel';
  4087. }()),
  4088. normalize: function normalize(e) {
  4089. // Reasonable defaults
  4090. var PIXEL_STEP = 10;
  4091. var LINE_HEIGHT = 40;
  4092. var PAGE_HEIGHT = 800;
  4093. var sX = 0;
  4094. var sY = 0; // spinX, spinY
  4095. var pX = 0;
  4096. var pY = 0; // pixelX, pixelY
  4097. // Legacy
  4098. if ('detail' in e) {
  4099. sY = e.detail;
  4100. }
  4101. if ('wheelDelta' in e) {
  4102. sY = -e.wheelDelta / 120;
  4103. }
  4104. if ('wheelDeltaY' in e) {
  4105. sY = -e.wheelDeltaY / 120;
  4106. }
  4107. if ('wheelDeltaX' in e) {
  4108. sX = -e.wheelDeltaX / 120;
  4109. }
  4110. // side scrolling on FF with DOMMouseScroll
  4111. if ('axis' in e && e.axis === e.HORIZONTAL_AXIS) {
  4112. sX = sY;
  4113. sY = 0;
  4114. }
  4115. pX = sX * PIXEL_STEP;
  4116. pY = sY * PIXEL_STEP;
  4117. if ('deltaY' in e) {
  4118. pY = e.deltaY;
  4119. }
  4120. if ('deltaX' in e) {
  4121. pX = e.deltaX;
  4122. }
  4123. if ((pX || pY) && e.deltaMode) {
  4124. if (e.deltaMode === 1) { // delta in LINE units
  4125. pX *= LINE_HEIGHT;
  4126. pY *= LINE_HEIGHT;
  4127. } else { // delta in PAGE units
  4128. pX *= PAGE_HEIGHT;
  4129. pY *= PAGE_HEIGHT;
  4130. }
  4131. }
  4132. // Fall-back if spin cannot be determined
  4133. if (pX && !sX) {
  4134. sX = (pX < 1) ? -1 : 1;
  4135. }
  4136. if (pY && !sY) {
  4137. sY = (pY < 1) ? -1 : 1;
  4138. }
  4139. return {
  4140. spinX: sX,
  4141. spinY: sY,
  4142. pixelX: pX,
  4143. pixelY: pY,
  4144. };
  4145. },
  4146. handleMouseEnter: function handleMouseEnter() {
  4147. var swiper = this;
  4148. swiper.mouseEntered = true;
  4149. },
  4150. handleMouseLeave: function handleMouseLeave() {
  4151. var swiper = this;
  4152. swiper.mouseEntered = false;
  4153. },
  4154. handle: function handle(event) {
  4155. var e = event;
  4156. var swiper = this;
  4157. var params = swiper.params.mousewheel;
  4158. if (!swiper.mouseEntered && !params.releaseOnEdges) { return true; }
  4159. if (e.originalEvent) { e = e.originalEvent; } // jquery fix
  4160. var delta = 0;
  4161. var rtlFactor = swiper.rtlTranslate ? -1 : 1;
  4162. var data = Mousewheel.normalize(e);
  4163. if (params.forceToAxis) {
  4164. if (swiper.isHorizontal()) {
  4165. if (Math.abs(data.pixelX) > Math.abs(data.pixelY)) { delta = data.pixelX * rtlFactor; }
  4166. else { return true; }
  4167. } else if (Math.abs(data.pixelY) > Math.abs(data.pixelX)) { delta = data.pixelY; }
  4168. else { return true; }
  4169. } else {
  4170. delta = Math.abs(data.pixelX) > Math.abs(data.pixelY) ? -data.pixelX * rtlFactor : -data.pixelY;
  4171. }
  4172. if (delta === 0) { return true; }
  4173. if (params.invert) { delta = -delta; }
  4174. if (!swiper.params.freeMode) {
  4175. if (Utils.now() - swiper.mousewheel.lastScrollTime > 60) {
  4176. if (delta < 0) {
  4177. if ((!swiper.isEnd || swiper.params.loop) && !swiper.animating) {
  4178. swiper.slideNext();
  4179. swiper.emit('scroll', e);
  4180. } else if (params.releaseOnEdges) { return true; }
  4181. } else if ((!swiper.isBeginning || swiper.params.loop) && !swiper.animating) {
  4182. swiper.slidePrev();
  4183. swiper.emit('scroll', e);
  4184. } else if (params.releaseOnEdges) { return true; }
  4185. }
  4186. swiper.mousewheel.lastScrollTime = (new win.Date()).getTime();
  4187. } else {
  4188. // Freemode or scrollContainer:
  4189. if (swiper.params.loop) {
  4190. swiper.loopFix();
  4191. }
  4192. var position = swiper.getTranslate() + (delta * params.sensitivity);
  4193. var wasBeginning = swiper.isBeginning;
  4194. var wasEnd = swiper.isEnd;
  4195. if (position >= swiper.minTranslate()) { position = swiper.minTranslate(); }
  4196. if (position <= swiper.maxTranslate()) { position = swiper.maxTranslate(); }
  4197. swiper.setTransition(0);
  4198. swiper.setTranslate(position);
  4199. swiper.updateProgress();
  4200. swiper.updateActiveIndex();
  4201. swiper.updateSlidesClasses();
  4202. if ((!wasBeginning && swiper.isBeginning) || (!wasEnd && swiper.isEnd)) {
  4203. swiper.updateSlidesClasses();
  4204. }
  4205. if (swiper.params.freeModeSticky) {
  4206. clearTimeout(swiper.mousewheel.timeout);
  4207. swiper.mousewheel.timeout = Utils.nextTick(function () {
  4208. swiper.slideToClosest();
  4209. }, 300);
  4210. }
  4211. // Emit event
  4212. swiper.emit('scroll', e);
  4213. // Stop autoplay
  4214. if (swiper.params.autoplay && swiper.params.autoplayDisableOnInteraction) { swiper.autoplay.stop(); }
  4215. // Return page scroll on edge positions
  4216. if (position === swiper.minTranslate() || position === swiper.maxTranslate()) { return true; }
  4217. }
  4218. if (e.preventDefault) { e.preventDefault(); }
  4219. else { e.returnValue = false; }
  4220. return false;
  4221. },
  4222. enable: function enable() {
  4223. var swiper = this;
  4224. if (!Mousewheel.event) { return false; }
  4225. if (swiper.mousewheel.enabled) { return false; }
  4226. var target = swiper.$el;
  4227. if (swiper.params.mousewheel.eventsTarged !== 'container') {
  4228. target = $(swiper.params.mousewheel.eventsTarged);
  4229. }
  4230. target.on('mouseenter', swiper.mousewheel.handleMouseEnter);
  4231. target.on('mouseleave', swiper.mousewheel.handleMouseLeave);
  4232. target.on(Mousewheel.event, swiper.mousewheel.handle);
  4233. swiper.mousewheel.enabled = true;
  4234. return true;
  4235. },
  4236. disable: function disable() {
  4237. var swiper = this;
  4238. if (!Mousewheel.event) { return false; }
  4239. if (!swiper.mousewheel.enabled) { return false; }
  4240. var target = swiper.$el;
  4241. if (swiper.params.mousewheel.eventsTarged !== 'container') {
  4242. target = $(swiper.params.mousewheel.eventsTarged);
  4243. }
  4244. target.off(Mousewheel.event, swiper.mousewheel.handle);
  4245. swiper.mousewheel.enabled = false;
  4246. return true;
  4247. },
  4248. };
  4249. var Mousewheel$1 = {
  4250. name: 'mousewheel',
  4251. params: {
  4252. mousewheel: {
  4253. enabled: false,
  4254. releaseOnEdges: false,
  4255. invert: false,
  4256. forceToAxis: false,
  4257. sensitivity: 1,
  4258. eventsTarged: 'container',
  4259. },
  4260. },
  4261. create: function create() {
  4262. var swiper = this;
  4263. Utils.extend(swiper, {
  4264. mousewheel: {
  4265. enabled: false,
  4266. enable: Mousewheel.enable.bind(swiper),
  4267. disable: Mousewheel.disable.bind(swiper),
  4268. handle: Mousewheel.handle.bind(swiper),
  4269. handleMouseEnter: Mousewheel.handleMouseEnter.bind(swiper),
  4270. handleMouseLeave: Mousewheel.handleMouseLeave.bind(swiper),
  4271. lastScrollTime: Utils.now(),
  4272. },
  4273. });
  4274. },
  4275. on: {
  4276. init: function init() {
  4277. var swiper = this;
  4278. if (swiper.params.mousewheel.enabled) { swiper.mousewheel.enable(); }
  4279. },
  4280. destroy: function destroy() {
  4281. var swiper = this;
  4282. if (swiper.mousewheel.enabled) { swiper.mousewheel.disable(); }
  4283. },
  4284. },
  4285. };
  4286. var Navigation = {
  4287. update: function update() {
  4288. // Update Navigation Buttons
  4289. var swiper = this;
  4290. var params = swiper.params.navigation;
  4291. if (swiper.params.loop) { return; }
  4292. var ref = swiper.navigation;
  4293. var $nextEl = ref.$nextEl;
  4294. var $prevEl = ref.$prevEl;
  4295. if ($prevEl && $prevEl.length > 0) {
  4296. if (swiper.isBeginning) {
  4297. $prevEl.addClass(params.disabledClass);
  4298. } else {
  4299. $prevEl.removeClass(params.disabledClass);
  4300. }
  4301. $prevEl[swiper.params.watchOverflow && swiper.isLocked ? 'addClass' : 'removeClass'](params.lockClass);
  4302. }
  4303. if ($nextEl && $nextEl.length > 0) {
  4304. if (swiper.isEnd) {
  4305. $nextEl.addClass(params.disabledClass);
  4306. } else {
  4307. $nextEl.removeClass(params.disabledClass);
  4308. }
  4309. $nextEl[swiper.params.watchOverflow && swiper.isLocked ? 'addClass' : 'removeClass'](params.lockClass);
  4310. }
  4311. },
  4312. init: function init() {
  4313. var swiper = this;
  4314. var params = swiper.params.navigation;
  4315. if (!(params.nextEl || params.prevEl)) { return; }
  4316. var $nextEl;
  4317. var $prevEl;
  4318. if (params.nextEl) {
  4319. $nextEl = $(params.nextEl);
  4320. if (
  4321. swiper.params.uniqueNavElements &&
  4322. typeof params.nextEl === 'string' &&
  4323. $nextEl.length > 1 &&
  4324. swiper.$el.find(params.nextEl).length === 1
  4325. ) {
  4326. $nextEl = swiper.$el.find(params.nextEl);
  4327. }
  4328. }
  4329. if (params.prevEl) {
  4330. $prevEl = $(params.prevEl);
  4331. if (
  4332. swiper.params.uniqueNavElements &&
  4333. typeof params.prevEl === 'string' &&
  4334. $prevEl.length > 1 &&
  4335. swiper.$el.find(params.prevEl).length === 1
  4336. ) {
  4337. $prevEl = swiper.$el.find(params.prevEl);
  4338. }
  4339. }
  4340. if ($nextEl && $nextEl.length > 0) {
  4341. $nextEl.on('click', function (e) {
  4342. e.preventDefault();
  4343. if (swiper.isEnd && !swiper.params.loop) { return; }
  4344. swiper.slideNext();
  4345. });
  4346. }
  4347. if ($prevEl && $prevEl.length > 0) {
  4348. $prevEl.on('click', function (e) {
  4349. e.preventDefault();
  4350. if (swiper.isBeginning && !swiper.params.loop) { return; }
  4351. swiper.slidePrev();
  4352. });
  4353. }
  4354. Utils.extend(swiper.navigation, {
  4355. $nextEl: $nextEl,
  4356. nextEl: $nextEl && $nextEl[0],
  4357. $prevEl: $prevEl,
  4358. prevEl: $prevEl && $prevEl[0],
  4359. });
  4360. },
  4361. destroy: function destroy() {
  4362. var swiper = this;
  4363. var ref = swiper.navigation;
  4364. var $nextEl = ref.$nextEl;
  4365. var $prevEl = ref.$prevEl;
  4366. if ($nextEl && $nextEl.length) {
  4367. $nextEl.off('click');
  4368. $nextEl.removeClass(swiper.params.navigation.disabledClass);
  4369. }
  4370. if ($prevEl && $prevEl.length) {
  4371. $prevEl.off('click');
  4372. $prevEl.removeClass(swiper.params.navigation.disabledClass);
  4373. }
  4374. },
  4375. };
  4376. var Navigation$1 = {
  4377. name: 'navigation',
  4378. params: {
  4379. navigation: {
  4380. nextEl: null,
  4381. prevEl: null,
  4382. hideOnClick: false,
  4383. disabledClass: 'swiper-button-disabled',
  4384. hiddenClass: 'swiper-button-hidden',
  4385. lockClass: 'swiper-button-lock',
  4386. },
  4387. },
  4388. create: function create() {
  4389. var swiper = this;
  4390. Utils.extend(swiper, {
  4391. navigation: {
  4392. init: Navigation.init.bind(swiper),
  4393. update: Navigation.update.bind(swiper),
  4394. destroy: Navigation.destroy.bind(swiper),
  4395. },
  4396. });
  4397. },
  4398. on: {
  4399. init: function init() {
  4400. var swiper = this;
  4401. swiper.navigation.init();
  4402. swiper.navigation.update();
  4403. },
  4404. toEdge: function toEdge() {
  4405. var swiper = this;
  4406. swiper.navigation.update();
  4407. },
  4408. fromEdge: function fromEdge() {
  4409. var swiper = this;
  4410. swiper.navigation.update();
  4411. },
  4412. destroy: function destroy() {
  4413. var swiper = this;
  4414. swiper.navigation.destroy();
  4415. },
  4416. click: function click(e) {
  4417. var swiper = this;
  4418. var ref = swiper.navigation;
  4419. var $nextEl = ref.$nextEl;
  4420. var $prevEl = ref.$prevEl;
  4421. if (
  4422. swiper.params.navigation.hideOnClick &&
  4423. !$(e.target).is($prevEl) &&
  4424. !$(e.target).is($nextEl)
  4425. ) {
  4426. if ($nextEl) { $nextEl.toggleClass(swiper.params.navigation.hiddenClass); }
  4427. if ($prevEl) { $prevEl.toggleClass(swiper.params.navigation.hiddenClass); }
  4428. }
  4429. },
  4430. },
  4431. };
  4432. var Pagination = {
  4433. update: function update() {
  4434. // Render || Update Pagination bullets/items
  4435. var swiper = this;
  4436. var rtl = swiper.rtl;
  4437. var params = swiper.params.pagination;
  4438. if (!params.el || !swiper.pagination.el || !swiper.pagination.$el || swiper.pagination.$el.length === 0) { return; }
  4439. var slidesLength = swiper.virtual && swiper.params.virtual.enabled ? swiper.virtual.slides.length : swiper.slides.length;
  4440. var $el = swiper.pagination.$el;
  4441. // Current/Total
  4442. var current;
  4443. var total = swiper.params.loop ? Math.ceil((slidesLength - (swiper.loopedSlides * 2)) / swiper.params.slidesPerGroup) : swiper.snapGrid.length;
  4444. if (swiper.params.loop) {
  4445. current = Math.ceil((swiper.activeIndex - swiper.loopedSlides) / swiper.params.slidesPerGroup);
  4446. if (current > slidesLength - 1 - (swiper.loopedSlides * 2)) {
  4447. current -= (slidesLength - (swiper.loopedSlides * 2));
  4448. }
  4449. if (current > total - 1) { current -= total; }
  4450. if (current < 0 && swiper.params.paginationType !== 'bullets') { current = total + current; }
  4451. } else if (typeof swiper.snapIndex !== 'undefined') {
  4452. current = swiper.snapIndex;
  4453. } else {
  4454. current = swiper.activeIndex || 0;
  4455. }
  4456. // Types
  4457. if (params.type === 'bullets' && swiper.pagination.bullets && swiper.pagination.bullets.length > 0) {
  4458. var bullets = swiper.pagination.bullets;
  4459. var firstIndex;
  4460. var lastIndex;
  4461. var midIndex;
  4462. if (params.dynamicBullets) {
  4463. swiper.pagination.bulletSize = bullets.eq(0)[swiper.isHorizontal() ? 'outerWidth' : 'outerHeight'](true);
  4464. $el.css(swiper.isHorizontal() ? 'width' : 'height', ((swiper.pagination.bulletSize * (params.dynamicMainBullets + 4)) + "px"));
  4465. if (params.dynamicMainBullets > 1 && swiper.previousIndex !== undefined) {
  4466. swiper.pagination.dynamicBulletIndex += (current - swiper.previousIndex);
  4467. if (swiper.pagination.dynamicBulletIndex > (params.dynamicMainBullets - 1)) {
  4468. swiper.pagination.dynamicBulletIndex = params.dynamicMainBullets - 1;
  4469. } else if (swiper.pagination.dynamicBulletIndex < 0) {
  4470. swiper.pagination.dynamicBulletIndex = 0;
  4471. }
  4472. }
  4473. firstIndex = current - swiper.pagination.dynamicBulletIndex;
  4474. lastIndex = firstIndex + (Math.min(bullets.length, params.dynamicMainBullets) - 1);
  4475. midIndex = (lastIndex + firstIndex) / 2;
  4476. }
  4477. bullets.removeClass(((params.bulletActiveClass) + " " + (params.bulletActiveClass) + "-next " + (params.bulletActiveClass) + "-next-next " + (params.bulletActiveClass) + "-prev " + (params.bulletActiveClass) + "-prev-prev " + (params.bulletActiveClass) + "-main"));
  4478. if ($el.length > 1) {
  4479. bullets.each(function (index, bullet) {
  4480. var $bullet = $(bullet);
  4481. var bulletIndex = $bullet.index();
  4482. if (bulletIndex === current) {
  4483. $bullet.addClass(params.bulletActiveClass);
  4484. }
  4485. if (params.dynamicBullets) {
  4486. if (bulletIndex >= firstIndex && bulletIndex <= lastIndex) {
  4487. $bullet.addClass(((params.bulletActiveClass) + "-main"));
  4488. }
  4489. if (bulletIndex === firstIndex) {
  4490. $bullet
  4491. .prev()
  4492. .addClass(((params.bulletActiveClass) + "-prev"))
  4493. .prev()
  4494. .addClass(((params.bulletActiveClass) + "-prev-prev"));
  4495. }
  4496. if (bulletIndex === lastIndex) {
  4497. $bullet
  4498. .next()
  4499. .addClass(((params.bulletActiveClass) + "-next"))
  4500. .next()
  4501. .addClass(((params.bulletActiveClass) + "-next-next"));
  4502. }
  4503. }
  4504. });
  4505. } else {
  4506. var $bullet = bullets.eq(current);
  4507. $bullet.addClass(params.bulletActiveClass);
  4508. if (params.dynamicBullets) {
  4509. var $firstDisplayedBullet = bullets.eq(firstIndex);
  4510. var $lastDisplayedBullet = bullets.eq(lastIndex);
  4511. for (var i = firstIndex; i <= lastIndex; i += 1) {
  4512. bullets.eq(i).addClass(((params.bulletActiveClass) + "-main"));
  4513. }
  4514. $firstDisplayedBullet
  4515. .prev()
  4516. .addClass(((params.bulletActiveClass) + "-prev"))
  4517. .prev()
  4518. .addClass(((params.bulletActiveClass) + "-prev-prev"));
  4519. $lastDisplayedBullet
  4520. .next()
  4521. .addClass(((params.bulletActiveClass) + "-next"))
  4522. .next()
  4523. .addClass(((params.bulletActiveClass) + "-next-next"));
  4524. }
  4525. }
  4526. if (params.dynamicBullets) {
  4527. var dynamicBulletsLength = Math.min(bullets.length, params.dynamicMainBullets + 4);
  4528. var bulletsOffset = (((swiper.pagination.bulletSize * dynamicBulletsLength) - (swiper.pagination.bulletSize)) / 2) - (midIndex * swiper.pagination.bulletSize);
  4529. var offsetProp = rtl ? 'right' : 'left';
  4530. bullets.css(swiper.isHorizontal() ? offsetProp : 'top', (bulletsOffset + "px"));
  4531. }
  4532. }
  4533. if (params.type === 'fraction') {
  4534. $el.find(("." + (params.currentClass))).text(params.formatFractionCurrent(current + 1));
  4535. $el.find(("." + (params.totalClass))).text(params.formatFractionTotal(total));
  4536. }
  4537. if (params.type === 'progressbar') {
  4538. var progressbarDirection;
  4539. if (params.progressbarOpposite) {
  4540. progressbarDirection = swiper.isHorizontal() ? 'vertical' : 'horizontal';
  4541. } else {
  4542. progressbarDirection = swiper.isHorizontal() ? 'horizontal' : 'vertical';
  4543. }
  4544. var scale = (current + 1) / total;
  4545. var scaleX = 1;
  4546. var scaleY = 1;
  4547. if (progressbarDirection === 'horizontal') {
  4548. scaleX = scale;
  4549. } else {
  4550. scaleY = scale;
  4551. }
  4552. $el.find(("." + (params.progressbarFillClass))).transform(("translate3d(0,0,0) scaleX(" + scaleX + ") scaleY(" + scaleY + ")")).transition(swiper.params.speed);
  4553. }
  4554. if (params.type === 'custom' && params.renderCustom) {
  4555. $el.html(params.renderCustom(swiper, current + 1, total));
  4556. swiper.emit('paginationRender', swiper, $el[0]);
  4557. } else {
  4558. swiper.emit('paginationUpdate', swiper, $el[0]);
  4559. }
  4560. $el[swiper.params.watchOverflow && swiper.isLocked ? 'addClass' : 'removeClass'](params.lockClass);
  4561. },
  4562. render: function render() {
  4563. // Render Container
  4564. var swiper = this;
  4565. var params = swiper.params.pagination;
  4566. if (!params.el || !swiper.pagination.el || !swiper.pagination.$el || swiper.pagination.$el.length === 0) { return; }
  4567. var slidesLength = swiper.virtual && swiper.params.virtual.enabled ? swiper.virtual.slides.length : swiper.slides.length;
  4568. var $el = swiper.pagination.$el;
  4569. var paginationHTML = '';
  4570. if (params.type === 'bullets') {
  4571. var numberOfBullets = swiper.params.loop ? Math.ceil((slidesLength - (swiper.loopedSlides * 2)) / swiper.params.slidesPerGroup) : swiper.snapGrid.length;
  4572. for (var i = 0; i < numberOfBullets; i += 1) {
  4573. if (params.renderBullet) {
  4574. paginationHTML += params.renderBullet.call(swiper, i, params.bulletClass);
  4575. } else {
  4576. paginationHTML += "<" + (params.bulletElement) + " class=\"" + (params.bulletClass) + "\"></" + (params.bulletElement) + ">";
  4577. }
  4578. }
  4579. $el.html(paginationHTML);
  4580. swiper.pagination.bullets = $el.find(("." + (params.bulletClass)));
  4581. }
  4582. if (params.type === 'fraction') {
  4583. if (params.renderFraction) {
  4584. paginationHTML = params.renderFraction.call(swiper, params.currentClass, params.totalClass);
  4585. } else {
  4586. paginationHTML =
  4587. "<span class=\"" + (params.currentClass) + "\"></span>" +
  4588. ' / ' +
  4589. "<span class=\"" + (params.totalClass) + "\"></span>";
  4590. }
  4591. $el.html(paginationHTML);
  4592. }
  4593. if (params.type === 'progressbar') {
  4594. if (params.renderProgressbar) {
  4595. paginationHTML = params.renderProgressbar.call(swiper, params.progressbarFillClass);
  4596. } else {
  4597. paginationHTML = "<span class=\"" + (params.progressbarFillClass) + "\"></span>";
  4598. }
  4599. $el.html(paginationHTML);
  4600. }
  4601. if (params.type !== 'custom') {
  4602. swiper.emit('paginationRender', swiper.pagination.$el[0]);
  4603. }
  4604. },
  4605. init: function init() {
  4606. var swiper = this;
  4607. var params = swiper.params.pagination;
  4608. if (!params.el) { return; }
  4609. var $el = $(params.el);
  4610. if ($el.length === 0) { return; }
  4611. if (
  4612. swiper.params.uniqueNavElements &&
  4613. typeof params.el === 'string' &&
  4614. $el.length > 1 &&
  4615. swiper.$el.find(params.el).length === 1
  4616. ) {
  4617. $el = swiper.$el.find(params.el);
  4618. }
  4619. if (params.type === 'bullets' && params.clickable) {
  4620. $el.addClass(params.clickableClass);
  4621. }
  4622. $el.addClass(params.modifierClass + params.type);
  4623. if (params.type === 'bullets' && params.dynamicBullets) {
  4624. $el.addClass(("" + (params.modifierClass) + (params.type) + "-dynamic"));
  4625. swiper.pagination.dynamicBulletIndex = 0;
  4626. if (params.dynamicMainBullets < 1) {
  4627. params.dynamicMainBullets = 1;
  4628. }
  4629. }
  4630. if (params.type === 'progressbar' && params.progressbarOpposite) {
  4631. $el.addClass(params.progressbarOppositeClass);
  4632. }
  4633. if (params.clickable) {
  4634. $el.on('click', ("." + (params.bulletClass)), function onClick(e) {
  4635. e.preventDefault();
  4636. var index = $(this).index() * swiper.params.slidesPerGroup;
  4637. if (swiper.params.loop) { index += swiper.loopedSlides; }
  4638. swiper.slideTo(index);
  4639. });
  4640. }
  4641. Utils.extend(swiper.pagination, {
  4642. $el: $el,
  4643. el: $el[0],
  4644. });
  4645. },
  4646. destroy: function destroy() {
  4647. var swiper = this;
  4648. var params = swiper.params.pagination;
  4649. if (!params.el || !swiper.pagination.el || !swiper.pagination.$el || swiper.pagination.$el.length === 0) { return; }
  4650. var $el = swiper.pagination.$el;
  4651. $el.removeClass(params.hiddenClass);
  4652. $el.removeClass(params.modifierClass + params.type);
  4653. if (swiper.pagination.bullets) { swiper.pagination.bullets.removeClass(params.bulletActiveClass); }
  4654. if (params.clickable) {
  4655. $el.off('click', ("." + (params.bulletClass)));
  4656. }
  4657. },
  4658. };
  4659. var Pagination$1 = {
  4660. name: 'pagination',
  4661. params: {
  4662. pagination: {
  4663. el: null,
  4664. bulletElement: 'span',
  4665. clickable: false,
  4666. hideOnClick: false,
  4667. renderBullet: null,
  4668. renderProgressbar: null,
  4669. renderFraction: null,
  4670. renderCustom: null,
  4671. progressbarOpposite: false,
  4672. type: 'bullets', // 'bullets' or 'progressbar' or 'fraction' or 'custom'
  4673. dynamicBullets: false,
  4674. dynamicMainBullets: 1,
  4675. formatFractionCurrent: function (number) { return number; },
  4676. formatFractionTotal: function (number) { return number; },
  4677. bulletClass: 'swiper-pagination-bullet',
  4678. bulletActiveClass: 'swiper-pagination-bullet-active',
  4679. modifierClass: 'swiper-pagination-', // NEW
  4680. currentClass: 'swiper-pagination-current',
  4681. totalClass: 'swiper-pagination-total',
  4682. hiddenClass: 'swiper-pagination-hidden',
  4683. progressbarFillClass: 'swiper-pagination-progressbar-fill',
  4684. progressbarOppositeClass: 'swiper-pagination-progressbar-opposite',
  4685. clickableClass: 'swiper-pagination-clickable', // NEW
  4686. lockClass: 'swiper-pagination-lock',
  4687. },
  4688. },
  4689. create: function create() {
  4690. var swiper = this;
  4691. Utils.extend(swiper, {
  4692. pagination: {
  4693. init: Pagination.init.bind(swiper),
  4694. render: Pagination.render.bind(swiper),
  4695. update: Pagination.update.bind(swiper),
  4696. destroy: Pagination.destroy.bind(swiper),
  4697. dynamicBulletIndex: 0,
  4698. },
  4699. });
  4700. },
  4701. on: {
  4702. init: function init() {
  4703. var swiper = this;
  4704. swiper.pagination.init();
  4705. swiper.pagination.render();
  4706. swiper.pagination.update();
  4707. },
  4708. activeIndexChange: function activeIndexChange() {
  4709. var swiper = this;
  4710. if (swiper.params.loop) {
  4711. swiper.pagination.update();
  4712. } else if (typeof swiper.snapIndex === 'undefined') {
  4713. swiper.pagination.update();
  4714. }
  4715. },
  4716. snapIndexChange: function snapIndexChange() {
  4717. var swiper = this;
  4718. if (!swiper.params.loop) {
  4719. swiper.pagination.update();
  4720. }
  4721. },
  4722. slidesLengthChange: function slidesLengthChange() {
  4723. var swiper = this;
  4724. if (swiper.params.loop) {
  4725. swiper.pagination.render();
  4726. swiper.pagination.update();
  4727. }
  4728. },
  4729. snapGridLengthChange: function snapGridLengthChange() {
  4730. var swiper = this;
  4731. if (!swiper.params.loop) {
  4732. swiper.pagination.render();
  4733. swiper.pagination.update();
  4734. }
  4735. },
  4736. destroy: function destroy() {
  4737. var swiper = this;
  4738. swiper.pagination.destroy();
  4739. },
  4740. click: function click(e) {
  4741. var swiper = this;
  4742. if (
  4743. swiper.params.pagination.el &&
  4744. swiper.params.pagination.hideOnClick &&
  4745. swiper.pagination.$el.length > 0 &&
  4746. !$(e.target).hasClass(swiper.params.pagination.bulletClass)
  4747. ) {
  4748. swiper.pagination.$el.toggleClass(swiper.params.pagination.hiddenClass);
  4749. }
  4750. },
  4751. },
  4752. };
  4753. var Scrollbar = {
  4754. setTranslate: function setTranslate() {
  4755. var swiper = this;
  4756. if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) { return; }
  4757. var scrollbar = swiper.scrollbar;
  4758. var rtl = swiper.rtlTranslate;
  4759. var progress = swiper.progress;
  4760. var dragSize = scrollbar.dragSize;
  4761. var trackSize = scrollbar.trackSize;
  4762. var $dragEl = scrollbar.$dragEl;
  4763. var $el = scrollbar.$el;
  4764. var params = swiper.params.scrollbar;
  4765. var newSize = dragSize;
  4766. var newPos = (trackSize - dragSize) * progress;
  4767. if (rtl) {
  4768. newPos = -newPos;
  4769. if (newPos > 0) {
  4770. newSize = dragSize - newPos;
  4771. newPos = 0;
  4772. } else if (-newPos + dragSize > trackSize) {
  4773. newSize = trackSize + newPos;
  4774. }
  4775. } else if (newPos < 0) {
  4776. newSize = dragSize + newPos;
  4777. newPos = 0;
  4778. } else if (newPos + dragSize > trackSize) {
  4779. newSize = trackSize - newPos;
  4780. }
  4781. if (swiper.isHorizontal()) {
  4782. if (Support.transforms3d) {
  4783. $dragEl.transform(("translate3d(" + newPos + "px, 0, 0)"));
  4784. } else {
  4785. $dragEl.transform(("translateX(" + newPos + "px)"));
  4786. }
  4787. $dragEl[0].style.width = newSize + "px";
  4788. } else {
  4789. if (Support.transforms3d) {
  4790. $dragEl.transform(("translate3d(0px, " + newPos + "px, 0)"));
  4791. } else {
  4792. $dragEl.transform(("translateY(" + newPos + "px)"));
  4793. }
  4794. $dragEl[0].style.height = newSize + "px";
  4795. }
  4796. if (params.hide) {
  4797. clearTimeout(swiper.scrollbar.timeout);
  4798. $el[0].style.opacity = 1;
  4799. swiper.scrollbar.timeout = setTimeout(function () {
  4800. $el[0].style.opacity = 0;
  4801. $el.transition(400);
  4802. }, 1000);
  4803. }
  4804. },
  4805. setTransition: function setTransition(duration) {
  4806. var swiper = this;
  4807. if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) { return; }
  4808. swiper.scrollbar.$dragEl.transition(duration);
  4809. },
  4810. updateSize: function updateSize() {
  4811. var swiper = this;
  4812. if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) { return; }
  4813. var scrollbar = swiper.scrollbar;
  4814. var $dragEl = scrollbar.$dragEl;
  4815. var $el = scrollbar.$el;
  4816. $dragEl[0].style.width = '';
  4817. $dragEl[0].style.height = '';
  4818. var trackSize = swiper.isHorizontal() ? $el[0].offsetWidth : $el[0].offsetHeight;
  4819. var divider = swiper.size / swiper.virtualSize;
  4820. var moveDivider = divider * (trackSize / swiper.size);
  4821. var dragSize;
  4822. if (swiper.params.scrollbar.dragSize === 'auto') {
  4823. dragSize = trackSize * divider;
  4824. } else {
  4825. dragSize = parseInt(swiper.params.scrollbar.dragSize, 10);
  4826. }
  4827. if (swiper.isHorizontal()) {
  4828. $dragEl[0].style.width = dragSize + "px";
  4829. } else {
  4830. $dragEl[0].style.height = dragSize + "px";
  4831. }
  4832. if (divider >= 1) {
  4833. $el[0].style.display = 'none';
  4834. } else {
  4835. $el[0].style.display = '';
  4836. }
  4837. if (swiper.params.scrollbarHide) {
  4838. $el[0].style.opacity = 0;
  4839. }
  4840. Utils.extend(scrollbar, {
  4841. trackSize: trackSize,
  4842. divider: divider,
  4843. moveDivider: moveDivider,
  4844. dragSize: dragSize,
  4845. });
  4846. scrollbar.$el[swiper.params.watchOverflow && swiper.isLocked ? 'addClass' : 'removeClass'](swiper.params.scrollbar.lockClass);
  4847. },
  4848. setDragPosition: function setDragPosition(e) {
  4849. var swiper = this;
  4850. var scrollbar = swiper.scrollbar;
  4851. var rtl = swiper.rtlTranslate;
  4852. var $el = scrollbar.$el;
  4853. var dragSize = scrollbar.dragSize;
  4854. var trackSize = scrollbar.trackSize;
  4855. var pointerPosition;
  4856. if (swiper.isHorizontal()) {
  4857. pointerPosition = ((e.type === 'touchstart' || e.type === 'touchmove') ? e.targetTouches[0].pageX : e.pageX || e.clientX);
  4858. } else {
  4859. pointerPosition = ((e.type === 'touchstart' || e.type === 'touchmove') ? e.targetTouches[0].pageY : e.pageY || e.clientY);
  4860. }
  4861. var positionRatio;
  4862. positionRatio = ((pointerPosition) - $el.offset()[swiper.isHorizontal() ? 'left' : 'top'] - (dragSize / 2)) / (trackSize - dragSize);
  4863. positionRatio = Math.max(Math.min(positionRatio, 1), 0);
  4864. if (rtl) {
  4865. positionRatio = 1 - positionRatio;
  4866. }
  4867. var position = swiper.minTranslate() + ((swiper.maxTranslate() - swiper.minTranslate()) * positionRatio);
  4868. swiper.updateProgress(position);
  4869. swiper.setTranslate(position);
  4870. swiper.updateActiveIndex();
  4871. swiper.updateSlidesClasses();
  4872. },
  4873. onDragStart: function onDragStart(e) {
  4874. var swiper = this;
  4875. var params = swiper.params.scrollbar;
  4876. var scrollbar = swiper.scrollbar;
  4877. var $wrapperEl = swiper.$wrapperEl;
  4878. var $el = scrollbar.$el;
  4879. var $dragEl = scrollbar.$dragEl;
  4880. swiper.scrollbar.isTouched = true;
  4881. e.preventDefault();
  4882. e.stopPropagation();
  4883. $wrapperEl.transition(100);
  4884. $dragEl.transition(100);
  4885. scrollbar.setDragPosition(e);
  4886. clearTimeout(swiper.scrollbar.dragTimeout);
  4887. $el.transition(0);
  4888. if (params.hide) {
  4889. $el.css('opacity', 1);
  4890. }
  4891. swiper.emit('scrollbarDragStart', e);
  4892. },
  4893. onDragMove: function onDragMove(e) {
  4894. var swiper = this;
  4895. var scrollbar = swiper.scrollbar;
  4896. var $wrapperEl = swiper.$wrapperEl;
  4897. var $el = scrollbar.$el;
  4898. var $dragEl = scrollbar.$dragEl;
  4899. if (!swiper.scrollbar.isTouched) { return; }
  4900. if (e.preventDefault) { e.preventDefault(); }
  4901. else { e.returnValue = false; }
  4902. scrollbar.setDragPosition(e);
  4903. $wrapperEl.transition(0);
  4904. $el.transition(0);
  4905. $dragEl.transition(0);
  4906. swiper.emit('scrollbarDragMove', e);
  4907. },
  4908. onDragEnd: function onDragEnd(e) {
  4909. var swiper = this;
  4910. var params = swiper.params.scrollbar;
  4911. var scrollbar = swiper.scrollbar;
  4912. var $el = scrollbar.$el;
  4913. if (!swiper.scrollbar.isTouched) { return; }
  4914. swiper.scrollbar.isTouched = false;
  4915. if (params.hide) {
  4916. clearTimeout(swiper.scrollbar.dragTimeout);
  4917. swiper.scrollbar.dragTimeout = Utils.nextTick(function () {
  4918. $el.css('opacity', 0);
  4919. $el.transition(400);
  4920. }, 1000);
  4921. }
  4922. swiper.emit('scrollbarDragEnd', e);
  4923. if (params.snapOnRelease) {
  4924. swiper.slideToClosest();
  4925. }
  4926. },
  4927. enableDraggable: function enableDraggable() {
  4928. var swiper = this;
  4929. if (!swiper.params.scrollbar.el) { return; }
  4930. var scrollbar = swiper.scrollbar;
  4931. var touchEvents = swiper.touchEvents;
  4932. var touchEventsDesktop = swiper.touchEventsDesktop;
  4933. var params = swiper.params;
  4934. var $el = scrollbar.$el;
  4935. var target = $el[0];
  4936. var activeListener = Support.passiveListener && params.passiveListener ? { passive: false, capture: false } : false;
  4937. var passiveListener = Support.passiveListener && params.passiveListener ? { passive: true, capture: false } : false;
  4938. if (!Support.touch && (Support.pointerEvents || Support.prefixedPointerEvents)) {
  4939. target.addEventListener(touchEventsDesktop.start, swiper.scrollbar.onDragStart, activeListener);
  4940. doc.addEventListener(touchEventsDesktop.move, swiper.scrollbar.onDragMove, activeListener);
  4941. doc.addEventListener(touchEventsDesktop.end, swiper.scrollbar.onDragEnd, passiveListener);
  4942. } else {
  4943. if (Support.touch) {
  4944. target.addEventListener(touchEvents.start, swiper.scrollbar.onDragStart, activeListener);
  4945. target.addEventListener(touchEvents.move, swiper.scrollbar.onDragMove, activeListener);
  4946. target.addEventListener(touchEvents.end, swiper.scrollbar.onDragEnd, passiveListener);
  4947. }
  4948. if ((params.simulateTouch && !Device.ios && !Device.android) || (params.simulateTouch && !Support.touch && Device.ios)) {
  4949. target.addEventListener('mousedown', swiper.scrollbar.onDragStart, activeListener);
  4950. doc.addEventListener('mousemove', swiper.scrollbar.onDragMove, activeListener);
  4951. doc.addEventListener('mouseup', swiper.scrollbar.onDragEnd, passiveListener);
  4952. }
  4953. }
  4954. },
  4955. disableDraggable: function disableDraggable() {
  4956. var swiper = this;
  4957. if (!swiper.params.scrollbar.el) { return; }
  4958. var scrollbar = swiper.scrollbar;
  4959. var touchEvents = swiper.touchEvents;
  4960. var touchEventsDesktop = swiper.touchEventsDesktop;
  4961. var params = swiper.params;
  4962. var $el = scrollbar.$el;
  4963. var target = $el[0];
  4964. var activeListener = Support.passiveListener && params.passiveListener ? { passive: false, capture: false } : false;
  4965. var passiveListener = Support.passiveListener && params.passiveListener ? { passive: true, capture: false } : false;
  4966. if (!Support.touch && (Support.pointerEvents || Support.prefixedPointerEvents)) {
  4967. target.removeEventListener(touchEventsDesktop.start, swiper.scrollbar.onDragStart, activeListener);
  4968. doc.removeEventListener(touchEventsDesktop.move, swiper.scrollbar.onDragMove, activeListener);
  4969. doc.removeEventListener(touchEventsDesktop.end, swiper.scrollbar.onDragEnd, passiveListener);
  4970. } else {
  4971. if (Support.touch) {
  4972. target.removeEventListener(touchEvents.start, swiper.scrollbar.onDragStart, activeListener);
  4973. target.removeEventListener(touchEvents.move, swiper.scrollbar.onDragMove, activeListener);
  4974. target.removeEventListener(touchEvents.end, swiper.scrollbar.onDragEnd, passiveListener);
  4975. }
  4976. if ((params.simulateTouch && !Device.ios && !Device.android) || (params.simulateTouch && !Support.touch && Device.ios)) {
  4977. target.removeEventListener('mousedown', swiper.scrollbar.onDragStart, activeListener);
  4978. doc.removeEventListener('mousemove', swiper.scrollbar.onDragMove, activeListener);
  4979. doc.removeEventListener('mouseup', swiper.scrollbar.onDragEnd, passiveListener);
  4980. }
  4981. }
  4982. },
  4983. init: function init() {
  4984. var swiper = this;
  4985. if (!swiper.params.scrollbar.el) { return; }
  4986. var scrollbar = swiper.scrollbar;
  4987. var $swiperEl = swiper.$el;
  4988. var params = swiper.params.scrollbar;
  4989. var $el = $(params.el);
  4990. if (swiper.params.uniqueNavElements && typeof params.el === 'string' && $el.length > 1 && $swiperEl.find(params.el).length === 1) {
  4991. $el = $swiperEl.find(params.el);
  4992. }
  4993. var $dragEl = $el.find(("." + (swiper.params.scrollbar.dragClass)));
  4994. if ($dragEl.length === 0) {
  4995. $dragEl = $(("<div class=\"" + (swiper.params.scrollbar.dragClass) + "\"></div>"));
  4996. $el.append($dragEl);
  4997. }
  4998. Utils.extend(scrollbar, {
  4999. $el: $el,
  5000. el: $el[0],
  5001. $dragEl: $dragEl,
  5002. dragEl: $dragEl[0],
  5003. });
  5004. if (params.draggable) {
  5005. scrollbar.enableDraggable();
  5006. }
  5007. },
  5008. destroy: function destroy() {
  5009. var swiper = this;
  5010. swiper.scrollbar.disableDraggable();
  5011. },
  5012. };
  5013. var Scrollbar$1 = {
  5014. name: 'scrollbar',
  5015. params: {
  5016. scrollbar: {
  5017. el: null,
  5018. dragSize: 'auto',
  5019. hide: false,
  5020. draggable: false,
  5021. snapOnRelease: true,
  5022. lockClass: 'swiper-scrollbar-lock',
  5023. dragClass: 'swiper-scrollbar-drag',
  5024. },
  5025. },
  5026. create: function create() {
  5027. var swiper = this;
  5028. Utils.extend(swiper, {
  5029. scrollbar: {
  5030. init: Scrollbar.init.bind(swiper),
  5031. destroy: Scrollbar.destroy.bind(swiper),
  5032. updateSize: Scrollbar.updateSize.bind(swiper),
  5033. setTranslate: Scrollbar.setTranslate.bind(swiper),
  5034. setTransition: Scrollbar.setTransition.bind(swiper),
  5035. enableDraggable: Scrollbar.enableDraggable.bind(swiper),
  5036. disableDraggable: Scrollbar.disableDraggable.bind(swiper),
  5037. setDragPosition: Scrollbar.setDragPosition.bind(swiper),
  5038. onDragStart: Scrollbar.onDragStart.bind(swiper),
  5039. onDragMove: Scrollbar.onDragMove.bind(swiper),
  5040. onDragEnd: Scrollbar.onDragEnd.bind(swiper),
  5041. isTouched: false,
  5042. timeout: null,
  5043. dragTimeout: null,
  5044. },
  5045. });
  5046. },
  5047. on: {
  5048. init: function init() {
  5049. var swiper = this;
  5050. swiper.scrollbar.init();
  5051. swiper.scrollbar.updateSize();
  5052. swiper.scrollbar.setTranslate();
  5053. },
  5054. update: function update() {
  5055. var swiper = this;
  5056. swiper.scrollbar.updateSize();
  5057. },
  5058. resize: function resize() {
  5059. var swiper = this;
  5060. swiper.scrollbar.updateSize();
  5061. },
  5062. observerUpdate: function observerUpdate() {
  5063. var swiper = this;
  5064. swiper.scrollbar.updateSize();
  5065. },
  5066. setTranslate: function setTranslate() {
  5067. var swiper = this;
  5068. swiper.scrollbar.setTranslate();
  5069. },
  5070. setTransition: function setTransition(duration) {
  5071. var swiper = this;
  5072. swiper.scrollbar.setTransition(duration);
  5073. },
  5074. destroy: function destroy() {
  5075. var swiper = this;
  5076. swiper.scrollbar.destroy();
  5077. },
  5078. },
  5079. };
  5080. var Parallax = {
  5081. setTransform: function setTransform(el, progress) {
  5082. var swiper = this;
  5083. var rtl = swiper.rtl;
  5084. var $el = $(el);
  5085. var rtlFactor = rtl ? -1 : 1;
  5086. var p = $el.attr('data-swiper-parallax') || '0';
  5087. var x = $el.attr('data-swiper-parallax-x');
  5088. var y = $el.attr('data-swiper-parallax-y');
  5089. var scale = $el.attr('data-swiper-parallax-scale');
  5090. var opacity = $el.attr('data-swiper-parallax-opacity');
  5091. if (x || y) {
  5092. x = x || '0';
  5093. y = y || '0';
  5094. } else if (swiper.isHorizontal()) {
  5095. x = p;
  5096. y = '0';
  5097. } else {
  5098. y = p;
  5099. x = '0';
  5100. }
  5101. if ((x).indexOf('%') >= 0) {
  5102. x = (parseInt(x, 10) * progress * rtlFactor) + "%";
  5103. } else {
  5104. x = (x * progress * rtlFactor) + "px";
  5105. }
  5106. if ((y).indexOf('%') >= 0) {
  5107. y = (parseInt(y, 10) * progress) + "%";
  5108. } else {
  5109. y = (y * progress) + "px";
  5110. }
  5111. if (typeof opacity !== 'undefined' && opacity !== null) {
  5112. var currentOpacity = opacity - ((opacity - 1) * (1 - Math.abs(progress)));
  5113. $el[0].style.opacity = currentOpacity;
  5114. }
  5115. if (typeof scale === 'undefined' || scale === null) {
  5116. $el.transform(("translate3d(" + x + ", " + y + ", 0px)"));
  5117. } else {
  5118. var currentScale = scale - ((scale - 1) * (1 - Math.abs(progress)));
  5119. $el.transform(("translate3d(" + x + ", " + y + ", 0px) scale(" + currentScale + ")"));
  5120. }
  5121. },
  5122. setTranslate: function setTranslate() {
  5123. var swiper = this;
  5124. var $el = swiper.$el;
  5125. var slides = swiper.slides;
  5126. var progress = swiper.progress;
  5127. var snapGrid = swiper.snapGrid;
  5128. $el.children('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y]')
  5129. .each(function (index, el) {
  5130. swiper.parallax.setTransform(el, progress);
  5131. });
  5132. slides.each(function (slideIndex, slideEl) {
  5133. var slideProgress = slideEl.progress;
  5134. if (swiper.params.slidesPerGroup > 1 && swiper.params.slidesPerView !== 'auto') {
  5135. slideProgress += Math.ceil(slideIndex / 2) - (progress * (snapGrid.length - 1));
  5136. }
  5137. slideProgress = Math.min(Math.max(slideProgress, -1), 1);
  5138. $(slideEl).find('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y]')
  5139. .each(function (index, el) {
  5140. swiper.parallax.setTransform(el, slideProgress);
  5141. });
  5142. });
  5143. },
  5144. setTransition: function setTransition(duration) {
  5145. if ( duration === void 0 ) duration = this.params.speed;
  5146. var swiper = this;
  5147. var $el = swiper.$el;
  5148. $el.find('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y]')
  5149. .each(function (index, parallaxEl) {
  5150. var $parallaxEl = $(parallaxEl);
  5151. var parallaxDuration = parseInt($parallaxEl.attr('data-swiper-parallax-duration'), 10) || duration;
  5152. if (duration === 0) { parallaxDuration = 0; }
  5153. $parallaxEl.transition(parallaxDuration);
  5154. });
  5155. },
  5156. };
  5157. var Parallax$1 = {
  5158. name: 'parallax',
  5159. params: {
  5160. parallax: {
  5161. enabled: false,
  5162. },
  5163. },
  5164. create: function create() {
  5165. var swiper = this;
  5166. Utils.extend(swiper, {
  5167. parallax: {
  5168. setTransform: Parallax.setTransform.bind(swiper),
  5169. setTranslate: Parallax.setTranslate.bind(swiper),
  5170. setTransition: Parallax.setTransition.bind(swiper),
  5171. },
  5172. });
  5173. },
  5174. on: {
  5175. beforeInit: function beforeInit() {
  5176. var swiper = this;
  5177. if (!swiper.params.parallax.enabled) { return; }
  5178. swiper.params.watchSlidesProgress = true;
  5179. },
  5180. init: function init() {
  5181. var swiper = this;
  5182. if (!swiper.params.parallax) { return; }
  5183. swiper.parallax.setTranslate();
  5184. },
  5185. setTranslate: function setTranslate() {
  5186. var swiper = this;
  5187. if (!swiper.params.parallax) { return; }
  5188. swiper.parallax.setTranslate();
  5189. },
  5190. setTransition: function setTransition(duration) {
  5191. var swiper = this;
  5192. if (!swiper.params.parallax) { return; }
  5193. swiper.parallax.setTransition(duration);
  5194. },
  5195. },
  5196. };
  5197. var Zoom = {
  5198. // Calc Scale From Multi-touches
  5199. getDistanceBetweenTouches: function getDistanceBetweenTouches(e) {
  5200. if (e.targetTouches.length < 2) { return 1; }
  5201. var x1 = e.targetTouches[0].pageX;
  5202. var y1 = e.targetTouches[0].pageY;
  5203. var x2 = e.targetTouches[1].pageX;
  5204. var y2 = e.targetTouches[1].pageY;
  5205. var distance = Math.sqrt((Math.pow( (x2 - x1), 2 )) + (Math.pow( (y2 - y1), 2 )));
  5206. return distance;
  5207. },
  5208. // Events
  5209. onGestureStart: function onGestureStart(e) {
  5210. var swiper = this;
  5211. var params = swiper.params.zoom;
  5212. var zoom = swiper.zoom;
  5213. var gesture = zoom.gesture;
  5214. zoom.fakeGestureTouched = false;
  5215. zoom.fakeGestureMoved = false;
  5216. if (!Support.gestures) {
  5217. if (e.type !== 'touchstart' || (e.type === 'touchstart' && e.targetTouches.length < 2)) {
  5218. return;
  5219. }
  5220. zoom.fakeGestureTouched = true;
  5221. gesture.scaleStart = Zoom.getDistanceBetweenTouches(e);
  5222. }
  5223. if (!gesture.$slideEl || !gesture.$slideEl.length) {
  5224. gesture.$slideEl = $(e.target).closest('.swiper-slide');
  5225. if (gesture.$slideEl.length === 0) { gesture.$slideEl = swiper.slides.eq(swiper.activeIndex); }
  5226. gesture.$imageEl = gesture.$slideEl.find('img, svg, canvas');
  5227. gesture.$imageWrapEl = gesture.$imageEl.parent(("." + (params.containerClass)));
  5228. gesture.maxRatio = gesture.$imageWrapEl.attr('data-swiper-zoom') || params.maxRatio;
  5229. if (gesture.$imageWrapEl.length === 0) {
  5230. gesture.$imageEl = undefined;
  5231. return;
  5232. }
  5233. }
  5234. gesture.$imageEl.transition(0);
  5235. swiper.zoom.isScaling = true;
  5236. },
  5237. onGestureChange: function onGestureChange(e) {
  5238. var swiper = this;
  5239. var params = swiper.params.zoom;
  5240. var zoom = swiper.zoom;
  5241. var gesture = zoom.gesture;
  5242. if (!Support.gestures) {
  5243. if (e.type !== 'touchmove' || (e.type === 'touchmove' && e.targetTouches.length < 2)) {
  5244. return;
  5245. }
  5246. zoom.fakeGestureMoved = true;
  5247. gesture.scaleMove = Zoom.getDistanceBetweenTouches(e);
  5248. }
  5249. if (!gesture.$imageEl || gesture.$imageEl.length === 0) { return; }
  5250. if (Support.gestures) {
  5251. swiper.zoom.scale = e.scale * zoom.currentScale;
  5252. } else {
  5253. zoom.scale = (gesture.scaleMove / gesture.scaleStart) * zoom.currentScale;
  5254. }
  5255. if (zoom.scale > gesture.maxRatio) {
  5256. zoom.scale = (gesture.maxRatio - 1) + (Math.pow( ((zoom.scale - gesture.maxRatio) + 1), 0.5 ));
  5257. }
  5258. if (zoom.scale < params.minRatio) {
  5259. zoom.scale = (params.minRatio + 1) - (Math.pow( ((params.minRatio - zoom.scale) + 1), 0.5 ));
  5260. }
  5261. gesture.$imageEl.transform(("translate3d(0,0,0) scale(" + (zoom.scale) + ")"));
  5262. },
  5263. onGestureEnd: function onGestureEnd(e) {
  5264. var swiper = this;
  5265. var params = swiper.params.zoom;
  5266. var zoom = swiper.zoom;
  5267. var gesture = zoom.gesture;
  5268. if (!Support.gestures) {
  5269. if (!zoom.fakeGestureTouched || !zoom.fakeGestureMoved) {
  5270. return;
  5271. }
  5272. if (e.type !== 'touchend' || (e.type === 'touchend' && e.changedTouches.length < 2 && !Device.android)) {
  5273. return;
  5274. }
  5275. zoom.fakeGestureTouched = false;
  5276. zoom.fakeGestureMoved = false;
  5277. }
  5278. if (!gesture.$imageEl || gesture.$imageEl.length === 0) { return; }
  5279. zoom.scale = Math.max(Math.min(zoom.scale, gesture.maxRatio), params.minRatio);
  5280. gesture.$imageEl.transition(swiper.params.speed).transform(("translate3d(0,0,0) scale(" + (zoom.scale) + ")"));
  5281. zoom.currentScale = zoom.scale;
  5282. zoom.isScaling = false;
  5283. if (zoom.scale === 1) { gesture.$slideEl = undefined; }
  5284. },
  5285. onTouchStart: function onTouchStart(e) {
  5286. var swiper = this;
  5287. var zoom = swiper.zoom;
  5288. var gesture = zoom.gesture;
  5289. var image = zoom.image;
  5290. if (!gesture.$imageEl || gesture.$imageEl.length === 0) { return; }
  5291. if (image.isTouched) { return; }
  5292. if (Device.android) { e.preventDefault(); }
  5293. image.isTouched = true;
  5294. image.touchesStart.x = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX;
  5295. image.touchesStart.y = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY;
  5296. },
  5297. onTouchMove: function onTouchMove(e) {
  5298. var swiper = this;
  5299. var zoom = swiper.zoom;
  5300. var gesture = zoom.gesture;
  5301. var image = zoom.image;
  5302. var velocity = zoom.velocity;
  5303. if (!gesture.$imageEl || gesture.$imageEl.length === 0) { return; }
  5304. swiper.allowClick = false;
  5305. if (!image.isTouched || !gesture.$slideEl) { return; }
  5306. if (!image.isMoved) {
  5307. image.width = gesture.$imageEl[0].offsetWidth;
  5308. image.height = gesture.$imageEl[0].offsetHeight;
  5309. image.startX = Utils.getTranslate(gesture.$imageWrapEl[0], 'x') || 0;
  5310. image.startY = Utils.getTranslate(gesture.$imageWrapEl[0], 'y') || 0;
  5311. gesture.slideWidth = gesture.$slideEl[0].offsetWidth;
  5312. gesture.slideHeight = gesture.$slideEl[0].offsetHeight;
  5313. gesture.$imageWrapEl.transition(0);
  5314. if (swiper.rtl) {
  5315. image.startX = -image.startX;
  5316. image.startY = -image.startY;
  5317. }
  5318. }
  5319. // Define if we need image drag
  5320. var scaledWidth = image.width * zoom.scale;
  5321. var scaledHeight = image.height * zoom.scale;
  5322. if (scaledWidth < gesture.slideWidth && scaledHeight < gesture.slideHeight) { return; }
  5323. image.minX = Math.min(((gesture.slideWidth / 2) - (scaledWidth / 2)), 0);
  5324. image.maxX = -image.minX;
  5325. image.minY = Math.min(((gesture.slideHeight / 2) - (scaledHeight / 2)), 0);
  5326. image.maxY = -image.minY;
  5327. image.touchesCurrent.x = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX;
  5328. image.touchesCurrent.y = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY;
  5329. if (!image.isMoved && !zoom.isScaling) {
  5330. if (
  5331. swiper.isHorizontal() &&
  5332. (
  5333. (Math.floor(image.minX) === Math.floor(image.startX) && image.touchesCurrent.x < image.touchesStart.x) ||
  5334. (Math.floor(image.maxX) === Math.floor(image.startX) && image.touchesCurrent.x > image.touchesStart.x)
  5335. )
  5336. ) {
  5337. image.isTouched = false;
  5338. return;
  5339. } else if (
  5340. !swiper.isHorizontal() &&
  5341. (
  5342. (Math.floor(image.minY) === Math.floor(image.startY) && image.touchesCurrent.y < image.touchesStart.y) ||
  5343. (Math.floor(image.maxY) === Math.floor(image.startY) && image.touchesCurrent.y > image.touchesStart.y)
  5344. )
  5345. ) {
  5346. image.isTouched = false;
  5347. return;
  5348. }
  5349. }
  5350. e.preventDefault();
  5351. e.stopPropagation();
  5352. image.isMoved = true;
  5353. image.currentX = (image.touchesCurrent.x - image.touchesStart.x) + image.startX;
  5354. image.currentY = (image.touchesCurrent.y - image.touchesStart.y) + image.startY;
  5355. if (image.currentX < image.minX) {
  5356. image.currentX = (image.minX + 1) - (Math.pow( ((image.minX - image.currentX) + 1), 0.8 ));
  5357. }
  5358. if (image.currentX > image.maxX) {
  5359. image.currentX = (image.maxX - 1) + (Math.pow( ((image.currentX - image.maxX) + 1), 0.8 ));
  5360. }
  5361. if (image.currentY < image.minY) {
  5362. image.currentY = (image.minY + 1) - (Math.pow( ((image.minY - image.currentY) + 1), 0.8 ));
  5363. }
  5364. if (image.currentY > image.maxY) {
  5365. image.currentY = (image.maxY - 1) + (Math.pow( ((image.currentY - image.maxY) + 1), 0.8 ));
  5366. }
  5367. // Velocity
  5368. if (!velocity.prevPositionX) { velocity.prevPositionX = image.touchesCurrent.x; }
  5369. if (!velocity.prevPositionY) { velocity.prevPositionY = image.touchesCurrent.y; }
  5370. if (!velocity.prevTime) { velocity.prevTime = Date.now(); }
  5371. velocity.x = (image.touchesCurrent.x - velocity.prevPositionX) / (Date.now() - velocity.prevTime) / 2;
  5372. velocity.y = (image.touchesCurrent.y - velocity.prevPositionY) / (Date.now() - velocity.prevTime) / 2;
  5373. if (Math.abs(image.touchesCurrent.x - velocity.prevPositionX) < 2) { velocity.x = 0; }
  5374. if (Math.abs(image.touchesCurrent.y - velocity.prevPositionY) < 2) { velocity.y = 0; }
  5375. velocity.prevPositionX = image.touchesCurrent.x;
  5376. velocity.prevPositionY = image.touchesCurrent.y;
  5377. velocity.prevTime = Date.now();
  5378. gesture.$imageWrapEl.transform(("translate3d(" + (image.currentX) + "px, " + (image.currentY) + "px,0)"));
  5379. },
  5380. onTouchEnd: function onTouchEnd() {
  5381. var swiper = this;
  5382. var zoom = swiper.zoom;
  5383. var gesture = zoom.gesture;
  5384. var image = zoom.image;
  5385. var velocity = zoom.velocity;
  5386. if (!gesture.$imageEl || gesture.$imageEl.length === 0) { return; }
  5387. if (!image.isTouched || !image.isMoved) {
  5388. image.isTouched = false;
  5389. image.isMoved = false;
  5390. return;
  5391. }
  5392. image.isTouched = false;
  5393. image.isMoved = false;
  5394. var momentumDurationX = 300;
  5395. var momentumDurationY = 300;
  5396. var momentumDistanceX = velocity.x * momentumDurationX;
  5397. var newPositionX = image.currentX + momentumDistanceX;
  5398. var momentumDistanceY = velocity.y * momentumDurationY;
  5399. var newPositionY = image.currentY + momentumDistanceY;
  5400. // Fix duration
  5401. if (velocity.x !== 0) { momentumDurationX = Math.abs((newPositionX - image.currentX) / velocity.x); }
  5402. if (velocity.y !== 0) { momentumDurationY = Math.abs((newPositionY - image.currentY) / velocity.y); }
  5403. var momentumDuration = Math.max(momentumDurationX, momentumDurationY);
  5404. image.currentX = newPositionX;
  5405. image.currentY = newPositionY;
  5406. // Define if we need image drag
  5407. var scaledWidth = image.width * zoom.scale;
  5408. var scaledHeight = image.height * zoom.scale;
  5409. image.minX = Math.min(((gesture.slideWidth / 2) - (scaledWidth / 2)), 0);
  5410. image.maxX = -image.minX;
  5411. image.minY = Math.min(((gesture.slideHeight / 2) - (scaledHeight / 2)), 0);
  5412. image.maxY = -image.minY;
  5413. image.currentX = Math.max(Math.min(image.currentX, image.maxX), image.minX);
  5414. image.currentY = Math.max(Math.min(image.currentY, image.maxY), image.minY);
  5415. gesture.$imageWrapEl.transition(momentumDuration).transform(("translate3d(" + (image.currentX) + "px, " + (image.currentY) + "px,0)"));
  5416. },
  5417. onTransitionEnd: function onTransitionEnd() {
  5418. var swiper = this;
  5419. var zoom = swiper.zoom;
  5420. var gesture = zoom.gesture;
  5421. if (gesture.$slideEl && swiper.previousIndex !== swiper.activeIndex) {
  5422. gesture.$imageEl.transform('translate3d(0,0,0) scale(1)');
  5423. gesture.$imageWrapEl.transform('translate3d(0,0,0)');
  5424. gesture.$slideEl = undefined;
  5425. gesture.$imageEl = undefined;
  5426. gesture.$imageWrapEl = undefined;
  5427. zoom.scale = 1;
  5428. zoom.currentScale = 1;
  5429. }
  5430. },
  5431. // Toggle Zoom
  5432. toggle: function toggle(e) {
  5433. var swiper = this;
  5434. var zoom = swiper.zoom;
  5435. if (zoom.scale && zoom.scale !== 1) {
  5436. // Zoom Out
  5437. zoom.out();
  5438. } else {
  5439. // Zoom In
  5440. zoom.in(e);
  5441. }
  5442. },
  5443. in: function in$1(e) {
  5444. var swiper = this;
  5445. var zoom = swiper.zoom;
  5446. var params = swiper.params.zoom;
  5447. var gesture = zoom.gesture;
  5448. var image = zoom.image;
  5449. if (!gesture.$slideEl) {
  5450. gesture.$slideEl = swiper.clickedSlide ? $(swiper.clickedSlide) : swiper.slides.eq(swiper.activeIndex);
  5451. gesture.$imageEl = gesture.$slideEl.find('img, svg, canvas');
  5452. gesture.$imageWrapEl = gesture.$imageEl.parent(("." + (params.containerClass)));
  5453. }
  5454. if (!gesture.$imageEl || gesture.$imageEl.length === 0) { return; }
  5455. gesture.$slideEl.addClass(("" + (params.zoomedSlideClass)));
  5456. var touchX;
  5457. var touchY;
  5458. var offsetX;
  5459. var offsetY;
  5460. var diffX;
  5461. var diffY;
  5462. var translateX;
  5463. var translateY;
  5464. var imageWidth;
  5465. var imageHeight;
  5466. var scaledWidth;
  5467. var scaledHeight;
  5468. var translateMinX;
  5469. var translateMinY;
  5470. var translateMaxX;
  5471. var translateMaxY;
  5472. var slideWidth;
  5473. var slideHeight;
  5474. if (typeof image.touchesStart.x === 'undefined' && e) {
  5475. touchX = e.type === 'touchend' ? e.changedTouches[0].pageX : e.pageX;
  5476. touchY = e.type === 'touchend' ? e.changedTouches[0].pageY : e.pageY;
  5477. } else {
  5478. touchX = image.touchesStart.x;
  5479. touchY = image.touchesStart.y;
  5480. }
  5481. zoom.scale = gesture.$imageWrapEl.attr('data-swiper-zoom') || params.maxRatio;
  5482. zoom.currentScale = gesture.$imageWrapEl.attr('data-swiper-zoom') || params.maxRatio;
  5483. if (e) {
  5484. slideWidth = gesture.$slideEl[0].offsetWidth;
  5485. slideHeight = gesture.$slideEl[0].offsetHeight;
  5486. offsetX = gesture.$slideEl.offset().left;
  5487. offsetY = gesture.$slideEl.offset().top;
  5488. diffX = (offsetX + (slideWidth / 2)) - touchX;
  5489. diffY = (offsetY + (slideHeight / 2)) - touchY;
  5490. imageWidth = gesture.$imageEl[0].offsetWidth;
  5491. imageHeight = gesture.$imageEl[0].offsetHeight;
  5492. scaledWidth = imageWidth * zoom.scale;
  5493. scaledHeight = imageHeight * zoom.scale;
  5494. translateMinX = Math.min(((slideWidth / 2) - (scaledWidth / 2)), 0);
  5495. translateMinY = Math.min(((slideHeight / 2) - (scaledHeight / 2)), 0);
  5496. translateMaxX = -translateMinX;
  5497. translateMaxY = -translateMinY;
  5498. translateX = diffX * zoom.scale;
  5499. translateY = diffY * zoom.scale;
  5500. if (translateX < translateMinX) {
  5501. translateX = translateMinX;
  5502. }
  5503. if (translateX > translateMaxX) {
  5504. translateX = translateMaxX;
  5505. }
  5506. if (translateY < translateMinY) {
  5507. translateY = translateMinY;
  5508. }
  5509. if (translateY > translateMaxY) {
  5510. translateY = translateMaxY;
  5511. }
  5512. } else {
  5513. translateX = 0;
  5514. translateY = 0;
  5515. }
  5516. gesture.$imageWrapEl.transition(300).transform(("translate3d(" + translateX + "px, " + translateY + "px,0)"));
  5517. gesture.$imageEl.transition(300).transform(("translate3d(0,0,0) scale(" + (zoom.scale) + ")"));
  5518. },
  5519. out: function out() {
  5520. var swiper = this;
  5521. var zoom = swiper.zoom;
  5522. var params = swiper.params.zoom;
  5523. var gesture = zoom.gesture;
  5524. if (!gesture.$slideEl) {
  5525. gesture.$slideEl = swiper.clickedSlide ? $(swiper.clickedSlide) : swiper.slides.eq(swiper.activeIndex);
  5526. gesture.$imageEl = gesture.$slideEl.find('img, svg, canvas');
  5527. gesture.$imageWrapEl = gesture.$imageEl.parent(("." + (params.containerClass)));
  5528. }
  5529. if (!gesture.$imageEl || gesture.$imageEl.length === 0) { return; }
  5530. zoom.scale = 1;
  5531. zoom.currentScale = 1;
  5532. gesture.$imageWrapEl.transition(300).transform('translate3d(0,0,0)');
  5533. gesture.$imageEl.transition(300).transform('translate3d(0,0,0) scale(1)');
  5534. gesture.$slideEl.removeClass(("" + (params.zoomedSlideClass)));
  5535. gesture.$slideEl = undefined;
  5536. },
  5537. // Attach/Detach Events
  5538. enable: function enable() {
  5539. var swiper = this;
  5540. var zoom = swiper.zoom;
  5541. if (zoom.enabled) { return; }
  5542. zoom.enabled = true;
  5543. var passiveListener = swiper.touchEvents.start === 'touchstart' && Support.passiveListener && swiper.params.passiveListeners ? { passive: true, capture: false } : false;
  5544. // Scale image
  5545. if (Support.gestures) {
  5546. swiper.$wrapperEl.on('gesturestart', '.swiper-slide', zoom.onGestureStart, passiveListener);
  5547. swiper.$wrapperEl.on('gesturechange', '.swiper-slide', zoom.onGestureChange, passiveListener);
  5548. swiper.$wrapperEl.on('gestureend', '.swiper-slide', zoom.onGestureEnd, passiveListener);
  5549. } else if (swiper.touchEvents.start === 'touchstart') {
  5550. swiper.$wrapperEl.on(swiper.touchEvents.start, '.swiper-slide', zoom.onGestureStart, passiveListener);
  5551. swiper.$wrapperEl.on(swiper.touchEvents.move, '.swiper-slide', zoom.onGestureChange, passiveListener);
  5552. swiper.$wrapperEl.on(swiper.touchEvents.end, '.swiper-slide', zoom.onGestureEnd, passiveListener);
  5553. }
  5554. // Move image
  5555. swiper.$wrapperEl.on(swiper.touchEvents.move, ("." + (swiper.params.zoom.containerClass)), zoom.onTouchMove);
  5556. },
  5557. disable: function disable() {
  5558. var swiper = this;
  5559. var zoom = swiper.zoom;
  5560. if (!zoom.enabled) { return; }
  5561. swiper.zoom.enabled = false;
  5562. var passiveListener = swiper.touchEvents.start === 'touchstart' && Support.passiveListener && swiper.params.passiveListeners ? { passive: true, capture: false } : false;
  5563. // Scale image
  5564. if (Support.gestures) {
  5565. swiper.$wrapperEl.off('gesturestart', '.swiper-slide', zoom.onGestureStart, passiveListener);
  5566. swiper.$wrapperEl.off('gesturechange', '.swiper-slide', zoom.onGestureChange, passiveListener);
  5567. swiper.$wrapperEl.off('gestureend', '.swiper-slide', zoom.onGestureEnd, passiveListener);
  5568. } else if (swiper.touchEvents.start === 'touchstart') {
  5569. swiper.$wrapperEl.off(swiper.touchEvents.start, '.swiper-slide', zoom.onGestureStart, passiveListener);
  5570. swiper.$wrapperEl.off(swiper.touchEvents.move, '.swiper-slide', zoom.onGestureChange, passiveListener);
  5571. swiper.$wrapperEl.off(swiper.touchEvents.end, '.swiper-slide', zoom.onGestureEnd, passiveListener);
  5572. }
  5573. // Move image
  5574. swiper.$wrapperEl.off(swiper.touchEvents.move, ("." + (swiper.params.zoom.containerClass)), zoom.onTouchMove);
  5575. },
  5576. };
  5577. var Zoom$1 = {
  5578. name: 'zoom',
  5579. params: {
  5580. zoom: {
  5581. enabled: false,
  5582. maxRatio: 3,
  5583. minRatio: 1,
  5584. toggle: true,
  5585. containerClass: 'swiper-zoom-container',
  5586. zoomedSlideClass: 'swiper-slide-zoomed',
  5587. },
  5588. },
  5589. create: function create() {
  5590. var swiper = this;
  5591. var zoom = {
  5592. enabled: false,
  5593. scale: 1,
  5594. currentScale: 1,
  5595. isScaling: false,
  5596. gesture: {
  5597. $slideEl: undefined,
  5598. slideWidth: undefined,
  5599. slideHeight: undefined,
  5600. $imageEl: undefined,
  5601. $imageWrapEl: undefined,
  5602. maxRatio: 3,
  5603. },
  5604. image: {
  5605. isTouched: undefined,
  5606. isMoved: undefined,
  5607. currentX: undefined,
  5608. currentY: undefined,
  5609. minX: undefined,
  5610. minY: undefined,
  5611. maxX: undefined,
  5612. maxY: undefined,
  5613. width: undefined,
  5614. height: undefined,
  5615. startX: undefined,
  5616. startY: undefined,
  5617. touchesStart: {},
  5618. touchesCurrent: {},
  5619. },
  5620. velocity: {
  5621. x: undefined,
  5622. y: undefined,
  5623. prevPositionX: undefined,
  5624. prevPositionY: undefined,
  5625. prevTime: undefined,
  5626. },
  5627. };
  5628. ('onGestureStart onGestureChange onGestureEnd onTouchStart onTouchMove onTouchEnd onTransitionEnd toggle enable disable in out').split(' ').forEach(function (methodName) {
  5629. zoom[methodName] = Zoom[methodName].bind(swiper);
  5630. });
  5631. Utils.extend(swiper, {
  5632. zoom: zoom,
  5633. });
  5634. },
  5635. on: {
  5636. init: function init() {
  5637. var swiper = this;
  5638. if (swiper.params.zoom.enabled) {
  5639. swiper.zoom.enable();
  5640. }
  5641. },
  5642. destroy: function destroy() {
  5643. var swiper = this;
  5644. swiper.zoom.disable();
  5645. },
  5646. touchStart: function touchStart(e) {
  5647. var swiper = this;
  5648. if (!swiper.zoom.enabled) { return; }
  5649. swiper.zoom.onTouchStart(e);
  5650. },
  5651. touchEnd: function touchEnd(e) {
  5652. var swiper = this;
  5653. if (!swiper.zoom.enabled) { return; }
  5654. swiper.zoom.onTouchEnd(e);
  5655. },
  5656. doubleTap: function doubleTap(e) {
  5657. var swiper = this;
  5658. if (swiper.params.zoom.enabled && swiper.zoom.enabled && swiper.params.zoom.toggle) {
  5659. swiper.zoom.toggle(e);
  5660. }
  5661. },
  5662. transitionEnd: function transitionEnd() {
  5663. var swiper = this;
  5664. if (swiper.zoom.enabled && swiper.params.zoom.enabled) {
  5665. swiper.zoom.onTransitionEnd();
  5666. }
  5667. },
  5668. },
  5669. };
  5670. var Lazy = {
  5671. loadInSlide: function loadInSlide(index, loadInDuplicate) {
  5672. if ( loadInDuplicate === void 0 ) loadInDuplicate = true;
  5673. var swiper = this;
  5674. var params = swiper.params.lazy;
  5675. if (typeof index === 'undefined') { return; }
  5676. if (swiper.slides.length === 0) { return; }
  5677. var isVirtual = swiper.virtual && swiper.params.virtual.enabled;
  5678. var $slideEl = isVirtual
  5679. ? swiper.$wrapperEl.children(("." + (swiper.params.slideClass) + "[data-swiper-slide-index=\"" + index + "\"]"))
  5680. : swiper.slides.eq(index);
  5681. var $images = $slideEl.find(("." + (params.elementClass) + ":not(." + (params.loadedClass) + "):not(." + (params.loadingClass) + ")"));
  5682. if ($slideEl.hasClass(params.elementClass) && !$slideEl.hasClass(params.loadedClass) && !$slideEl.hasClass(params.loadingClass)) {
  5683. $images = $images.add($slideEl[0]);
  5684. }
  5685. if ($images.length === 0) { return; }
  5686. $images.each(function (imageIndex, imageEl) {
  5687. var $imageEl = $(imageEl);
  5688. $imageEl.addClass(params.loadingClass);
  5689. var background = $imageEl.attr('data-background');
  5690. var src = $imageEl.attr('data-src');
  5691. var srcset = $imageEl.attr('data-srcset');
  5692. var sizes = $imageEl.attr('data-sizes');
  5693. swiper.loadImage($imageEl[0], (src || background), srcset, sizes, false, function () {
  5694. if (typeof swiper === 'undefined' || swiper === null || !swiper || (swiper && !swiper.params) || swiper.destroyed) { return; }
  5695. if (background) {
  5696. $imageEl.css('background-image', ("url(\"" + background + "\")"));
  5697. $imageEl.removeAttr('data-background');
  5698. } else {
  5699. if (srcset) {
  5700. $imageEl.attr('srcset', srcset);
  5701. $imageEl.removeAttr('data-srcset');
  5702. }
  5703. if (sizes) {
  5704. $imageEl.attr('sizes', sizes);
  5705. $imageEl.removeAttr('data-sizes');
  5706. }
  5707. if (src) {
  5708. $imageEl.attr('src', src);
  5709. $imageEl.removeAttr('data-src');
  5710. }
  5711. }
  5712. $imageEl.addClass(params.loadedClass).removeClass(params.loadingClass);
  5713. $slideEl.find(("." + (params.preloaderClass))).remove();
  5714. if (swiper.params.loop && loadInDuplicate) {
  5715. var slideOriginalIndex = $slideEl.attr('data-swiper-slide-index');
  5716. if ($slideEl.hasClass(swiper.params.slideDuplicateClass)) {
  5717. var originalSlide = swiper.$wrapperEl.children(("[data-swiper-slide-index=\"" + slideOriginalIndex + "\"]:not(." + (swiper.params.slideDuplicateClass) + ")"));
  5718. swiper.lazy.loadInSlide(originalSlide.index(), false);
  5719. } else {
  5720. var duplicatedSlide = swiper.$wrapperEl.children(("." + (swiper.params.slideDuplicateClass) + "[data-swiper-slide-index=\"" + slideOriginalIndex + "\"]"));
  5721. swiper.lazy.loadInSlide(duplicatedSlide.index(), false);
  5722. }
  5723. }
  5724. swiper.emit('lazyImageReady', $slideEl[0], $imageEl[0]);
  5725. });
  5726. swiper.emit('lazyImageLoad', $slideEl[0], $imageEl[0]);
  5727. });
  5728. },
  5729. load: function load() {
  5730. var swiper = this;
  5731. var $wrapperEl = swiper.$wrapperEl;
  5732. var swiperParams = swiper.params;
  5733. var slides = swiper.slides;
  5734. var activeIndex = swiper.activeIndex;
  5735. var isVirtual = swiper.virtual && swiperParams.virtual.enabled;
  5736. var params = swiperParams.lazy;
  5737. var slidesPerView = swiperParams.slidesPerView;
  5738. if (slidesPerView === 'auto') {
  5739. slidesPerView = 0;
  5740. }
  5741. function slideExist(index) {
  5742. if (isVirtual) {
  5743. if ($wrapperEl.children(("." + (swiperParams.slideClass) + "[data-swiper-slide-index=\"" + index + "\"]")).length) {
  5744. return true;
  5745. }
  5746. } else if (slides[index]) { return true; }
  5747. return false;
  5748. }
  5749. function slideIndex(slideEl) {
  5750. if (isVirtual) {
  5751. return $(slideEl).attr('data-swiper-slide-index');
  5752. }
  5753. return $(slideEl).index();
  5754. }
  5755. if (!swiper.lazy.initialImageLoaded) { swiper.lazy.initialImageLoaded = true; }
  5756. if (swiper.params.watchSlidesVisibility) {
  5757. $wrapperEl.children(("." + (swiperParams.slideVisibleClass))).each(function (elIndex, slideEl) {
  5758. var index = isVirtual ? $(slideEl).attr('data-swiper-slide-index') : $(slideEl).index();
  5759. swiper.lazy.loadInSlide(index);
  5760. });
  5761. } else if (slidesPerView > 1) {
  5762. for (var i = activeIndex; i < activeIndex + slidesPerView; i += 1) {
  5763. if (slideExist(i)) { swiper.lazy.loadInSlide(i); }
  5764. }
  5765. } else {
  5766. swiper.lazy.loadInSlide(activeIndex);
  5767. }
  5768. if (params.loadPrevNext) {
  5769. if (slidesPerView > 1 || (params.loadPrevNextAmount && params.loadPrevNextAmount > 1)) {
  5770. var amount = params.loadPrevNextAmount;
  5771. var spv = slidesPerView;
  5772. var maxIndex = Math.min(activeIndex + spv + Math.max(amount, spv), slides.length);
  5773. var minIndex = Math.max(activeIndex - Math.max(spv, amount), 0);
  5774. // Next Slides
  5775. for (var i$1 = activeIndex + slidesPerView; i$1 < maxIndex; i$1 += 1) {
  5776. if (slideExist(i$1)) { swiper.lazy.loadInSlide(i$1); }
  5777. }
  5778. // Prev Slides
  5779. for (var i$2 = minIndex; i$2 < activeIndex; i$2 += 1) {
  5780. if (slideExist(i$2)) { swiper.lazy.loadInSlide(i$2); }
  5781. }
  5782. } else {
  5783. var nextSlide = $wrapperEl.children(("." + (swiperParams.slideNextClass)));
  5784. if (nextSlide.length > 0) { swiper.lazy.loadInSlide(slideIndex(nextSlide)); }
  5785. var prevSlide = $wrapperEl.children(("." + (swiperParams.slidePrevClass)));
  5786. if (prevSlide.length > 0) { swiper.lazy.loadInSlide(slideIndex(prevSlide)); }
  5787. }
  5788. }
  5789. },
  5790. };
  5791. var Lazy$1 = {
  5792. name: 'lazy',
  5793. params: {
  5794. lazy: {
  5795. enabled: false,
  5796. loadPrevNext: false,
  5797. loadPrevNextAmount: 1,
  5798. loadOnTransitionStart: false,
  5799. elementClass: 'swiper-lazy',
  5800. loadingClass: 'swiper-lazy-loading',
  5801. loadedClass: 'swiper-lazy-loaded',
  5802. preloaderClass: 'swiper-lazy-preloader',
  5803. },
  5804. },
  5805. create: function create() {
  5806. var swiper = this;
  5807. Utils.extend(swiper, {
  5808. lazy: {
  5809. initialImageLoaded: false,
  5810. load: Lazy.load.bind(swiper),
  5811. loadInSlide: Lazy.loadInSlide.bind(swiper),
  5812. },
  5813. });
  5814. },
  5815. on: {
  5816. beforeInit: function beforeInit() {
  5817. var swiper = this;
  5818. if (swiper.params.lazy.enabled && swiper.params.preloadImages) {
  5819. swiper.params.preloadImages = false;
  5820. }
  5821. },
  5822. init: function init() {
  5823. var swiper = this;
  5824. if (swiper.params.lazy.enabled && !swiper.params.loop && swiper.params.initialSlide === 0) {
  5825. swiper.lazy.load();
  5826. }
  5827. },
  5828. scroll: function scroll() {
  5829. var swiper = this;
  5830. if (swiper.params.freeMode && !swiper.params.freeModeSticky) {
  5831. swiper.lazy.load();
  5832. }
  5833. },
  5834. resize: function resize() {
  5835. var swiper = this;
  5836. if (swiper.params.lazy.enabled) {
  5837. swiper.lazy.load();
  5838. }
  5839. },
  5840. scrollbarDragMove: function scrollbarDragMove() {
  5841. var swiper = this;
  5842. if (swiper.params.lazy.enabled) {
  5843. swiper.lazy.load();
  5844. }
  5845. },
  5846. transitionStart: function transitionStart() {
  5847. var swiper = this;
  5848. if (swiper.params.lazy.enabled) {
  5849. if (swiper.params.lazy.loadOnTransitionStart || (!swiper.params.lazy.loadOnTransitionStart && !swiper.lazy.initialImageLoaded)) {
  5850. swiper.lazy.load();
  5851. }
  5852. }
  5853. },
  5854. transitionEnd: function transitionEnd() {
  5855. var swiper = this;
  5856. if (swiper.params.lazy.enabled && !swiper.params.lazy.loadOnTransitionStart) {
  5857. swiper.lazy.load();
  5858. }
  5859. },
  5860. },
  5861. };
  5862. /* eslint no-bitwise: ["error", { "allow": [">>"] }] */
  5863. var Controller = {
  5864. LinearSpline: function LinearSpline(x, y) {
  5865. var binarySearch = (function search() {
  5866. var maxIndex;
  5867. var minIndex;
  5868. var guess;
  5869. return function (array, val) {
  5870. minIndex = -1;
  5871. maxIndex = array.length;
  5872. while (maxIndex - minIndex > 1) {
  5873. guess = maxIndex + minIndex >> 1;
  5874. if (array[guess] <= val) {
  5875. minIndex = guess;
  5876. } else {
  5877. maxIndex = guess;
  5878. }
  5879. }
  5880. return maxIndex;
  5881. };
  5882. }());
  5883. this.x = x;
  5884. this.y = y;
  5885. this.lastIndex = x.length - 1;
  5886. // Given an x value (x2), return the expected y2 value:
  5887. // (x1,y1) is the known point before given value,
  5888. // (x3,y3) is the known point after given value.
  5889. var i1;
  5890. var i3;
  5891. this.interpolate = function interpolate(x2) {
  5892. if (!x2) { return 0; }
  5893. // Get the indexes of x1 and x3 (the array indexes before and after given x2):
  5894. i3 = binarySearch(this.x, x2);
  5895. i1 = i3 - 1;
  5896. // We have our indexes i1 & i3, so we can calculate already:
  5897. // y2 := ((x2−x1) × (y3−y1)) ÷ (x3−x1) + y1
  5898. return (((x2 - this.x[i1]) * (this.y[i3] - this.y[i1])) / (this.x[i3] - this.x[i1])) + this.y[i1];
  5899. };
  5900. return this;
  5901. },
  5902. // xxx: for now i will just save one spline function to to
  5903. getInterpolateFunction: function getInterpolateFunction(c) {
  5904. var swiper = this;
  5905. if (!swiper.controller.spline) {
  5906. swiper.controller.spline = swiper.params.loop ?
  5907. new Controller.LinearSpline(swiper.slidesGrid, c.slidesGrid) :
  5908. new Controller.LinearSpline(swiper.snapGrid, c.snapGrid);
  5909. }
  5910. },
  5911. setTranslate: function setTranslate(setTranslate$1, byController) {
  5912. var swiper = this;
  5913. var controlled = swiper.controller.control;
  5914. var multiplier;
  5915. var controlledTranslate;
  5916. function setControlledTranslate(c) {
  5917. // this will create an Interpolate function based on the snapGrids
  5918. // x is the Grid of the scrolled scroller and y will be the controlled scroller
  5919. // it makes sense to create this only once and recall it for the interpolation
  5920. // the function does a lot of value caching for performance
  5921. var translate = swiper.rtlTranslate ? -swiper.translate : swiper.translate;
  5922. if (swiper.params.controller.by === 'slide') {
  5923. swiper.controller.getInterpolateFunction(c);
  5924. // i am not sure why the values have to be multiplicated this way, tried to invert the snapGrid
  5925. // but it did not work out
  5926. controlledTranslate = -swiper.controller.spline.interpolate(-translate);
  5927. }
  5928. if (!controlledTranslate || swiper.params.controller.by === 'container') {
  5929. multiplier = (c.maxTranslate() - c.minTranslate()) / (swiper.maxTranslate() - swiper.minTranslate());
  5930. controlledTranslate = ((translate - swiper.minTranslate()) * multiplier) + c.minTranslate();
  5931. }
  5932. if (swiper.params.controller.inverse) {
  5933. controlledTranslate = c.maxTranslate() - controlledTranslate;
  5934. }
  5935. c.updateProgress(controlledTranslate);
  5936. c.setTranslate(controlledTranslate, swiper);
  5937. c.updateActiveIndex();
  5938. c.updateSlidesClasses();
  5939. }
  5940. if (Array.isArray(controlled)) {
  5941. for (var i = 0; i < controlled.length; i += 1) {
  5942. if (controlled[i] !== byController && controlled[i] instanceof Swiper) {
  5943. setControlledTranslate(controlled[i]);
  5944. }
  5945. }
  5946. } else if (controlled instanceof Swiper && byController !== controlled) {
  5947. setControlledTranslate(controlled);
  5948. }
  5949. },
  5950. setTransition: function setTransition(duration, byController) {
  5951. var swiper = this;
  5952. var controlled = swiper.controller.control;
  5953. var i;
  5954. function setControlledTransition(c) {
  5955. c.setTransition(duration, swiper);
  5956. if (duration !== 0) {
  5957. c.transitionStart();
  5958. c.$wrapperEl.transitionEnd(function () {
  5959. if (!controlled) { return; }
  5960. if (c.params.loop && swiper.params.controller.by === 'slide') {
  5961. c.loopFix();
  5962. }
  5963. c.transitionEnd();
  5964. });
  5965. }
  5966. }
  5967. if (Array.isArray(controlled)) {
  5968. for (i = 0; i < controlled.length; i += 1) {
  5969. if (controlled[i] !== byController && controlled[i] instanceof Swiper) {
  5970. setControlledTransition(controlled[i]);
  5971. }
  5972. }
  5973. } else if (controlled instanceof Swiper && byController !== controlled) {
  5974. setControlledTransition(controlled);
  5975. }
  5976. },
  5977. };
  5978. var Controller$1 = {
  5979. name: 'controller',
  5980. params: {
  5981. controller: {
  5982. control: undefined,
  5983. inverse: false,
  5984. by: 'slide', // or 'container'
  5985. },
  5986. },
  5987. create: function create() {
  5988. var swiper = this;
  5989. Utils.extend(swiper, {
  5990. controller: {
  5991. control: swiper.params.controller.control,
  5992. getInterpolateFunction: Controller.getInterpolateFunction.bind(swiper),
  5993. setTranslate: Controller.setTranslate.bind(swiper),
  5994. setTransition: Controller.setTransition.bind(swiper),
  5995. },
  5996. });
  5997. },
  5998. on: {
  5999. update: function update() {
  6000. var swiper = this;
  6001. if (!swiper.controller.control) { return; }
  6002. if (swiper.controller.spline) {
  6003. swiper.controller.spline = undefined;
  6004. delete swiper.controller.spline;
  6005. }
  6006. },
  6007. resize: function resize() {
  6008. var swiper = this;
  6009. if (!swiper.controller.control) { return; }
  6010. if (swiper.controller.spline) {
  6011. swiper.controller.spline = undefined;
  6012. delete swiper.controller.spline;
  6013. }
  6014. },
  6015. observerUpdate: function observerUpdate() {
  6016. var swiper = this;
  6017. if (!swiper.controller.control) { return; }
  6018. if (swiper.controller.spline) {
  6019. swiper.controller.spline = undefined;
  6020. delete swiper.controller.spline;
  6021. }
  6022. },
  6023. setTranslate: function setTranslate(translate, byController) {
  6024. var swiper = this;
  6025. if (!swiper.controller.control) { return; }
  6026. swiper.controller.setTranslate(translate, byController);
  6027. },
  6028. setTransition: function setTransition(duration, byController) {
  6029. var swiper = this;
  6030. if (!swiper.controller.control) { return; }
  6031. swiper.controller.setTransition(duration, byController);
  6032. },
  6033. },
  6034. };
  6035. var a11y = {
  6036. makeElFocusable: function makeElFocusable($el) {
  6037. $el.attr('tabIndex', '0');
  6038. return $el;
  6039. },
  6040. addElRole: function addElRole($el, role) {
  6041. $el.attr('role', role);
  6042. return $el;
  6043. },
  6044. addElLabel: function addElLabel($el, label) {
  6045. $el.attr('aria-label', label);
  6046. return $el;
  6047. },
  6048. disableEl: function disableEl($el) {
  6049. $el.attr('aria-disabled', true);
  6050. return $el;
  6051. },
  6052. enableEl: function enableEl($el) {
  6053. $el.attr('aria-disabled', false);
  6054. return $el;
  6055. },
  6056. onEnterKey: function onEnterKey(e) {
  6057. var swiper = this;
  6058. var params = swiper.params.a11y;
  6059. if (e.keyCode !== 13) { return; }
  6060. var $targetEl = $(e.target);
  6061. if (swiper.navigation && swiper.navigation.$nextEl && $targetEl.is(swiper.navigation.$nextEl)) {
  6062. if (!(swiper.isEnd && !swiper.params.loop)) {
  6063. swiper.slideNext();
  6064. }
  6065. if (swiper.isEnd) {
  6066. swiper.a11y.notify(params.lastSlideMessage);
  6067. } else {
  6068. swiper.a11y.notify(params.nextSlideMessage);
  6069. }
  6070. }
  6071. if (swiper.navigation && swiper.navigation.$prevEl && $targetEl.is(swiper.navigation.$prevEl)) {
  6072. if (!(swiper.isBeginning && !swiper.params.loop)) {
  6073. swiper.slidePrev();
  6074. }
  6075. if (swiper.isBeginning) {
  6076. swiper.a11y.notify(params.firstSlideMessage);
  6077. } else {
  6078. swiper.a11y.notify(params.prevSlideMessage);
  6079. }
  6080. }
  6081. if (swiper.pagination && $targetEl.is(("." + (swiper.params.pagination.bulletClass)))) {
  6082. $targetEl[0].click();
  6083. }
  6084. },
  6085. notify: function notify(message) {
  6086. var swiper = this;
  6087. var notification = swiper.a11y.liveRegion;
  6088. if (notification.length === 0) { return; }
  6089. notification.html('');
  6090. notification.html(message);
  6091. },
  6092. updateNavigation: function updateNavigation() {
  6093. var swiper = this;
  6094. if (swiper.params.loop) { return; }
  6095. var ref = swiper.navigation;
  6096. var $nextEl = ref.$nextEl;
  6097. var $prevEl = ref.$prevEl;
  6098. if ($prevEl && $prevEl.length > 0) {
  6099. if (swiper.isBeginning) {
  6100. swiper.a11y.disableEl($prevEl);
  6101. } else {
  6102. swiper.a11y.enableEl($prevEl);
  6103. }
  6104. }
  6105. if ($nextEl && $nextEl.length > 0) {
  6106. if (swiper.isEnd) {
  6107. swiper.a11y.disableEl($nextEl);
  6108. } else {
  6109. swiper.a11y.enableEl($nextEl);
  6110. }
  6111. }
  6112. },
  6113. updatePagination: function updatePagination() {
  6114. var swiper = this;
  6115. var params = swiper.params.a11y;
  6116. if (swiper.pagination && swiper.params.pagination.clickable && swiper.pagination.bullets && swiper.pagination.bullets.length) {
  6117. swiper.pagination.bullets.each(function (bulletIndex, bulletEl) {
  6118. var $bulletEl = $(bulletEl);
  6119. swiper.a11y.makeElFocusable($bulletEl);
  6120. swiper.a11y.addElRole($bulletEl, 'button');
  6121. swiper.a11y.addElLabel($bulletEl, params.paginationBulletMessage.replace(/{{index}}/, $bulletEl.index() + 1));
  6122. });
  6123. }
  6124. },
  6125. init: function init() {
  6126. var swiper = this;
  6127. swiper.$el.append(swiper.a11y.liveRegion);
  6128. // Navigation
  6129. var params = swiper.params.a11y;
  6130. var $nextEl;
  6131. var $prevEl;
  6132. if (swiper.navigation && swiper.navigation.$nextEl) {
  6133. $nextEl = swiper.navigation.$nextEl;
  6134. }
  6135. if (swiper.navigation && swiper.navigation.$prevEl) {
  6136. $prevEl = swiper.navigation.$prevEl;
  6137. }
  6138. if ($nextEl) {
  6139. swiper.a11y.makeElFocusable($nextEl);
  6140. swiper.a11y.addElRole($nextEl, 'button');
  6141. swiper.a11y.addElLabel($nextEl, params.nextSlideMessage);
  6142. $nextEl.on('keydown', swiper.a11y.onEnterKey);
  6143. }
  6144. if ($prevEl) {
  6145. swiper.a11y.makeElFocusable($prevEl);
  6146. swiper.a11y.addElRole($prevEl, 'button');
  6147. swiper.a11y.addElLabel($prevEl, params.prevSlideMessage);
  6148. $prevEl.on('keydown', swiper.a11y.onEnterKey);
  6149. }
  6150. // Pagination
  6151. if (swiper.pagination && swiper.params.pagination.clickable && swiper.pagination.bullets && swiper.pagination.bullets.length) {
  6152. swiper.pagination.$el.on('keydown', ("." + (swiper.params.pagination.bulletClass)), swiper.a11y.onEnterKey);
  6153. }
  6154. },
  6155. destroy: function destroy() {
  6156. var swiper = this;
  6157. if (swiper.a11y.liveRegion && swiper.a11y.liveRegion.length > 0) { swiper.a11y.liveRegion.remove(); }
  6158. var $nextEl;
  6159. var $prevEl;
  6160. if (swiper.navigation && swiper.navigation.$nextEl) {
  6161. $nextEl = swiper.navigation.$nextEl;
  6162. }
  6163. if (swiper.navigation && swiper.navigation.$prevEl) {
  6164. $prevEl = swiper.navigation.$prevEl;
  6165. }
  6166. if ($nextEl) {
  6167. $nextEl.off('keydown', swiper.a11y.onEnterKey);
  6168. }
  6169. if ($prevEl) {
  6170. $prevEl.off('keydown', swiper.a11y.onEnterKey);
  6171. }
  6172. // Pagination
  6173. if (swiper.pagination && swiper.params.pagination.clickable && swiper.pagination.bullets && swiper.pagination.bullets.length) {
  6174. swiper.pagination.$el.off('keydown', ("." + (swiper.params.pagination.bulletClass)), swiper.a11y.onEnterKey);
  6175. }
  6176. },
  6177. };
  6178. var A11y = {
  6179. name: 'a11y',
  6180. params: {
  6181. a11y: {
  6182. enabled: true,
  6183. notificationClass: 'swiper-notification',
  6184. prevSlideMessage: 'Previous slide',
  6185. nextSlideMessage: 'Next slide',
  6186. firstSlideMessage: 'This is the first slide',
  6187. lastSlideMessage: 'This is the last slide',
  6188. paginationBulletMessage: 'Go to slide {{index}}',
  6189. },
  6190. },
  6191. create: function create() {
  6192. var swiper = this;
  6193. Utils.extend(swiper, {
  6194. a11y: {
  6195. liveRegion: $(("<span class=\"" + (swiper.params.a11y.notificationClass) + "\" aria-live=\"assertive\" aria-atomic=\"true\"></span>")),
  6196. },
  6197. });
  6198. Object.keys(a11y).forEach(function (methodName) {
  6199. swiper.a11y[methodName] = a11y[methodName].bind(swiper);
  6200. });
  6201. },
  6202. on: {
  6203. init: function init() {
  6204. var swiper = this;
  6205. if (!swiper.params.a11y.enabled) { return; }
  6206. swiper.a11y.init();
  6207. swiper.a11y.updateNavigation();
  6208. },
  6209. toEdge: function toEdge() {
  6210. var swiper = this;
  6211. if (!swiper.params.a11y.enabled) { return; }
  6212. swiper.a11y.updateNavigation();
  6213. },
  6214. fromEdge: function fromEdge() {
  6215. var swiper = this;
  6216. if (!swiper.params.a11y.enabled) { return; }
  6217. swiper.a11y.updateNavigation();
  6218. },
  6219. paginationUpdate: function paginationUpdate() {
  6220. var swiper = this;
  6221. if (!swiper.params.a11y.enabled) { return; }
  6222. swiper.a11y.updatePagination();
  6223. },
  6224. destroy: function destroy() {
  6225. var swiper = this;
  6226. if (!swiper.params.a11y.enabled) { return; }
  6227. swiper.a11y.destroy();
  6228. },
  6229. },
  6230. };
  6231. var History = {
  6232. init: function init() {
  6233. var swiper = this;
  6234. if (!swiper.params.history) { return; }
  6235. if (!win.history || !win.history.pushState) {
  6236. swiper.params.history.enabled = false;
  6237. swiper.params.hashNavigation.enabled = true;
  6238. return;
  6239. }
  6240. var history = swiper.history;
  6241. history.initialized = true;
  6242. history.paths = History.getPathValues();
  6243. if (!history.paths.key && !history.paths.value) { return; }
  6244. history.scrollToSlide(0, history.paths.value, swiper.params.runCallbacksOnInit);
  6245. if (!swiper.params.history.replaceState) {
  6246. win.addEventListener('popstate', swiper.history.setHistoryPopState);
  6247. }
  6248. },
  6249. destroy: function destroy() {
  6250. var swiper = this;
  6251. if (!swiper.params.history.replaceState) {
  6252. win.removeEventListener('popstate', swiper.history.setHistoryPopState);
  6253. }
  6254. },
  6255. setHistoryPopState: function setHistoryPopState() {
  6256. var swiper = this;
  6257. swiper.history.paths = History.getPathValues();
  6258. swiper.history.scrollToSlide(swiper.params.speed, swiper.history.paths.value, false);
  6259. },
  6260. getPathValues: function getPathValues() {
  6261. var pathArray = win.location.pathname.slice(1).split('/').filter(function (part) { return part !== ''; });
  6262. var total = pathArray.length;
  6263. var key = pathArray[total - 2];
  6264. var value = pathArray[total - 1];
  6265. return { key: key, value: value };
  6266. },
  6267. setHistory: function setHistory(key, index) {
  6268. var swiper = this;
  6269. if (!swiper.history.initialized || !swiper.params.history.enabled) { return; }
  6270. var slide = swiper.slides.eq(index);
  6271. var value = History.slugify(slide.attr('data-history'));
  6272. if (!win.location.pathname.includes(key)) {
  6273. value = key + "/" + value;
  6274. }
  6275. var currentState = win.history.state;
  6276. if (currentState && currentState.value === value) {
  6277. return;
  6278. }
  6279. if (swiper.params.history.replaceState) {
  6280. win.history.replaceState({ value: value }, null, value);
  6281. } else {
  6282. win.history.pushState({ value: value }, null, value);
  6283. }
  6284. },
  6285. slugify: function slugify(text) {
  6286. return text.toString().toLowerCase()
  6287. .replace(/\s+/g, '-')
  6288. .replace(/[^\w-]+/g, '')
  6289. .replace(/--+/g, '-')
  6290. .replace(/^-+/, '')
  6291. .replace(/-+$/, '');
  6292. },
  6293. scrollToSlide: function scrollToSlide(speed, value, runCallbacks) {
  6294. var swiper = this;
  6295. if (value) {
  6296. for (var i = 0, length = swiper.slides.length; i < length; i += 1) {
  6297. var slide = swiper.slides.eq(i);
  6298. var slideHistory = History.slugify(slide.attr('data-history'));
  6299. if (slideHistory === value && !slide.hasClass(swiper.params.slideDuplicateClass)) {
  6300. var index = slide.index();
  6301. swiper.slideTo(index, speed, runCallbacks);
  6302. }
  6303. }
  6304. } else {
  6305. swiper.slideTo(0, speed, runCallbacks);
  6306. }
  6307. },
  6308. };
  6309. var History$1 = {
  6310. name: 'history',
  6311. params: {
  6312. history: {
  6313. enabled: false,
  6314. replaceState: false,
  6315. key: 'slides',
  6316. },
  6317. },
  6318. create: function create() {
  6319. var swiper = this;
  6320. Utils.extend(swiper, {
  6321. history: {
  6322. init: History.init.bind(swiper),
  6323. setHistory: History.setHistory.bind(swiper),
  6324. setHistoryPopState: History.setHistoryPopState.bind(swiper),
  6325. scrollToSlide: History.scrollToSlide.bind(swiper),
  6326. destroy: History.destroy.bind(swiper),
  6327. },
  6328. });
  6329. },
  6330. on: {
  6331. init: function init() {
  6332. var swiper = this;
  6333. if (swiper.params.history.enabled) {
  6334. swiper.history.init();
  6335. }
  6336. },
  6337. destroy: function destroy() {
  6338. var swiper = this;
  6339. if (swiper.params.history.enabled) {
  6340. swiper.history.destroy();
  6341. }
  6342. },
  6343. transitionEnd: function transitionEnd() {
  6344. var swiper = this;
  6345. if (swiper.history.initialized) {
  6346. swiper.history.setHistory(swiper.params.history.key, swiper.activeIndex);
  6347. }
  6348. },
  6349. },
  6350. };
  6351. var HashNavigation = {
  6352. onHashCange: function onHashCange() {
  6353. var swiper = this;
  6354. var newHash = doc.location.hash.replace('#', '');
  6355. var activeSlideHash = swiper.slides.eq(swiper.activeIndex).attr('data-hash');
  6356. if (newHash !== activeSlideHash) {
  6357. swiper.slideTo(swiper.$wrapperEl.children(("." + (swiper.params.slideClass) + "[data-hash=\"" + newHash + "\"]")).index());
  6358. }
  6359. },
  6360. setHash: function setHash() {
  6361. var swiper = this;
  6362. if (!swiper.hashNavigation.initialized || !swiper.params.hashNavigation.enabled) { return; }
  6363. if (swiper.params.hashNavigation.replaceState && win.history && win.history.replaceState) {
  6364. win.history.replaceState(null, null, (("#" + (swiper.slides.eq(swiper.activeIndex).attr('data-hash'))) || ''));
  6365. } else {
  6366. var slide = swiper.slides.eq(swiper.activeIndex);
  6367. var hash = slide.attr('data-hash') || slide.attr('data-history');
  6368. doc.location.hash = hash || '';
  6369. }
  6370. },
  6371. init: function init() {
  6372. var swiper = this;
  6373. if (!swiper.params.hashNavigation.enabled || (swiper.params.history && swiper.params.history.enabled)) { return; }
  6374. swiper.hashNavigation.initialized = true;
  6375. var hash = doc.location.hash.replace('#', '');
  6376. if (hash) {
  6377. var speed = 0;
  6378. for (var i = 0, length = swiper.slides.length; i < length; i += 1) {
  6379. var slide = swiper.slides.eq(i);
  6380. var slideHash = slide.attr('data-hash') || slide.attr('data-history');
  6381. if (slideHash === hash && !slide.hasClass(swiper.params.slideDuplicateClass)) {
  6382. var index = slide.index();
  6383. swiper.slideTo(index, speed, swiper.params.runCallbacksOnInit, true);
  6384. }
  6385. }
  6386. }
  6387. if (swiper.params.hashNavigation.watchState) {
  6388. $(win).on('hashchange', swiper.hashNavigation.onHashCange);
  6389. }
  6390. },
  6391. destroy: function destroy() {
  6392. var swiper = this;
  6393. if (swiper.params.hashNavigation.watchState) {
  6394. $(win).off('hashchange', swiper.hashNavigation.onHashCange);
  6395. }
  6396. },
  6397. };
  6398. var HashNavigation$1 = {
  6399. name: 'hash-navigation',
  6400. params: {
  6401. hashNavigation: {
  6402. enabled: false,
  6403. replaceState: false,
  6404. watchState: false,
  6405. },
  6406. },
  6407. create: function create() {
  6408. var swiper = this;
  6409. Utils.extend(swiper, {
  6410. hashNavigation: {
  6411. initialized: false,
  6412. init: HashNavigation.init.bind(swiper),
  6413. destroy: HashNavigation.destroy.bind(swiper),
  6414. setHash: HashNavigation.setHash.bind(swiper),
  6415. onHashCange: HashNavigation.onHashCange.bind(swiper),
  6416. },
  6417. });
  6418. },
  6419. on: {
  6420. init: function init() {
  6421. var swiper = this;
  6422. if (swiper.params.hashNavigation.enabled) {
  6423. swiper.hashNavigation.init();
  6424. }
  6425. },
  6426. destroy: function destroy() {
  6427. var swiper = this;
  6428. if (swiper.params.hashNavigation.enabled) {
  6429. swiper.hashNavigation.destroy();
  6430. }
  6431. },
  6432. transitionEnd: function transitionEnd() {
  6433. var swiper = this;
  6434. if (swiper.hashNavigation.initialized) {
  6435. swiper.hashNavigation.setHash();
  6436. }
  6437. },
  6438. },
  6439. };
  6440. /* eslint no-underscore-dangle: "off" */
  6441. var Autoplay = {
  6442. run: function run() {
  6443. var swiper = this;
  6444. var $activeSlideEl = swiper.slides.eq(swiper.activeIndex);
  6445. var delay = swiper.params.autoplay.delay;
  6446. if ($activeSlideEl.attr('data-swiper-autoplay')) {
  6447. delay = $activeSlideEl.attr('data-swiper-autoplay') || swiper.params.autoplay.delay;
  6448. }
  6449. swiper.autoplay.timeout = Utils.nextTick(function () {
  6450. if (swiper.params.autoplay.reverseDirection) {
  6451. if (swiper.params.loop) {
  6452. swiper.loopFix();
  6453. swiper.slidePrev(swiper.params.speed, true, true);
  6454. swiper.emit('autoplay');
  6455. } else if (!swiper.isBeginning) {
  6456. swiper.slidePrev(swiper.params.speed, true, true);
  6457. swiper.emit('autoplay');
  6458. } else if (!swiper.params.autoplay.stopOnLastSlide) {
  6459. swiper.slideTo(swiper.slides.length - 1, swiper.params.speed, true, true);
  6460. swiper.emit('autoplay');
  6461. } else {
  6462. swiper.autoplay.stop();
  6463. }
  6464. } else if (swiper.params.loop) {
  6465. swiper.loopFix();
  6466. swiper.slideNext(swiper.params.speed, true, true);
  6467. swiper.emit('autoplay');
  6468. } else if (!swiper.isEnd) {
  6469. swiper.slideNext(swiper.params.speed, true, true);
  6470. swiper.emit('autoplay');
  6471. } else if (!swiper.params.autoplay.stopOnLastSlide) {
  6472. swiper.slideTo(0, swiper.params.speed, true, true);
  6473. swiper.emit('autoplay');
  6474. } else {
  6475. swiper.autoplay.stop();
  6476. }
  6477. }, delay);
  6478. },
  6479. start: function start() {
  6480. var swiper = this;
  6481. if (typeof swiper.autoplay.timeout !== 'undefined') { return false; }
  6482. if (swiper.autoplay.running) { return false; }
  6483. swiper.autoplay.running = true;
  6484. swiper.emit('autoplayStart');
  6485. swiper.autoplay.run();
  6486. return true;
  6487. },
  6488. stop: function stop() {
  6489. var swiper = this;
  6490. if (!swiper.autoplay.running) { return false; }
  6491. if (typeof swiper.autoplay.timeout === 'undefined') { return false; }
  6492. if (swiper.autoplay.timeout) {
  6493. clearTimeout(swiper.autoplay.timeout);
  6494. swiper.autoplay.timeout = undefined;
  6495. }
  6496. swiper.autoplay.running = false;
  6497. swiper.emit('autoplayStop');
  6498. return true;
  6499. },
  6500. pause: function pause(speed) {
  6501. var swiper = this;
  6502. if (!swiper.autoplay.running) { return; }
  6503. if (swiper.autoplay.paused) { return; }
  6504. if (swiper.autoplay.timeout) { clearTimeout(swiper.autoplay.timeout); }
  6505. swiper.autoplay.paused = true;
  6506. if (speed === 0 || !swiper.params.autoplay.waitForTransition) {
  6507. swiper.autoplay.paused = false;
  6508. swiper.autoplay.run();
  6509. } else {
  6510. swiper.$wrapperEl[0].addEventListener('transitionend', swiper.autoplay.onTransitionEnd);
  6511. swiper.$wrapperEl[0].addEventListener('webkitTransitionEnd', swiper.autoplay.onTransitionEnd);
  6512. }
  6513. },
  6514. };
  6515. var Autoplay$1 = {
  6516. name: 'autoplay',
  6517. params: {
  6518. autoplay: {
  6519. enabled: false,
  6520. delay: 3000,
  6521. waitForTransition: true,
  6522. disableOnInteraction: true,
  6523. stopOnLastSlide: false,
  6524. reverseDirection: false,
  6525. },
  6526. },
  6527. create: function create() {
  6528. var swiper = this;
  6529. Utils.extend(swiper, {
  6530. autoplay: {
  6531. running: false,
  6532. paused: false,
  6533. run: Autoplay.run.bind(swiper),
  6534. start: Autoplay.start.bind(swiper),
  6535. stop: Autoplay.stop.bind(swiper),
  6536. pause: Autoplay.pause.bind(swiper),
  6537. onTransitionEnd: function onTransitionEnd(e) {
  6538. if (!swiper || swiper.destroyed || !swiper.$wrapperEl) { return; }
  6539. if (e.target !== this) { return; }
  6540. swiper.$wrapperEl[0].removeEventListener('transitionend', swiper.autoplay.onTransitionEnd);
  6541. swiper.$wrapperEl[0].removeEventListener('webkitTransitionEnd', swiper.autoplay.onTransitionEnd);
  6542. swiper.autoplay.paused = false;
  6543. if (!swiper.autoplay.running) {
  6544. swiper.autoplay.stop();
  6545. } else {
  6546. swiper.autoplay.run();
  6547. }
  6548. },
  6549. },
  6550. });
  6551. },
  6552. on: {
  6553. init: function init() {
  6554. var swiper = this;
  6555. if (swiper.params.autoplay.enabled) {
  6556. swiper.autoplay.start();
  6557. }
  6558. },
  6559. beforeTransitionStart: function beforeTransitionStart(speed, internal) {
  6560. var swiper = this;
  6561. if (swiper.autoplay.running) {
  6562. if (internal || !swiper.params.autoplay.disableOnInteraction) {
  6563. swiper.autoplay.pause(speed);
  6564. } else {
  6565. swiper.autoplay.stop();
  6566. }
  6567. }
  6568. },
  6569. sliderFirstMove: function sliderFirstMove() {
  6570. var swiper = this;
  6571. if (swiper.autoplay.running) {
  6572. if (swiper.params.autoplay.disableOnInteraction) {
  6573. swiper.autoplay.stop();
  6574. } else {
  6575. swiper.autoplay.pause();
  6576. }
  6577. }
  6578. },
  6579. destroy: function destroy() {
  6580. var swiper = this;
  6581. if (swiper.autoplay.running) {
  6582. swiper.autoplay.stop();
  6583. }
  6584. },
  6585. },
  6586. };
  6587. var Fade = {
  6588. setTranslate: function setTranslate() {
  6589. var swiper = this;
  6590. var slides = swiper.slides;
  6591. for (var i = 0; i < slides.length; i += 1) {
  6592. var $slideEl = swiper.slides.eq(i);
  6593. var offset = $slideEl[0].swiperSlideOffset;
  6594. var tx = -offset;
  6595. if (!swiper.params.virtualTranslate) { tx -= swiper.translate; }
  6596. var ty = 0;
  6597. if (!swiper.isHorizontal()) {
  6598. ty = tx;
  6599. tx = 0;
  6600. }
  6601. var slideOpacity = swiper.params.fadeEffect.crossFade ?
  6602. Math.max(1 - Math.abs($slideEl[0].progress), 0) :
  6603. 1 + Math.min(Math.max($slideEl[0].progress, -1), 0);
  6604. $slideEl
  6605. .css({
  6606. opacity: slideOpacity,
  6607. })
  6608. .transform(("translate3d(" + tx + "px, " + ty + "px, 0px)"));
  6609. }
  6610. },
  6611. setTransition: function setTransition(duration) {
  6612. var swiper = this;
  6613. var slides = swiper.slides;
  6614. var $wrapperEl = swiper.$wrapperEl;
  6615. slides.transition(duration);
  6616. if (swiper.params.virtualTranslate && duration !== 0) {
  6617. var eventTriggered = false;
  6618. slides.transitionEnd(function () {
  6619. if (eventTriggered) { return; }
  6620. if (!swiper || swiper.destroyed) { return; }
  6621. eventTriggered = true;
  6622. swiper.animating = false;
  6623. var triggerEvents = ['webkitTransitionEnd', 'transitionend'];
  6624. for (var i = 0; i < triggerEvents.length; i += 1) {
  6625. $wrapperEl.trigger(triggerEvents[i]);
  6626. }
  6627. });
  6628. }
  6629. },
  6630. };
  6631. var EffectFade = {
  6632. name: 'effect-fade',
  6633. params: {
  6634. fadeEffect: {
  6635. crossFade: false,
  6636. },
  6637. },
  6638. create: function create() {
  6639. var swiper = this;
  6640. Utils.extend(swiper, {
  6641. fadeEffect: {
  6642. setTranslate: Fade.setTranslate.bind(swiper),
  6643. setTransition: Fade.setTransition.bind(swiper),
  6644. },
  6645. });
  6646. },
  6647. on: {
  6648. beforeInit: function beforeInit() {
  6649. var swiper = this;
  6650. if (swiper.params.effect !== 'fade') { return; }
  6651. swiper.classNames.push(((swiper.params.containerModifierClass) + "fade"));
  6652. var overwriteParams = {
  6653. slidesPerView: 1,
  6654. slidesPerColumn: 1,
  6655. slidesPerGroup: 1,
  6656. watchSlidesProgress: true,
  6657. spaceBetween: 0,
  6658. virtualTranslate: true,
  6659. };
  6660. Utils.extend(swiper.params, overwriteParams);
  6661. Utils.extend(swiper.originalParams, overwriteParams);
  6662. },
  6663. setTranslate: function setTranslate() {
  6664. var swiper = this;
  6665. if (swiper.params.effect !== 'fade') { return; }
  6666. swiper.fadeEffect.setTranslate();
  6667. },
  6668. setTransition: function setTransition(duration) {
  6669. var swiper = this;
  6670. if (swiper.params.effect !== 'fade') { return; }
  6671. swiper.fadeEffect.setTransition(duration);
  6672. },
  6673. },
  6674. };
  6675. var Cube = {
  6676. setTranslate: function setTranslate() {
  6677. var swiper = this;
  6678. var $el = swiper.$el;
  6679. var $wrapperEl = swiper.$wrapperEl;
  6680. var slides = swiper.slides;
  6681. var swiperWidth = swiper.width;
  6682. var swiperHeight = swiper.height;
  6683. var rtl = swiper.rtlTranslate;
  6684. var swiperSize = swiper.size;
  6685. var params = swiper.params.cubeEffect;
  6686. var isHorizontal = swiper.isHorizontal();
  6687. var isVirtual = swiper.virtual && swiper.params.virtual.enabled;
  6688. var wrapperRotate = 0;
  6689. var $cubeShadowEl;
  6690. if (params.shadow) {
  6691. if (isHorizontal) {
  6692. $cubeShadowEl = $wrapperEl.find('.swiper-cube-shadow');
  6693. if ($cubeShadowEl.length === 0) {
  6694. $cubeShadowEl = $('<div class="swiper-cube-shadow"></div>');
  6695. $wrapperEl.append($cubeShadowEl);
  6696. }
  6697. $cubeShadowEl.css({ height: (swiperWidth + "px") });
  6698. } else {
  6699. $cubeShadowEl = $el.find('.swiper-cube-shadow');
  6700. if ($cubeShadowEl.length === 0) {
  6701. $cubeShadowEl = $('<div class="swiper-cube-shadow"></div>');
  6702. $el.append($cubeShadowEl);
  6703. }
  6704. }
  6705. }
  6706. for (var i = 0; i < slides.length; i += 1) {
  6707. var $slideEl = slides.eq(i);
  6708. var slideIndex = i;
  6709. if (isVirtual) {
  6710. slideIndex = parseInt($slideEl.attr('data-swiper-slide-index'), 10);
  6711. }
  6712. var slideAngle = slideIndex * 90;
  6713. var round = Math.floor(slideAngle / 360);
  6714. if (rtl) {
  6715. slideAngle = -slideAngle;
  6716. round = Math.floor(-slideAngle / 360);
  6717. }
  6718. var progress = Math.max(Math.min($slideEl[0].progress, 1), -1);
  6719. var tx = 0;
  6720. var ty = 0;
  6721. var tz = 0;
  6722. if (slideIndex % 4 === 0) {
  6723. tx = -round * 4 * swiperSize;
  6724. tz = 0;
  6725. } else if ((slideIndex - 1) % 4 === 0) {
  6726. tx = 0;
  6727. tz = -round * 4 * swiperSize;
  6728. } else if ((slideIndex - 2) % 4 === 0) {
  6729. tx = swiperSize + (round * 4 * swiperSize);
  6730. tz = swiperSize;
  6731. } else if ((slideIndex - 3) % 4 === 0) {
  6732. tx = -swiperSize;
  6733. tz = (3 * swiperSize) + (swiperSize * 4 * round);
  6734. }
  6735. if (rtl) {
  6736. tx = -tx;
  6737. }
  6738. if (!isHorizontal) {
  6739. ty = tx;
  6740. tx = 0;
  6741. }
  6742. var transform = "rotateX(" + (isHorizontal ? 0 : -slideAngle) + "deg) rotateY(" + (isHorizontal ? slideAngle : 0) + "deg) translate3d(" + tx + "px, " + ty + "px, " + tz + "px)";
  6743. if (progress <= 1 && progress > -1) {
  6744. wrapperRotate = (slideIndex * 90) + (progress * 90);
  6745. if (rtl) { wrapperRotate = (-slideIndex * 90) - (progress * 90); }
  6746. }
  6747. $slideEl.transform(transform);
  6748. if (params.slideShadows) {
  6749. // Set shadows
  6750. var shadowBefore = isHorizontal ? $slideEl.find('.swiper-slide-shadow-left') : $slideEl.find('.swiper-slide-shadow-top');
  6751. var shadowAfter = isHorizontal ? $slideEl.find('.swiper-slide-shadow-right') : $slideEl.find('.swiper-slide-shadow-bottom');
  6752. if (shadowBefore.length === 0) {
  6753. shadowBefore = $(("<div class=\"swiper-slide-shadow-" + (isHorizontal ? 'left' : 'top') + "\"></div>"));
  6754. $slideEl.append(shadowBefore);
  6755. }
  6756. if (shadowAfter.length === 0) {
  6757. shadowAfter = $(("<div class=\"swiper-slide-shadow-" + (isHorizontal ? 'right' : 'bottom') + "\"></div>"));
  6758. $slideEl.append(shadowAfter);
  6759. }
  6760. if (shadowBefore.length) { shadowBefore[0].style.opacity = Math.max(-progress, 0); }
  6761. if (shadowAfter.length) { shadowAfter[0].style.opacity = Math.max(progress, 0); }
  6762. }
  6763. }
  6764. $wrapperEl.css({
  6765. '-webkit-transform-origin': ("50% 50% -" + (swiperSize / 2) + "px"),
  6766. '-moz-transform-origin': ("50% 50% -" + (swiperSize / 2) + "px"),
  6767. '-ms-transform-origin': ("50% 50% -" + (swiperSize / 2) + "px"),
  6768. 'transform-origin': ("50% 50% -" + (swiperSize / 2) + "px"),
  6769. });
  6770. if (params.shadow) {
  6771. if (isHorizontal) {
  6772. $cubeShadowEl.transform(("translate3d(0px, " + ((swiperWidth / 2) + params.shadowOffset) + "px, " + (-swiperWidth / 2) + "px) rotateX(90deg) rotateZ(0deg) scale(" + (params.shadowScale) + ")"));
  6773. } else {
  6774. var shadowAngle = Math.abs(wrapperRotate) - (Math.floor(Math.abs(wrapperRotate) / 90) * 90);
  6775. var multiplier = 1.5 - (
  6776. (Math.sin((shadowAngle * 2 * Math.PI) / 360) / 2) +
  6777. (Math.cos((shadowAngle * 2 * Math.PI) / 360) / 2)
  6778. );
  6779. var scale1 = params.shadowScale;
  6780. var scale2 = params.shadowScale / multiplier;
  6781. var offset = params.shadowOffset;
  6782. $cubeShadowEl.transform(("scale3d(" + scale1 + ", 1, " + scale2 + ") translate3d(0px, " + ((swiperHeight / 2) + offset) + "px, " + (-swiperHeight / 2 / scale2) + "px) rotateX(-90deg)"));
  6783. }
  6784. }
  6785. var zFactor = (Browser.isSafari || Browser.isUiWebView) ? (-swiperSize / 2) : 0;
  6786. $wrapperEl
  6787. .transform(("translate3d(0px,0," + zFactor + "px) rotateX(" + (swiper.isHorizontal() ? 0 : wrapperRotate) + "deg) rotateY(" + (swiper.isHorizontal() ? -wrapperRotate : 0) + "deg)"));
  6788. },
  6789. setTransition: function setTransition(duration) {
  6790. var swiper = this;
  6791. var $el = swiper.$el;
  6792. var slides = swiper.slides;
  6793. slides
  6794. .transition(duration)
  6795. .find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left')
  6796. .transition(duration);
  6797. if (swiper.params.cubeEffect.shadow && !swiper.isHorizontal()) {
  6798. $el.find('.swiper-cube-shadow').transition(duration);
  6799. }
  6800. },
  6801. };
  6802. var EffectCube = {
  6803. name: 'effect-cube',
  6804. params: {
  6805. cubeEffect: {
  6806. slideShadows: true,
  6807. shadow: true,
  6808. shadowOffset: 20,
  6809. shadowScale: 0.94,
  6810. },
  6811. },
  6812. create: function create() {
  6813. var swiper = this;
  6814. Utils.extend(swiper, {
  6815. cubeEffect: {
  6816. setTranslate: Cube.setTranslate.bind(swiper),
  6817. setTransition: Cube.setTransition.bind(swiper),
  6818. },
  6819. });
  6820. },
  6821. on: {
  6822. beforeInit: function beforeInit() {
  6823. var swiper = this;
  6824. if (swiper.params.effect !== 'cube') { return; }
  6825. swiper.classNames.push(((swiper.params.containerModifierClass) + "cube"));
  6826. swiper.classNames.push(((swiper.params.containerModifierClass) + "3d"));
  6827. var overwriteParams = {
  6828. slidesPerView: 1,
  6829. slidesPerColumn: 1,
  6830. slidesPerGroup: 1,
  6831. watchSlidesProgress: true,
  6832. resistanceRatio: 0,
  6833. spaceBetween: 0,
  6834. centeredSlides: false,
  6835. virtualTranslate: true,
  6836. };
  6837. Utils.extend(swiper.params, overwriteParams);
  6838. Utils.extend(swiper.originalParams, overwriteParams);
  6839. },
  6840. setTranslate: function setTranslate() {
  6841. var swiper = this;
  6842. if (swiper.params.effect !== 'cube') { return; }
  6843. swiper.cubeEffect.setTranslate();
  6844. },
  6845. setTransition: function setTransition(duration) {
  6846. var swiper = this;
  6847. if (swiper.params.effect !== 'cube') { return; }
  6848. swiper.cubeEffect.setTransition(duration);
  6849. },
  6850. },
  6851. };
  6852. var Flip = {
  6853. setTranslate: function setTranslate() {
  6854. var swiper = this;
  6855. var slides = swiper.slides;
  6856. var rtl = swiper.rtlTranslate;
  6857. for (var i = 0; i < slides.length; i += 1) {
  6858. var $slideEl = slides.eq(i);
  6859. var progress = $slideEl[0].progress;
  6860. if (swiper.params.flipEffect.limitRotation) {
  6861. progress = Math.max(Math.min($slideEl[0].progress, 1), -1);
  6862. }
  6863. var offset = $slideEl[0].swiperSlideOffset;
  6864. var rotate = -180 * progress;
  6865. var rotateY = rotate;
  6866. var rotateX = 0;
  6867. var tx = -offset;
  6868. var ty = 0;
  6869. if (!swiper.isHorizontal()) {
  6870. ty = tx;
  6871. tx = 0;
  6872. rotateX = -rotateY;
  6873. rotateY = 0;
  6874. } else if (rtl) {
  6875. rotateY = -rotateY;
  6876. }
  6877. $slideEl[0].style.zIndex = -Math.abs(Math.round(progress)) + slides.length;
  6878. if (swiper.params.flipEffect.slideShadows) {
  6879. // Set shadows
  6880. var shadowBefore = swiper.isHorizontal() ? $slideEl.find('.swiper-slide-shadow-left') : $slideEl.find('.swiper-slide-shadow-top');
  6881. var shadowAfter = swiper.isHorizontal() ? $slideEl.find('.swiper-slide-shadow-right') : $slideEl.find('.swiper-slide-shadow-bottom');
  6882. if (shadowBefore.length === 0) {
  6883. shadowBefore = $(("<div class=\"swiper-slide-shadow-" + (swiper.isHorizontal() ? 'left' : 'top') + "\"></div>"));
  6884. $slideEl.append(shadowBefore);
  6885. }
  6886. if (shadowAfter.length === 0) {
  6887. shadowAfter = $(("<div class=\"swiper-slide-shadow-" + (swiper.isHorizontal() ? 'right' : 'bottom') + "\"></div>"));
  6888. $slideEl.append(shadowAfter);
  6889. }
  6890. if (shadowBefore.length) { shadowBefore[0].style.opacity = Math.max(-progress, 0); }
  6891. if (shadowAfter.length) { shadowAfter[0].style.opacity = Math.max(progress, 0); }
  6892. }
  6893. $slideEl
  6894. .transform(("translate3d(" + tx + "px, " + ty + "px, 0px) rotateX(" + rotateX + "deg) rotateY(" + rotateY + "deg)"));
  6895. }
  6896. },
  6897. setTransition: function setTransition(duration) {
  6898. var swiper = this;
  6899. var slides = swiper.slides;
  6900. var activeIndex = swiper.activeIndex;
  6901. var $wrapperEl = swiper.$wrapperEl;
  6902. slides
  6903. .transition(duration)
  6904. .find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left')
  6905. .transition(duration);
  6906. if (swiper.params.virtualTranslate && duration !== 0) {
  6907. var eventTriggered = false;
  6908. // eslint-disable-next-line
  6909. slides.eq(activeIndex).transitionEnd(function onTransitionEnd() {
  6910. if (eventTriggered) { return; }
  6911. if (!swiper || swiper.destroyed) { return; }
  6912. // if (!$(this).hasClass(swiper.params.slideActiveClass)) return;
  6913. eventTriggered = true;
  6914. swiper.animating = false;
  6915. var triggerEvents = ['webkitTransitionEnd', 'transitionend'];
  6916. for (var i = 0; i < triggerEvents.length; i += 1) {
  6917. $wrapperEl.trigger(triggerEvents[i]);
  6918. }
  6919. });
  6920. }
  6921. },
  6922. };
  6923. var EffectFlip = {
  6924. name: 'effect-flip',
  6925. params: {
  6926. flipEffect: {
  6927. slideShadows: true,
  6928. limitRotation: true,
  6929. },
  6930. },
  6931. create: function create() {
  6932. var swiper = this;
  6933. Utils.extend(swiper, {
  6934. flipEffect: {
  6935. setTranslate: Flip.setTranslate.bind(swiper),
  6936. setTransition: Flip.setTransition.bind(swiper),
  6937. },
  6938. });
  6939. },
  6940. on: {
  6941. beforeInit: function beforeInit() {
  6942. var swiper = this;
  6943. if (swiper.params.effect !== 'flip') { return; }
  6944. swiper.classNames.push(((swiper.params.containerModifierClass) + "flip"));
  6945. swiper.classNames.push(((swiper.params.containerModifierClass) + "3d"));
  6946. var overwriteParams = {
  6947. slidesPerView: 1,
  6948. slidesPerColumn: 1,
  6949. slidesPerGroup: 1,
  6950. watchSlidesProgress: true,
  6951. spaceBetween: 0,
  6952. virtualTranslate: true,
  6953. };
  6954. Utils.extend(swiper.params, overwriteParams);
  6955. Utils.extend(swiper.originalParams, overwriteParams);
  6956. },
  6957. setTranslate: function setTranslate() {
  6958. var swiper = this;
  6959. if (swiper.params.effect !== 'flip') { return; }
  6960. swiper.flipEffect.setTranslate();
  6961. },
  6962. setTransition: function setTransition(duration) {
  6963. var swiper = this;
  6964. if (swiper.params.effect !== 'flip') { return; }
  6965. swiper.flipEffect.setTransition(duration);
  6966. },
  6967. },
  6968. };
  6969. var Coverflow = {
  6970. setTranslate: function setTranslate() {
  6971. var swiper = this;
  6972. var swiperWidth = swiper.width;
  6973. var swiperHeight = swiper.height;
  6974. var slides = swiper.slides;
  6975. var $wrapperEl = swiper.$wrapperEl;
  6976. var slidesSizesGrid = swiper.slidesSizesGrid;
  6977. var params = swiper.params.coverflowEffect;
  6978. var isHorizontal = swiper.isHorizontal();
  6979. var transform = swiper.translate;
  6980. var center = isHorizontal ? -transform + (swiperWidth / 2) : -transform + (swiperHeight / 2);
  6981. var rotate = isHorizontal ? params.rotate : -params.rotate;
  6982. var translate = params.depth;
  6983. // Each slide offset from center
  6984. for (var i = 0, length = slides.length; i < length; i += 1) {
  6985. var $slideEl = slides.eq(i);
  6986. var slideSize = slidesSizesGrid[i];
  6987. var slideOffset = $slideEl[0].swiperSlideOffset;
  6988. var offsetMultiplier = ((center - slideOffset - (slideSize / 2)) / slideSize) * params.modifier;
  6989. var rotateY = isHorizontal ? rotate * offsetMultiplier : 0;
  6990. var rotateX = isHorizontal ? 0 : rotate * offsetMultiplier;
  6991. // var rotateZ = 0
  6992. var translateZ = -translate * Math.abs(offsetMultiplier);
  6993. var translateY = isHorizontal ? 0 : params.stretch * (offsetMultiplier);
  6994. var translateX = isHorizontal ? params.stretch * (offsetMultiplier) : 0;
  6995. // Fix for ultra small values
  6996. if (Math.abs(translateX) < 0.001) { translateX = 0; }
  6997. if (Math.abs(translateY) < 0.001) { translateY = 0; }
  6998. if (Math.abs(translateZ) < 0.001) { translateZ = 0; }
  6999. if (Math.abs(rotateY) < 0.001) { rotateY = 0; }
  7000. if (Math.abs(rotateX) < 0.001) { rotateX = 0; }
  7001. var slideTransform = "translate3d(" + translateX + "px," + translateY + "px," + translateZ + "px) rotateX(" + rotateX + "deg) rotateY(" + rotateY + "deg)";
  7002. $slideEl.transform(slideTransform);
  7003. $slideEl[0].style.zIndex = -Math.abs(Math.round(offsetMultiplier)) + 1;
  7004. if (params.slideShadows) {
  7005. // Set shadows
  7006. var $shadowBeforeEl = isHorizontal ? $slideEl.find('.swiper-slide-shadow-left') : $slideEl.find('.swiper-slide-shadow-top');
  7007. var $shadowAfterEl = isHorizontal ? $slideEl.find('.swiper-slide-shadow-right') : $slideEl.find('.swiper-slide-shadow-bottom');
  7008. if ($shadowBeforeEl.length === 0) {
  7009. $shadowBeforeEl = $(("<div class=\"swiper-slide-shadow-" + (isHorizontal ? 'left' : 'top') + "\"></div>"));
  7010. $slideEl.append($shadowBeforeEl);
  7011. }
  7012. if ($shadowAfterEl.length === 0) {
  7013. $shadowAfterEl = $(("<div class=\"swiper-slide-shadow-" + (isHorizontal ? 'right' : 'bottom') + "\"></div>"));
  7014. $slideEl.append($shadowAfterEl);
  7015. }
  7016. if ($shadowBeforeEl.length) { $shadowBeforeEl[0].style.opacity = offsetMultiplier > 0 ? offsetMultiplier : 0; }
  7017. if ($shadowAfterEl.length) { $shadowAfterEl[0].style.opacity = (-offsetMultiplier) > 0 ? -offsetMultiplier : 0; }
  7018. }
  7019. }
  7020. // Set correct perspective for IE10
  7021. if (Support.pointerEvents || Support.prefixedPointerEvents) {
  7022. var ws = $wrapperEl[0].style;
  7023. ws.perspectiveOrigin = center + "px 50%";
  7024. }
  7025. },
  7026. setTransition: function setTransition(duration) {
  7027. var swiper = this;
  7028. swiper.slides
  7029. .transition(duration)
  7030. .find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left')
  7031. .transition(duration);
  7032. },
  7033. };
  7034. var EffectCoverflow = {
  7035. name: 'effect-coverflow',
  7036. params: {
  7037. coverflowEffect: {
  7038. rotate: 50,
  7039. stretch: 0,
  7040. depth: 100,
  7041. modifier: 1,
  7042. slideShadows: true,
  7043. },
  7044. },
  7045. create: function create() {
  7046. var swiper = this;
  7047. Utils.extend(swiper, {
  7048. coverflowEffect: {
  7049. setTranslate: Coverflow.setTranslate.bind(swiper),
  7050. setTransition: Coverflow.setTransition.bind(swiper),
  7051. },
  7052. });
  7053. },
  7054. on: {
  7055. beforeInit: function beforeInit() {
  7056. var swiper = this;
  7057. if (swiper.params.effect !== 'coverflow') { return; }
  7058. swiper.classNames.push(((swiper.params.containerModifierClass) + "coverflow"));
  7059. swiper.classNames.push(((swiper.params.containerModifierClass) + "3d"));
  7060. swiper.params.watchSlidesProgress = true;
  7061. swiper.originalParams.watchSlidesProgress = true;
  7062. },
  7063. setTranslate: function setTranslate() {
  7064. var swiper = this;
  7065. if (swiper.params.effect !== 'coverflow') { return; }
  7066. swiper.coverflowEffect.setTranslate();
  7067. },
  7068. setTransition: function setTransition(duration) {
  7069. var swiper = this;
  7070. if (swiper.params.effect !== 'coverflow') { return; }
  7071. swiper.coverflowEffect.setTransition(duration);
  7072. },
  7073. },
  7074. };
  7075. // Swiper Class
  7076. var components = [
  7077. Device$1,
  7078. Support$1,
  7079. Browser$1,
  7080. Resize,
  7081. Observer$1,
  7082. Virtual$1,
  7083. Keyboard$1,
  7084. Mousewheel$1,
  7085. Navigation$1,
  7086. Pagination$1,
  7087. Scrollbar$1,
  7088. Parallax$1,
  7089. Zoom$1,
  7090. Lazy$1,
  7091. Controller$1,
  7092. A11y,
  7093. History$1,
  7094. HashNavigation$1,
  7095. Autoplay$1,
  7096. EffectFade,
  7097. EffectCube,
  7098. EffectFlip,
  7099. EffectCoverflow
  7100. ];
  7101. if (typeof Swiper.use === 'undefined') {
  7102. Swiper.use = Swiper.Class.use;
  7103. Swiper.installModule = Swiper.Class.installModule;
  7104. }
  7105. Swiper.use(components);
  7106. return Swiper;
  7107. })));