swiper.js 298 KB

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