swiper.js 274 KB

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