暂无描述

swiper-bundle.js 206KB

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