swiper.js 297 KB

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