swiper-bundle.esm.browser.js 280 KB

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