swiper.js 275 KB

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