swiper-bundle.js 322 KB

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