swiper.js 275 KB

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