swiper-bundle.js 331 KB

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