swiper-bundle.esm.browser.js 296 KB

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