swiper.js 317 KB

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