swiper.esm.browser.bundle.js 265 KB

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