swiper.esm.browser.bundle.js 269 KB

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