swiper-bundle.esm.browser.js 288 KB

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