swiper-bundle.js 320 KB

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