swiper.js 300 KB

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