swiper.esm.browser.bundle.js 266 KB

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