fullpage.min.js 200 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982
  1. /*!
  2. * fullPage 4.0.20
  3. * https://github.com/alvarotrigo/fullPage.js
  4. *
  5. * @license GPLv3 for open source use only
  6. * or Fullpage Commercial License for commercial use
  7. * http://alvarotrigo.com/fullPage/pricing/
  8. *
  9. * Copyright (C) 2018 http://alvarotrigo.com/fullPage - A project by Alvaro Trigo
  10. */
  11. (function (global, factory) {
  12. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  13. typeof define === 'function' && define.amd ? define(factory) :
  14. (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.fullpage = factory());
  15. })(this, (function () { 'use strict';
  16. // https://tc39.github.io/ecma262/#sec-array.prototype.find
  17. if (!Array.prototype.find) {
  18. Object.defineProperty(Array.prototype, 'find', {
  19. value: function value(predicate) {
  20. // 1. Let O be ? ToObject(this value).
  21. if (this == null) {
  22. throw new TypeError('"this" is null or not defined');
  23. }
  24. var o = Object(this); // 2. Let len be ? ToLength(? Get(O, "length")).
  25. var len = o.length >>> 0; // 3. If IsCallable(predicate) is false, throw a TypeError exception.
  26. if (typeof predicate !== 'function') {
  27. throw new TypeError('predicate must be a function');
  28. } // 4. If thisArg was supplied, let T be thisArg; else let T be undefined.
  29. var thisArg = arguments[1]; // 5. Let k be 0.
  30. var k = 0; // 6. Repeat, while k < len
  31. while (k < len) {
  32. // a. Let Pk be ! ToString(k).
  33. // b. Let kValue be ? Get(O, Pk).
  34. // c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
  35. // d. If testResult is true, return kValue.
  36. var kValue = o[k];
  37. if (predicate.call(thisArg, kValue, k, o)) {
  38. return kValue;
  39. } // e. Increase k by 1.
  40. k++;
  41. } // 7. Return undefined.
  42. return undefined;
  43. }
  44. });
  45. }
  46. // Production steps of ECMA-262, Edition 6, 22.1.2.1
  47. if (!Array.from) {
  48. Array.from = function () {
  49. var toStr = Object.prototype.toString;
  50. var isCallable = function isCallable(fn) {
  51. return typeof fn === 'function' || toStr.call(fn) === '[object Function]';
  52. };
  53. var toInteger = function toInteger(value) {
  54. var number = Number(value);
  55. if (isNaN(number)) {
  56. return 0;
  57. }
  58. if (number === 0 || !isFinite(number)) {
  59. return number;
  60. }
  61. return (number > 0 ? 1 : -1) * Math.floor(Math.abs(number));
  62. };
  63. var maxSafeInteger = Math.pow(2, 53) - 1;
  64. var toLength = function toLength(value) {
  65. var len = toInteger(value);
  66. return Math.min(Math.max(len, 0), maxSafeInteger);
  67. }; // The length property of the from method is 1.
  68. return function from(arrayLike
  69. /*, mapFn, thisArg */
  70. ) {
  71. // 1. Let C be the this value.
  72. var C = this; // 2. Let items be ToObject(arrayLike).
  73. var items = Object(arrayLike); // 3. ReturnIfAbrupt(items).
  74. if (arrayLike == null) {
  75. throw new TypeError('Array.from requires an array-like object - not null or undefined');
  76. } // 4. If mapfn is undefined, then let mapping be false.
  77. var mapFn = arguments.length > 1 ? arguments[1] : void undefined;
  78. var T;
  79. if (typeof mapFn !== 'undefined') {
  80. // 5. else
  81. // 5. a If IsCallable(mapfn) is false, throw a TypeError exception.
  82. if (!isCallable(mapFn)) {
  83. throw new TypeError('Array.from: when provided, the second argument must be a function');
  84. } // 5. b. If thisArg was supplied, let T be thisArg; else let T be undefined.
  85. if (arguments.length > 2) {
  86. T = arguments[2];
  87. }
  88. } // 10. Let lenValue be Get(items, "length").
  89. // 11. Let len be ToLength(lenValue).
  90. var len = toLength(items.length); // 13. If IsConstructor(C) is true, then
  91. // 13. a. Let A be the result of calling the [[Construct]] internal method
  92. // of C with an argument list containing the single item len.
  93. // 14. a. Else, Let A be ArrayCreate(len).
  94. var A = isCallable(C) ? Object(new C(len)) : new Array(len); // 16. Let k be 0.
  95. var k = 0; // 17. Repeat, while k < len… (also steps a - h)
  96. var kValue;
  97. while (k < len) {
  98. kValue = items[k];
  99. if (mapFn) {
  100. A[k] = typeof T === 'undefined' ? mapFn(kValue, k) : mapFn.call(T, kValue, k);
  101. } else {
  102. A[k] = kValue;
  103. }
  104. k += 1;
  105. } // 18. Let putStatus be Put(A, "length", len, true).
  106. A.length = len; // 20. Return A.
  107. return A;
  108. };
  109. }();
  110. }
  111. var win = window;
  112. var doc = document;
  113. var isTouchDevice = navigator.userAgent.match(/(iPhone|iPod|iPad|Android|playbook|silk|BlackBerry|BB10|Windows Phone|Tizen|Bada|webOS|IEMobile|Opera Mini)/);
  114. var isMacDevice = /(Mac|iPhone|iPod|iPad)/i.test(win.navigator.userAgent); // @ts-ignore
  115. var isTouch = 'ontouchstart' in win || navigator.msMaxTouchPoints > 0 || navigator.maxTouchPoints;
  116. var isIE11 = !!window.MSInputMethodContext && !!document.documentMode; // taken from https://github.com/udacity/ud891/blob/gh-pages/lesson2-focus/07-modals-and-keyboard-traps/solution/modal.js
  117. var focusableElementsString = 'a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, [tabindex="0"], [contenteditable]'; // cache common elements
  118. var FP = {
  119. test: {},
  120. shared: {}
  121. };
  122. var extensions = ['parallax', 'scrollOverflowReset', 'dragAndMove', 'offsetSections', 'fadingEffect', 'responsiveSlides', 'continuousHorizontal', 'interlockedSlides', 'scrollHorizontally', 'resetSliders', 'cards', 'dropEffect', 'waterEffect'];
  123. /**
  124. * forEach polyfill for IE
  125. * https://developer.mozilla.org/en-US/docs/Web/API/NodeList/forEach#Browser_Compatibility
  126. */
  127. if (win.NodeList && !NodeList.prototype.forEach) {
  128. NodeList.prototype.forEach = function (callback, thisArg) {
  129. thisArg = thisArg || window;
  130. for (var i = 0; i < this.length; i++) {
  131. callback.call(thisArg, this[i], i, this);
  132. }
  133. };
  134. }
  135. if (typeof Object.assign != 'function') {
  136. // Must be writable: true, enumerable: false, configurable: true
  137. Object.defineProperty(Object, 'assign', {
  138. value: function assign(target, varArgs) {
  139. if (target == null) {
  140. // TypeError if undefined or null
  141. throw new TypeError('Cannot convert undefined or null to object');
  142. }
  143. var to = Object(target);
  144. for (var index = 1; index < arguments.length; index++) {
  145. var nextSource = arguments[index];
  146. if (nextSource != null) {
  147. // Skip over if undefined or null
  148. for (var nextKey in nextSource) {
  149. // Avoid bugs when hasOwnProperty is shadowed
  150. if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
  151. to[nextKey] = nextSource[nextKey];
  152. }
  153. }
  154. }
  155. }
  156. return to;
  157. },
  158. writable: true,
  159. configurable: true
  160. });
  161. }
  162. // https://stackoverflow.com/questions/51719553/padstart-not-working-in-ie11
  163. // https://github.com/behnammodi/polyfill/blob/master/string.polyfill.js
  164. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padStart
  165. if (!String.prototype.padStart) {
  166. String.prototype.padStart = function padStart(targetLength, padString) {
  167. targetLength = targetLength >> 0; //truncate if number or convert non-number to 0;
  168. padString = String(typeof padString !== 'undefined' ? padString : ' ');
  169. if (this.length > targetLength) {
  170. return String(this);
  171. } else {
  172. targetLength = targetLength - this.length;
  173. if (targetLength > padString.length) {
  174. padString += Array.apply(null, Array(targetLength)).map(function () {
  175. return padString;
  176. }).join("");
  177. }
  178. return padString.slice(0, targetLength) + String(this);
  179. }
  180. };
  181. }
  182. //utils
  183. /**
  184. * Shows a message in the console of the given type.
  185. */
  186. function showError(type, text) {
  187. win.console && win.console[type] && win.console[type]('fullPage: ' + text);
  188. }
  189. function isVisible(el) {
  190. var style = win.getComputedStyle(el);
  191. return style.display !== 'none';
  192. }
  193. function getVisible(elements) {
  194. return Array.from(elements).filter(function (e) {
  195. return isVisible(e);
  196. });
  197. }
  198. /**
  199. * Equivalent of jQuery function $().
  200. */
  201. function $(selector, context) {
  202. context = arguments.length > 1 ? context : document;
  203. return context ? context.querySelectorAll(selector) : null;
  204. }
  205. /**
  206. * Extends a given Object properties and its childs.
  207. */
  208. function deepExtend(out) {
  209. out = out || {};
  210. for (var i = 1, len = arguments.length; i < len; ++i) {
  211. var obj = arguments[i];
  212. if (!obj) {
  213. continue;
  214. }
  215. for (var key in obj) {
  216. if (!obj.hasOwnProperty(key) || key == '__proto__' || key == 'constructor') {
  217. continue;
  218. } // based on https://javascriptweblog.wordpress.com/2011/08/08/fixing-the-javascript-typeof-operator/
  219. if (Object.prototype.toString.call(obj[key]) === '[object Object]') {
  220. out[key] = deepExtend(out[key], obj[key]);
  221. continue;
  222. }
  223. out[key] = obj[key];
  224. }
  225. }
  226. return out;
  227. }
  228. /**
  229. * Checks if the passed element contains the passed class.
  230. */
  231. function hasClass(el, className) {
  232. if (el == null) {
  233. return false;
  234. }
  235. return el.classList.contains(className);
  236. }
  237. /**
  238. * Gets the window height. Crossbrowser.
  239. */
  240. function getWindowHeight() {
  241. return 'innerHeight' in win ? win.innerHeight : doc.documentElement.offsetHeight;
  242. }
  243. /**
  244. * Gets the window width.
  245. */
  246. function getWindowWidth() {
  247. return win.innerWidth;
  248. }
  249. /**
  250. * Set's the CSS properties for the passed item/s.
  251. * @param {NodeList|HTMLElement|Object} items
  252. * @param {Object} props css properties and values.
  253. */
  254. function css(items, props) {
  255. items = getList(items);
  256. var key;
  257. for (key in props) {
  258. if (props.hasOwnProperty(key)) {
  259. if (key !== null) {
  260. for (var i = 0; i < items.length; i++) {
  261. var item = items[i];
  262. item.style[key] = props[key];
  263. }
  264. }
  265. }
  266. }
  267. return items;
  268. }
  269. /**
  270. * Gets the previous element to the passed element.
  271. */
  272. function prev(item) {
  273. return item.previousElementSibling;
  274. }
  275. /**
  276. * Gets the next element to the passed element.
  277. */
  278. function next(item) {
  279. return item.nextElementSibling;
  280. }
  281. /**
  282. * Gets the last element from the passed list of elements.
  283. */
  284. function last(item) {
  285. return item[item.length - 1];
  286. }
  287. /**
  288. * Gets index from the passed element.
  289. * @param {String} selector is optional.
  290. */
  291. function index(item, selector) {
  292. item = isArrayOrList(item) ? item[0] : item;
  293. var children = selector != null ? $(selector, item.parentNode) : item.parentNode.childNodes;
  294. var num = 0;
  295. for (var i = 0; i < children.length; i++) {
  296. if (children[i] == item) return num;
  297. if (children[i].nodeType == 1) num++;
  298. }
  299. return -1;
  300. }
  301. /**
  302. * Gets an iterable element for the passed element/s
  303. */
  304. function getList(item) {
  305. return !isArrayOrList(item) ? [item] : item;
  306. }
  307. /**
  308. * Adds the display=none property for the passed element/s
  309. */
  310. function hide(el) {
  311. el = getList(el);
  312. for (var i = 0; i < el.length; i++) {
  313. el[i].style.display = 'none';
  314. }
  315. return el;
  316. }
  317. /**
  318. * Adds the display=block property for the passed element/s
  319. */
  320. function show(el) {
  321. el = getList(el);
  322. for (var i = 0; i < el.length; i++) {
  323. el[i].style.display = 'block';
  324. }
  325. return el;
  326. }
  327. /**
  328. * Checks if the passed element is an iterable element or not
  329. */
  330. function isArrayOrList(el) {
  331. return Object.prototype.toString.call(el) === '[object Array]' || Object.prototype.toString.call(el) === '[object NodeList]';
  332. }
  333. /**
  334. * Adds the passed class to the passed element/s
  335. */
  336. function addClass(el, className) {
  337. el = getList(el);
  338. for (var i = 0; i < el.length; i++) {
  339. var item = el[i];
  340. item.classList.add(className);
  341. }
  342. return el;
  343. }
  344. /**
  345. * Removes the passed class to the passed element/s
  346. * @param {String} `className` can be multiple classnames separated by whitespace
  347. */
  348. function removeClass(el, className) {
  349. el = getList(el);
  350. var classNames = className.split(' ');
  351. for (var a = 0; a < classNames.length; a++) {
  352. className = classNames[a];
  353. for (var i = 0; i < el.length; i++) {
  354. var item = el[i];
  355. item.classList.remove(className);
  356. }
  357. }
  358. return el;
  359. }
  360. /**
  361. * Appends the given element ot the given parent.
  362. */
  363. function appendTo(el, parent) {
  364. parent.appendChild(el);
  365. }
  366. /**
  367. Usage:
  368. var wrapper = document.createElement('div');
  369. wrapper.className = 'fp-slides';
  370. wrap($('.slide'), wrapper);
  371. https://jsfiddle.net/qwzc7oy3/15/ (vanilla)
  372. https://jsfiddle.net/oya6ndka/1/ (jquery equivalent)
  373. */
  374. function wrap(toWrap, wrapper, isWrapAll) {
  375. var newParent;
  376. wrapper = wrapper || doc.createElement('div');
  377. for (var i = 0; i < toWrap.length; i++) {
  378. var item = toWrap[i];
  379. if (isWrapAll && !i || !isWrapAll) {
  380. newParent = wrapper.cloneNode(true);
  381. item.parentNode.insertBefore(newParent, item);
  382. }
  383. newParent.appendChild(item);
  384. }
  385. return toWrap;
  386. }
  387. /**
  388. Usage:
  389. var wrapper = document.createElement('div');
  390. wrapper.className = 'fp-slides';
  391. wrap($('.slide'), wrapper);
  392. https://jsfiddle.net/qwzc7oy3/27/ (vanilla)
  393. https://jsfiddle.net/oya6ndka/4/ (jquery equivalent)
  394. */
  395. function wrapAll(toWrap, wrapper) {
  396. wrap(toWrap, wrapper, true);
  397. }
  398. /**
  399. * Usage:
  400. * wrapInner(document.querySelector('#pepe'), '<div class="test">afdas</div>');
  401. * wrapInner(document.querySelector('#pepe'), element);
  402. *
  403. * https://jsfiddle.net/zexxz0tw/6/
  404. *
  405. * https://stackoverflow.com/a/21817590/1081396
  406. */
  407. function wrapInner(parent, wrapper) {
  408. parent.appendChild(wrapper);
  409. while (parent.firstChild !== wrapper) {
  410. wrapper.appendChild(parent.firstChild);
  411. }
  412. }
  413. /**
  414. * Usage:
  415. * unwrap(document.querySelector('#pepe'));
  416. * unwrap(element);
  417. *
  418. * https://jsfiddle.net/szjt0hxq/1/
  419. *
  420. */
  421. function unwrap(wrapper) {
  422. var wrapperContent = doc.createDocumentFragment();
  423. while (wrapper.firstChild) {
  424. wrapperContent.appendChild(wrapper.firstChild);
  425. }
  426. wrapper.parentNode.replaceChild(wrapperContent, wrapper);
  427. }
  428. /**
  429. * http://stackoverflow.com/questions/22100853/dom-pure-javascript-solution-to-jquery-closest-implementation
  430. * Returns the element or `false` if there's none
  431. */
  432. function closest(el, selector) {
  433. if (el && el.nodeType === 1) {
  434. if (matches(el, selector)) {
  435. return el;
  436. }
  437. return closest(el.parentNode, selector);
  438. }
  439. return null;
  440. }
  441. /**
  442. * Places one element (rel) after another one or group of them (reference).
  443. * @param {HTMLElement} reference
  444. * @param {HTMLElement|NodeList|String|Array} el
  445. * https://jsfiddle.net/9s97hhzv/1/
  446. */
  447. function after(reference, el) {
  448. insertBefore(reference, reference.nextSibling, el);
  449. }
  450. /**
  451. * Places one element (rel) before another one or group of them (reference).
  452. * @param {HTMLElement} reference
  453. * @param {HTMLElement|NodeList|String|Array} el
  454. * https://jsfiddle.net/9s97hhzv/1/
  455. */
  456. function before(reference, el) {
  457. insertBefore(reference, reference, el);
  458. }
  459. /**
  460. * Based in https://stackoverflow.com/a/19316024/1081396
  461. * and https://stackoverflow.com/a/4793630/1081396
  462. */
  463. function insertBefore(reference, beforeElement, el) {
  464. if (!isArrayOrList(el)) {
  465. if (typeof el == 'string') {
  466. el = createElementFromHTML(el);
  467. }
  468. el = [el];
  469. }
  470. for (var i = 0; i < el.length; i++) {
  471. reference.parentNode.insertBefore(el[i], beforeElement);
  472. }
  473. } //http://stackoverflow.com/questions/3464876/javascript-get-window-x-y-position-for-scroll
  474. function getScrollTop() {
  475. var docElement = doc.documentElement;
  476. return (win.pageYOffset || docElement.scrollTop) - (docElement.clientTop || 0);
  477. }
  478. /**
  479. * Gets the siblings of the passed element
  480. */
  481. function siblings(el) {
  482. return Array.prototype.filter.call(el.parentNode.children, function (child) {
  483. return child !== el;
  484. });
  485. }
  486. function preventDefault(event) {
  487. event.preventDefault();
  488. }
  489. function getAttr(el, attr) {
  490. return el.getAttribute(attr);
  491. }
  492. function docAddEvent(event, callback, options) {
  493. doc.addEventListener(event, callback, options === 'undefined' ? null : options);
  494. }
  495. function windowAddEvent(event, callback, options) {
  496. win.addEventListener(event, callback, options === 'undefined' ? null : options);
  497. }
  498. function docRemoveEvent(event, callback, options) {
  499. doc.removeEventListener(event, callback, options === 'undefined' ? null : options);
  500. }
  501. function windowRemoveEvent(event, callback, options) {
  502. win.removeEventListener(event, callback, options === 'undefined' ? null : options);
  503. }
  504. /**
  505. * Determines whether the passed item is of function type.
  506. */
  507. function isFunction(item) {
  508. if (typeof item === 'function') {
  509. return true;
  510. }
  511. var type = Object.prototype.toString.call(item);
  512. return type === '[object Function]' || type === '[object GeneratorFunction]';
  513. }
  514. /**
  515. * Trigger custom events
  516. */
  517. function trigger(el, eventName, data) {
  518. var event;
  519. data = typeof data === 'undefined' ? {} : data; // Native
  520. if (typeof win.CustomEvent === "function") {
  521. event = new CustomEvent(eventName, {
  522. detail: data
  523. });
  524. } else {
  525. event = doc.createEvent('CustomEvent');
  526. event.initCustomEvent(eventName, true, true, data);
  527. }
  528. el.dispatchEvent(event);
  529. }
  530. /**
  531. * Polyfill of .matches()
  532. */
  533. function matches(el, selector) {
  534. return (el.matches || el.matchesSelector || el.msMatchesSelector || el.mozMatchesSelector || el.webkitMatchesSelector || el.oMatchesSelector).call(el, selector);
  535. }
  536. /**
  537. * Toggles the visibility of the passed element el.
  538. */
  539. function toggle(el, value) {
  540. if (typeof value === "boolean") {
  541. for (var i = 0; i < el.length; i++) {
  542. el[i].style.display = value ? 'block' : 'none';
  543. }
  544. } //we don't use it in other way, so no else :)
  545. return el;
  546. }
  547. /**
  548. * Creates a HTMLElement from the passed HTML string.
  549. * https://stackoverflow.com/a/494348/1081396
  550. */
  551. function createElementFromHTML(htmlString) {
  552. var div = doc.createElement('div');
  553. div.innerHTML = htmlString.trim(); // Change this to div.childNodes to support multiple top-level nodes
  554. return div.firstChild;
  555. }
  556. /**
  557. * Removes the passed item/s from the DOM.
  558. */
  559. function remove(items) {
  560. items = getList(items);
  561. for (var i = 0; i < items.length; i++) {
  562. var item = items[i];
  563. if (item && item.parentElement) {
  564. item.parentNode.removeChild(item);
  565. }
  566. }
  567. } //https://jsfiddle.net/w1rktecz/
  568. function untilAll(item, selector, fn) {
  569. var sibling = item[fn];
  570. var siblings = [];
  571. while (sibling) {
  572. if (matches(sibling, selector) || selector == null) {
  573. siblings.push(sibling);
  574. }
  575. sibling = sibling[fn];
  576. }
  577. return siblings;
  578. }
  579. /**
  580. * Gets all next elements matching the passed selector.
  581. */
  582. function nextAll(item, selector) {
  583. return untilAll(item, selector, 'nextElementSibling');
  584. }
  585. /**
  586. * Gets all previous elements matching the passed selector.
  587. */
  588. function prevAll(item, selector) {
  589. return untilAll(item, selector, 'previousElementSibling');
  590. }
  591. /**
  592. * Converts an object to an array.
  593. */
  594. function toArray(objectData) {
  595. return Object.keys(objectData).map(function (key) {
  596. return objectData[key];
  597. });
  598. }
  599. function getLast(items) {
  600. return items[items.length - 1];
  601. }
  602. /**
  603. * Gets the average of the last `number` elements of the given array.
  604. */
  605. function getAverage(elements, number) {
  606. var sum = 0; //taking `number` elements from the end to make the average, if there are not enought, 1
  607. var lastElements = elements.slice(Math.max(elements.length - number, 1));
  608. for (var i = 0; i < lastElements.length; i++) {
  609. sum = sum + lastElements[i];
  610. }
  611. return Math.ceil(sum / number);
  612. }
  613. /**
  614. * Sets the value for the given attribute from the `data-` attribute with the same suffix
  615. * ie: data-srcset ==> srcset | data-src ==> src
  616. */
  617. function setSrc(element, attribute) {
  618. element.setAttribute(attribute, getAttr(element, 'data-' + attribute));
  619. element.removeAttribute('data-' + attribute);
  620. }
  621. function getParentsUntil(item, topParentSelector) {
  622. var parents = [item];
  623. do {
  624. item = item.parentNode;
  625. parents.push(item);
  626. } while (!matches(item, topParentSelector));
  627. return parents;
  628. }
  629. function isInsideInput() {
  630. var activeElement = doc.activeElement;
  631. return matches(activeElement, 'textarea') || matches(activeElement, 'input') || matches(activeElement, 'select') || getAttr(activeElement, 'contentEditable') == "true" || getAttr(activeElement, 'contentEditable') == '';
  632. } //utils are public, so we can use it wherever we want
  633. // @ts-ignore
  634. window["fp_utils"] = {
  635. "$": $,
  636. "deepExtend": deepExtend,
  637. "hasClass": hasClass,
  638. "getWindowHeight": getWindowHeight,
  639. "css": css,
  640. "prev": prev,
  641. "next": next,
  642. "last": last,
  643. "index": index,
  644. "getList": getList,
  645. "hide": hide,
  646. "show": show,
  647. "isArrayOrList": isArrayOrList,
  648. "addClass": addClass,
  649. "removeClass": removeClass,
  650. "appendTo": appendTo,
  651. "wrap": wrap,
  652. "wrapAll": wrapAll,
  653. "unwrap": unwrap,
  654. "closest": closest,
  655. "after": after,
  656. "before": before,
  657. "insertBefore": insertBefore,
  658. "getScrollTop": getScrollTop,
  659. "siblings": siblings,
  660. "preventDefault": preventDefault,
  661. "isFunction": isFunction,
  662. "trigger": trigger,
  663. "matches": matches,
  664. "toggle": toggle,
  665. "createElementFromHTML": createElementFromHTML,
  666. "remove": remove,
  667. // "filter": filter,
  668. "untilAll": untilAll,
  669. "nextAll": nextAll,
  670. "prevAll": prevAll,
  671. "showError": showError
  672. };
  673. var utils = /*#__PURE__*/Object.freeze({
  674. __proto__: null,
  675. showError: showError,
  676. isVisible: isVisible,
  677. getVisible: getVisible,
  678. $: $,
  679. deepExtend: deepExtend,
  680. hasClass: hasClass,
  681. getWindowHeight: getWindowHeight,
  682. getWindowWidth: getWindowWidth,
  683. css: css,
  684. prev: prev,
  685. next: next,
  686. last: last,
  687. index: index,
  688. getList: getList,
  689. hide: hide,
  690. show: show,
  691. isArrayOrList: isArrayOrList,
  692. addClass: addClass,
  693. removeClass: removeClass,
  694. appendTo: appendTo,
  695. wrap: wrap,
  696. wrapAll: wrapAll,
  697. wrapInner: wrapInner,
  698. unwrap: unwrap,
  699. closest: closest,
  700. after: after,
  701. before: before,
  702. insertBefore: insertBefore,
  703. getScrollTop: getScrollTop,
  704. siblings: siblings,
  705. preventDefault: preventDefault,
  706. getAttr: getAttr,
  707. docAddEvent: docAddEvent,
  708. windowAddEvent: windowAddEvent,
  709. docRemoveEvent: docRemoveEvent,
  710. windowRemoveEvent: windowRemoveEvent,
  711. isFunction: isFunction,
  712. trigger: trigger,
  713. matches: matches,
  714. toggle: toggle,
  715. createElementFromHTML: createElementFromHTML,
  716. remove: remove,
  717. untilAll: untilAll,
  718. nextAll: nextAll,
  719. prevAll: prevAll,
  720. toArray: toArray,
  721. getLast: getLast,
  722. getAverage: getAverage,
  723. setSrc: setSrc,
  724. getParentsUntil: getParentsUntil,
  725. isInsideInput: isInsideInput
  726. });
  727. function _typeof(obj) {
  728. "@babel/helpers - typeof";
  729. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  730. _typeof = function (obj) {
  731. return typeof obj;
  732. };
  733. } else {
  734. _typeof = function (obj) {
  735. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  736. };
  737. }
  738. return _typeof(obj);
  739. }
  740. var EventEmitter = {
  741. events: {},
  742. on: function on(event, listener) {
  743. var _this = this;
  744. if (_typeof(this.events[event]) !== 'object') {
  745. this.events[event] = [];
  746. }
  747. this.events[event].push(listener);
  748. return function () {
  749. return _this.removeListener(event, listener);
  750. };
  751. },
  752. removeListener: function removeListener(event, listener) {
  753. if (_typeof(this.events[event]) === 'object') {
  754. var idx = this.events[event].indexOf(listener);
  755. if (idx > -1) {
  756. this.events[event].splice(idx, 1);
  757. }
  758. }
  759. },
  760. emit: function emit(event) {
  761. var _this2 = this;
  762. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  763. args[_key - 1] = arguments[_key];
  764. }
  765. if (_typeof(this.events[event]) === 'object') {
  766. this.events[event].forEach(function (listener) {
  767. return listener.apply(_this2, args);
  768. });
  769. }
  770. },
  771. once: function once(event, listener) {
  772. var _this3 = this;
  773. var remove = this.on(event, function () {
  774. remove();
  775. for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  776. args[_key2] = arguments[_key2];
  777. }
  778. listener.apply(_this3, args);
  779. });
  780. }
  781. };
  782. var state = {
  783. numSections: 0,
  784. numSlides: 0,
  785. slides: [],
  786. sections: [],
  787. activeSection: null,
  788. scrollTrigger: null,
  789. isBeyondFullpage: false,
  790. aboutToScrollToFullPage: false,
  791. slideMoving: false,
  792. isResizing: false,
  793. isScrolling: false,
  794. lastScrolledDestiny: undefined,
  795. lastScrolledSlide: undefined,
  796. activeAnimation: false,
  797. canScroll: true,
  798. touchDirection: 'none',
  799. wheelDirection: 'none',
  800. isGrabbing: false,
  801. isUsingWheel: false,
  802. isWindowFocused: true,
  803. previousDestTop: 0,
  804. windowsHeight: getWindowHeight(),
  805. isDoingContinousVertical: false,
  806. timeouts: {},
  807. scrollY: 0,
  808. scrollX: 0
  809. }; // @ts-ignore
  810. win.state = state;
  811. function setState(props) {
  812. Object.assign(state, props);
  813. }
  814. function getState() {
  815. return state;
  816. }
  817. function getActivePanel() {
  818. return state.activeSection && state.activeSection.activeSlide ? state.activeSection.activeSlide : state.activeSection;
  819. }
  820. var events = {
  821. onAfterRenderNoAnchor: 'onAfterRenderNoAnchor',
  822. onClickOrTouch: 'onClickOrTouch',
  823. moveSlideLeft: 'moveSlideLeft',
  824. moveSlideRight: 'moveSlideRight',
  825. onInitialise: 'onInitialise',
  826. beforeInit: 'beforeInit',
  827. bindEvents: 'bindEvents',
  828. onDestroy: 'onDestroy',
  829. contentChanged: 'contentChanged',
  830. onScrollOverflowScrolled: 'onScrollOverflowScrolled',
  831. onScrollPageAndSlide: 'onScrollPageAndSlide',
  832. onKeyDown: 'onKeyDown',
  833. onMenuClick: 'onMenuClick',
  834. scrollPage: 'scrollPage',
  835. landscapeScroll: 'landscapeScroll',
  836. scrollBeyondFullpage: 'scrollBeyondFullpage',
  837. onPerformMovement: 'onPerformMovement',
  838. onSlideLeave: 'onSlideLeave',
  839. onLeave: 'onLeave',
  840. afterSectionLoads: 'afterSectionLoads',
  841. afterSlideLoads: 'afterSlideLoads'
  842. };
  843. EventEmitter.on(events.bindEvents, bindEvents$c);
  844. function bindEvents$c() {
  845. //Scrolls to the section when clicking the navigation bullet
  846. //simulating the jQuery .on('click') event using delegation
  847. ['click', 'touchstart'].forEach(function (eventName) {
  848. docAddEvent(eventName, delegatedEvents);
  849. });
  850. windowAddEvent('focus', focusHandler);
  851. internalEvents();
  852. }
  853. function internalEvents() {
  854. EventEmitter.on(events.onDestroy, onDestroy$9);
  855. }
  856. function delegatedEvents(e) {
  857. EventEmitter.emit(events.onClickOrTouch, {
  858. e: e,
  859. target: e.target
  860. });
  861. }
  862. function onDestroy$9() {
  863. ['click', 'touchstart'].forEach(function (eventName) {
  864. docRemoveEvent(eventName, delegatedEvents);
  865. });
  866. } // changing isWindowFocused to true on focus event
  867. function focusHandler() {
  868. setState({
  869. isWindowFocused: true
  870. });
  871. }
  872. // keeping central set of classnames and selectors
  873. var WRAPPER = 'fullpage-wrapper';
  874. var WRAPPER_SEL = '.' + WRAPPER; // slimscroll
  875. var SCROLLABLE = 'fp-scrollable';
  876. var RESPONSIVE = 'fp-responsive';
  877. var NO_TRANSITION = 'fp-notransition';
  878. var DESTROYED = 'fp-destroyed';
  879. var ENABLED = 'fp-enabled';
  880. var VIEWING_PREFIX = 'fp-viewing';
  881. var ACTIVE = 'active';
  882. var ACTIVE_SEL = '.' + ACTIVE;
  883. var COMPLETELY = 'fp-completely';
  884. var COMPLETELY_SEL = '.' + COMPLETELY; // section
  885. var SECTION_DEFAULT_SEL = '.section';
  886. var SECTION = 'fp-section';
  887. var SECTION_SEL = '.' + SECTION;
  888. var SECTION_ACTIVE_SEL = SECTION_SEL + ACTIVE_SEL;
  889. var TABLE_CELL = 'fp-tableCell';
  890. var TABLE_CELL_SEL = '.' + TABLE_CELL;
  891. var AUTO_HEIGHT = 'fp-auto-height';
  892. var AUTO_HEIGHT_SEL = '.' + AUTO_HEIGHT;
  893. var AUTO_HEIGHT_RESPONSIVE = 'fp-auto-height-responsive';
  894. var AUTO_HEIGHT_RESPONSIVE_SEL = '.' + AUTO_HEIGHT_RESPONSIVE;
  895. var NORMAL_SCROLL = 'fp-normal-scroll';
  896. var SECTION_NAV = 'fp-nav';
  897. var SECTION_NAV_SEL = '#' + SECTION_NAV;
  898. var SECTION_NAV_TOOLTIP = 'fp-tooltip';
  899. var SECTION_NAV_TOOLTIP_SEL = '.' + SECTION_NAV_TOOLTIP;
  900. var SHOW_ACTIVE_TOOLTIP = 'fp-show-active'; // slide
  901. var SLIDE_DEFAULT_SEL = '.slide';
  902. var SLIDE = 'fp-slide';
  903. var SLIDE_SEL = '.' + SLIDE;
  904. var SLIDE_ACTIVE_SEL = SLIDE_SEL + ACTIVE_SEL;
  905. var SLIDES_WRAPPER = 'fp-slides';
  906. var SLIDES_WRAPPER_SEL = '.' + SLIDES_WRAPPER;
  907. var SLIDES_CONTAINER = 'fp-slidesContainer';
  908. var SLIDES_CONTAINER_SEL = '.' + SLIDES_CONTAINER;
  909. var TABLE = 'fp-table';
  910. var OVERFLOW = 'fp-overflow';
  911. var OVERFLOW_SEL = '.' + OVERFLOW;
  912. var IS_OVERFLOW = 'fp-is-overflow'; // slide nav
  913. var SLIDES_NAV = 'fp-slidesNav';
  914. var SLIDES_NAV_SEL = '.' + SLIDES_NAV;
  915. var SLIDES_NAV_LINK_SEL = SLIDES_NAV_SEL + ' a';
  916. var SLIDES_STYLED_ARROW = 'fp-arrow';
  917. var SLIDES_ARROW = 'fp-controlArrow';
  918. var SLIDES_ARROW_SEL = '.' + SLIDES_ARROW;
  919. var SLIDES_PREV = 'fp-prev';
  920. var SLIDES_PREV_SEL = '.' + SLIDES_PREV;
  921. var SLIDES_ARROW_PREV_SEL = SLIDES_ARROW_SEL + SLIDES_PREV_SEL;
  922. var SLIDES_NEXT = 'fp-next';
  923. var SLIDES_NEXT_SEL = '.' + SLIDES_NEXT;
  924. var SLIDES_ARROW_NEXT_SEL = SLIDES_ARROW_SEL + SLIDES_NEXT_SEL;
  925. var defaultOptions = {
  926. //navigation
  927. menu: false,
  928. anchors: [],
  929. lockAnchors: false,
  930. navigation: false,
  931. navigationPosition: 'right',
  932. navigationTooltips: [],
  933. showActiveTooltip: false,
  934. slidesNavigation: false,
  935. slidesNavPosition: 'bottom',
  936. scrollBar: false,
  937. hybrid: false,
  938. licenseKey: '',
  939. credits: {
  940. "enabled": true,
  941. "label": 'Made with fullPage.js',
  942. "position": 'right'
  943. },
  944. //scrolling
  945. css3: true,
  946. scrollingSpeed: 700,
  947. autoScrolling: true,
  948. fitToSection: true,
  949. fitToSectionDelay: 600,
  950. easing: 'easeInOutCubic',
  951. easingcss3: 'ease',
  952. loopBottom: false,
  953. loopTop: false,
  954. loopHorizontal: true,
  955. continuousVertical: false,
  956. continuousHorizontal: false,
  957. scrollHorizontally: false,
  958. interlockedSlides: false,
  959. dragAndMove: false,
  960. offsetSections: false,
  961. resetSliders: false,
  962. fadingEffect: false,
  963. normalScrollElements: null,
  964. scrollOverflow: true,
  965. scrollOverflowReset: false,
  966. touchSensitivity: 5,
  967. touchWrapper: null,
  968. bigSectionsDestination: null,
  969. //Accessibility
  970. keyboardScrolling: true,
  971. animateAnchor: true,
  972. recordHistory: true,
  973. allowCorrectDirection: false,
  974. //design
  975. scrollOverflowMacStyle: true,
  976. controlArrows: true,
  977. controlArrowsHTML: ['<div class="' + SLIDES_STYLED_ARROW + '"></div>', '<div class="' + SLIDES_STYLED_ARROW + '"></div>'],
  978. controlArrowColor: '#fff',
  979. verticalCentered: true,
  980. sectionsColor: [],
  981. paddingTop: 0,
  982. paddingBottom: 0,
  983. fixedElements: null,
  984. responsive: 0,
  985. //backwards compabitility with responsiveWiddth
  986. responsiveWidth: 0,
  987. responsiveHeight: 0,
  988. responsiveSlides: false,
  989. parallax: false,
  990. parallaxOptions: {
  991. type: 'reveal',
  992. percentage: 62,
  993. property: 'translate'
  994. },
  995. cards: false,
  996. cardsOptions: {
  997. perspective: 100,
  998. fadeContent: true,
  999. fadeBackground: true
  1000. },
  1001. //Custom selectors
  1002. sectionSelector: SECTION_DEFAULT_SEL,
  1003. slideSelector: SLIDE_DEFAULT_SEL,
  1004. //events
  1005. afterLoad: null,
  1006. beforeLeave: null,
  1007. onLeave: null,
  1008. afterRender: null,
  1009. afterResize: null,
  1010. afterReBuild: null,
  1011. afterSlideLoad: null,
  1012. onSlideLeave: null,
  1013. afterResponsive: null,
  1014. onScrollOverflow: null,
  1015. lazyLoading: true,
  1016. observer: true,
  1017. scrollBeyondFullpage: true
  1018. };
  1019. var container = null;
  1020. var g_initialAnchorsInDom = false;
  1021. var originals = deepExtend({}, defaultOptions); //deep copy
  1022. var g_options = null;
  1023. function getInitialAnchorsInDom() {
  1024. return g_initialAnchorsInDom;
  1025. }
  1026. function setContainer(value) {
  1027. container = value;
  1028. }
  1029. function getContainer(value) {
  1030. return container;
  1031. }
  1032. function getOptions() {
  1033. return g_options || defaultOptions;
  1034. }
  1035. function setOptions(options) {
  1036. g_options = deepExtend({}, defaultOptions, options);
  1037. originals = Object.assign({}, g_options);
  1038. }
  1039. function getOriginals() {
  1040. return originals;
  1041. }
  1042. function setOption(name, value) {
  1043. defaultOptions[name] = value;
  1044. }
  1045. /*
  1046. * Sets the state for a variable with multiple states (original, and temporal)
  1047. * Some variables such as `autoScrolling` or `recordHistory` might change automatically its state when using `responsive` or `autoScrolling:false`.
  1048. * This function is used to keep track of both states, the original and the temporal one.
  1049. * If type is not 'internal', then we assume the user is globally changing the variable.
  1050. */
  1051. function setVariableState(variable, value, type) {
  1052. g_options[variable] = value;
  1053. if (type !== 'internal') {
  1054. originals[variable] = value;
  1055. }
  1056. }
  1057. /**
  1058. * Setting options from DOM elements if they are not provided.
  1059. */
  1060. function setOptionsFromDOM() {
  1061. //no anchors option? Checking for them in the DOM attributes
  1062. if (!getOptions().anchors.length) {
  1063. var anchorsAttribute = '[data-anchor]';
  1064. var anchors = $(getOptions().sectionSelector.split(',').join(anchorsAttribute + ',') + anchorsAttribute, container);
  1065. if (anchors.length && anchors.length === $(getOptions().sectionSelector, container).length) {
  1066. g_initialAnchorsInDom = true;
  1067. anchors.forEach(function (item) {
  1068. getOptions().anchors.push(getAttr(item, 'data-anchor').toString());
  1069. });
  1070. }
  1071. } //no tooltips option? Checking for them in the DOM attributes
  1072. if (!getOptions().navigationTooltips.length) {
  1073. var tooltipsAttribute = '[data-tooltip]';
  1074. var tooltips = $(getOptions().sectionSelector.split(',').join(tooltipsAttribute + ',') + tooltipsAttribute, container);
  1075. if (tooltips.length) {
  1076. tooltips.forEach(function (item) {
  1077. getOptions().navigationTooltips.push(getAttr(item, 'data-tooltip').toString());
  1078. });
  1079. }
  1080. }
  1081. }
  1082. var plainItem = function plainItem(panel) {
  1083. this.anchor = panel.anchor;
  1084. this.item = panel.item;
  1085. this.index = panel.index();
  1086. this.isLast = this.index === panel.item.parentElement.querySelectorAll(panel.selector).length - 1;
  1087. this.isFirst = !this.index;
  1088. this.isActive = panel.isActive;
  1089. };
  1090. /**
  1091. * Item. Slide or Section objects share the same properties.
  1092. */
  1093. var Item = function Item(el, selector) {
  1094. this.parent = this.parent || null;
  1095. this.selector = selector;
  1096. this.anchor = getAttr(el, 'data-anchor') || getOptions().anchors[index(el, getOptions().sectionSelector)];
  1097. this.item = el;
  1098. this.isVisible = isVisible(el);
  1099. this.isActive = hasClass(el, ACTIVE);
  1100. this.hasScroll = hasClass(el, OVERFLOW) || $(OVERFLOW_SEL, el)[0] != null;
  1101. this.isSection = selector === getOptions().sectionSelector;
  1102. this.container = closest(el, SLIDES_CONTAINER_SEL) || closest(el, WRAPPER_SEL);
  1103. this.index = function () {
  1104. return this.siblings().indexOf(this);
  1105. };
  1106. };
  1107. Item.prototype.siblings = function () {
  1108. if (this.isSection) {
  1109. if (this.isVisible) {
  1110. return state.sections;
  1111. } else {
  1112. return state.sectionsIncludingHidden;
  1113. }
  1114. }
  1115. return this.parent ? this.parent.slides : 0;
  1116. };
  1117. Item.prototype.prev = function () {
  1118. var siblings = this.siblings();
  1119. var currentIndex = this.isSection ? siblings.indexOf(this) : this.parent.slides.indexOf(this);
  1120. var prevIndex = currentIndex - 1;
  1121. if (prevIndex >= 0) {
  1122. return siblings[prevIndex];
  1123. }
  1124. return null;
  1125. };
  1126. Item.prototype.next = function () {
  1127. var siblings = this.siblings();
  1128. var currentIndex = this.isSection ? siblings.indexOf(this) : this.parent.slides.indexOf(this);
  1129. var nextIndex = currentIndex + 1;
  1130. if (nextIndex < siblings.length) {
  1131. return siblings[nextIndex];
  1132. }
  1133. return null;
  1134. };
  1135. Item.prototype["prevPanel"] = function () {
  1136. return this.prev() || (this.parent ? this.parent.prev() : null);
  1137. };
  1138. Item.prototype["nextPanel"] = function () {
  1139. return this.next() || (this.parent ? this.parent.next() : null);
  1140. };
  1141. Item.prototype.getSiblings = function () {
  1142. if (this.isSection) {
  1143. return state.sections;
  1144. }
  1145. return state.panels;
  1146. };
  1147. function getNodes(panels) {
  1148. return panels.map(function (panel) {
  1149. return panel.item;
  1150. });
  1151. }
  1152. function getPanelByElement(panels, el) {
  1153. return panels.find(function (panel) {
  1154. return panel.item === el;
  1155. });
  1156. }
  1157. var Section = function Section(el) {
  1158. plainItem.call(this, el);
  1159. };
  1160. var Slide = function Slide(el) {
  1161. plainItem.call(this, el);
  1162. };
  1163. /**
  1164. * Gets the active slide (or section) for the given section
  1165. */
  1166. function getSlideOrSection(destiny) {
  1167. var slide = $(SLIDE_ACTIVE_SEL, destiny);
  1168. if (slide.length) {
  1169. destiny = slide[0];
  1170. }
  1171. return destiny;
  1172. }
  1173. function getSlideOrSectionPanel(panel) {
  1174. if (!panel) {
  1175. return null;
  1176. }
  1177. return panel.activeSlide ? panel.activeSlide : panel;
  1178. }
  1179. function isFullPageAbove() {
  1180. return getContainer().getBoundingClientRect().bottom >= 0;
  1181. }
  1182. /**
  1183. * Gets the scrolling settings depending on the plugin autoScrolling option
  1184. */
  1185. function getScrollSettings(top) {
  1186. var options = getOptions();
  1187. var position;
  1188. var element; //top property animation
  1189. if (options.autoScrolling && !options.scrollBar) {
  1190. position = -top;
  1191. element = $(WRAPPER_SEL)[0];
  1192. } //window real scrolling
  1193. else {
  1194. position = top;
  1195. element = window;
  1196. }
  1197. return {
  1198. options: position,
  1199. element: element
  1200. };
  1201. }
  1202. /**
  1203. * Scrolls the page / slider the given number of pixels.
  1204. * It will do it one or another way dependiong on the library's config.
  1205. */
  1206. function setScrolling(element, val) {
  1207. if (!getOptions().autoScrolling || getOptions().scrollBar || element.self != window && hasClass(element, SLIDES_WRAPPER)) {
  1208. //scrolling horizontally through the slides?
  1209. if (element.self != window && hasClass(element, SLIDES_WRAPPER)) {
  1210. element.scrollLeft = val;
  1211. } //vertical scroll
  1212. else {
  1213. element.scrollTo(0, val);
  1214. }
  1215. } else {
  1216. element.style.top = val + 'px';
  1217. }
  1218. }
  1219. /**
  1220. * Adds transition animations for the given element
  1221. */
  1222. function addAnimation(element) {
  1223. var transition = 'transform ' + getOptions().scrollingSpeed + 'ms ' + getOptions().easingcss3;
  1224. removeClass(element, NO_TRANSITION);
  1225. return css(element, {
  1226. '-webkit-transition': transition,
  1227. 'transition': transition
  1228. });
  1229. }
  1230. /**
  1231. * Retuns `up` or `down` depending on the scrolling movement to reach its destination
  1232. * from the current section.
  1233. */
  1234. function getYmovement(activeSection, destiny) {
  1235. var fromIndex = activeSection.index();
  1236. var toIndex = index(destiny, SECTION_SEL);
  1237. if (fromIndex == toIndex) {
  1238. return 'none';
  1239. }
  1240. if (fromIndex > toIndex) {
  1241. return 'up';
  1242. }
  1243. return 'down';
  1244. }
  1245. /**
  1246. * Remove transition animations for the given element
  1247. */
  1248. function removeAnimation(element) {
  1249. return addClass(element, NO_TRANSITION);
  1250. }
  1251. /**
  1252. * Returns the cross-browser transform string.
  1253. */
  1254. function getTransforms(translate3d) {
  1255. return {
  1256. '-webkit-transform': translate3d,
  1257. '-moz-transform': translate3d,
  1258. '-ms-transform': translate3d,
  1259. 'transform': translate3d
  1260. };
  1261. }
  1262. var silentScrollId;
  1263. /**
  1264. * Adds a css3 transform property to the container class with or without animation depending on the animated param.
  1265. */
  1266. function transformContainer(translate3d, animated) {
  1267. if (animated) {
  1268. addAnimation(getContainer());
  1269. } else {
  1270. removeAnimation(getContainer());
  1271. }
  1272. clearTimeout(silentScrollId);
  1273. css(getContainer(), getTransforms(translate3d));
  1274. FP.test.translate3d = translate3d; //syncronously removing the class after the animation has been applied.
  1275. silentScrollId = setTimeout(function () {
  1276. removeClass(getContainer(), NO_TRANSITION);
  1277. }, 10);
  1278. }
  1279. /**
  1280. * Scrolls silently (with no animation) the page to the given Y position.
  1281. */
  1282. function silentScroll(top) {
  1283. // The first section can have a negative value in iOS 10. Not quite sure why: -0.0142822265625
  1284. // that's why we round it to 0.
  1285. var roundedTop = Math.round(top);
  1286. if (getOptions().css3 && getOptions().autoScrolling && !getOptions().scrollBar) {
  1287. var translate3d = 'translate3d(0px, -' + roundedTop + 'px, 0px)';
  1288. transformContainer(translate3d, false);
  1289. } else if (getOptions().autoScrolling && !getOptions().scrollBar) {
  1290. css(getContainer(), {
  1291. 'top': -roundedTop + 'px'
  1292. });
  1293. FP.test.top = -roundedTop + 'px';
  1294. } else {
  1295. var scrollSettings = getScrollSettings(roundedTop);
  1296. setScrolling(scrollSettings.element, scrollSettings.options);
  1297. }
  1298. }
  1299. FP.setScrollingSpeed = setScrollingSpeed;
  1300. /**
  1301. * Defines the scrolling speed
  1302. */
  1303. function setScrollingSpeed(value, type) {
  1304. setVariableState('scrollingSpeed', value, type);
  1305. }
  1306. var $body = null;
  1307. var $html = null;
  1308. var $htmlBody = null; // caching common elements
  1309. function setCache() {
  1310. $body = $('body')[0];
  1311. $html = $('html')[0];
  1312. $htmlBody = $('html, body');
  1313. }
  1314. //@ts-check
  1315. var _g_animateScroll;
  1316. /**
  1317. * Simulates the animated scrollTop of jQuery. Used when css3:false or scrollBar:true or autoScrolling:false
  1318. * http://stackoverflow.com/a/16136789/1081396
  1319. */
  1320. function scrollTo(element, to, duration, callback) {
  1321. var start = getScrolledPosition(element);
  1322. var change = to - start;
  1323. var isCallbackFired = false;
  1324. var startTime;
  1325. var wasAnimationActive = state.activeAnimation;
  1326. setState({
  1327. activeAnimation: true
  1328. }); // Cancelling any possible previous animations (io: clicking on nav dots very fast)
  1329. if (_g_animateScroll) {
  1330. window.cancelAnimationFrame(_g_animateScroll);
  1331. }
  1332. _g_animateScroll = function g_animateScroll(timestamp) {
  1333. if (!startTime) {
  1334. startTime = timestamp;
  1335. }
  1336. var currentTime = Math.floor(timestamp - startTime);
  1337. if (state.activeAnimation) {
  1338. //in order to stope it from other function whenever we want
  1339. var val = to;
  1340. if (duration) {
  1341. // @ts-ignore
  1342. val = win.fp_easings[getOptions().easing](currentTime, start, change, duration);
  1343. }
  1344. if (currentTime <= duration) {
  1345. setScrolling(element, val);
  1346. }
  1347. if (currentTime < duration) {
  1348. window.requestAnimationFrame(_g_animateScroll);
  1349. } else if (typeof callback !== 'undefined' && !isCallbackFired) {
  1350. callback();
  1351. setState({
  1352. activeAnimation: false
  1353. });
  1354. isCallbackFired = true;
  1355. }
  1356. } else if (!isCallbackFired && !wasAnimationActive) {
  1357. callback();
  1358. setState({
  1359. activeAnimation: false
  1360. });
  1361. isCallbackFired = true;
  1362. }
  1363. };
  1364. window.requestAnimationFrame(_g_animateScroll);
  1365. }
  1366. /**
  1367. * Getting the position of the element to scroll when using jQuery animations
  1368. */
  1369. function getScrolledPosition(element) {
  1370. var position; //is not the window element and is a slide?
  1371. if (element.self != win && hasClass(element, SLIDES_WRAPPER)) {
  1372. position = element.scrollLeft;
  1373. } else if (!getOptions().autoScrolling || getOptions().scrollBar) {
  1374. position = getScrollTop();
  1375. } else {
  1376. position = element.offsetTop;
  1377. } //gets the top property of the wrapper
  1378. return position;
  1379. }
  1380. /**
  1381. * Makes sure to only create a Panel object if the element exist
  1382. */
  1383. function nullOrSection(el) {
  1384. if (el && !el.item) {
  1385. return new Section(new SectionPanel(el));
  1386. }
  1387. return el ? new Section(el) : null;
  1388. }
  1389. function nullOrSlide(el) {
  1390. return el ? new Slide(el) : null;
  1391. }
  1392. /**
  1393. * Dispatch events & callbacks
  1394. */
  1395. function fireCallback(eventName, v) {
  1396. var eventData = getEventData(eventName, v);
  1397. trigger(getContainer(), eventName, eventData);
  1398. if (getOptions()[eventName].apply(eventData[Object.keys(eventData)[0]], toArray(eventData)) === false) {
  1399. return false;
  1400. }
  1401. return true;
  1402. }
  1403. /**
  1404. * Gets the event's data for the given event on the right format.
  1405. */
  1406. function getEventData(eventName, v) {
  1407. //using functions to run only the necessary bits within the object
  1408. var paramsPerEvent = {
  1409. afterRender: function afterRender() {
  1410. return {
  1411. section: nullOrSection(getState().activeSection),
  1412. slide: nullOrSlide(getState().activeSection.activeSlide)
  1413. };
  1414. },
  1415. onLeave: function onLeave() {
  1416. return {
  1417. origin: nullOrSection(v.items.origin),
  1418. destination: nullOrSection(v.items.destination),
  1419. direction: v.direction,
  1420. trigger: getState().scrollTrigger
  1421. };
  1422. },
  1423. afterLoad: function afterLoad() {
  1424. return paramsPerEvent.onLeave();
  1425. },
  1426. afterSlideLoad: function afterSlideLoad() {
  1427. return {
  1428. section: nullOrSection(v.items.section),
  1429. origin: nullOrSection(v.items.origin),
  1430. destination: nullOrSection(v.items.destination),
  1431. direction: v.direction,
  1432. trigger: getState().scrollTrigger
  1433. };
  1434. },
  1435. onSlideLeave: function onSlideLeave() {
  1436. return paramsPerEvent.afterSlideLoad();
  1437. },
  1438. beforeLeave: function beforeLeave() {
  1439. return paramsPerEvent.onLeave();
  1440. },
  1441. onScrollOverflow: function onScrollOverflow() {
  1442. return {
  1443. section: nullOrSection(getState().activeSection),
  1444. slide: nullOrSlide(getState().activeSection.activeSlide),
  1445. position: v.position,
  1446. direction: v.direction
  1447. };
  1448. }
  1449. };
  1450. return paramsPerEvent[eventName]();
  1451. }
  1452. /**
  1453. * Plays video and audio elements.
  1454. */
  1455. function playMedia(destiny) {
  1456. var panel = getSlideOrSection(destiny); //playing HTML5 media elements
  1457. $('video, audio', panel).forEach(function (element) {
  1458. if (element.hasAttribute('data-autoplay') && typeof element.play === 'function') {
  1459. element.play();
  1460. }
  1461. }); //youtube videos
  1462. $('iframe[src*="youtube.com/embed/"]', panel).forEach(function (element) {
  1463. if (element.hasAttribute('data-autoplay')) {
  1464. playYoutube(element);
  1465. } //in case the URL was not loaded yet. On page load we need time for the new URL (with the API string) to load.
  1466. element.onload = function () {
  1467. if (element.hasAttribute('data-autoplay')) {
  1468. playYoutube(element);
  1469. }
  1470. };
  1471. });
  1472. }
  1473. /**
  1474. * Plays a youtube video
  1475. */
  1476. function playYoutube(element) {
  1477. element.contentWindow.postMessage('{"event":"command","func":"playVideo","args":""}', '*');
  1478. }
  1479. /**
  1480. * Stops video and audio elements.
  1481. */
  1482. function stopMedia(destiny) {
  1483. var panel = getSlideOrSection(destiny); //stopping HTML5 media elements
  1484. $('video, audio', panel).forEach(function (element) {
  1485. if (!element.hasAttribute('data-keepplaying') && typeof element.pause === 'function') {
  1486. element.pause();
  1487. }
  1488. }); //youtube videos
  1489. $('iframe[src*="youtube.com/embed/"]', panel).forEach(function (element) {
  1490. if (/youtube\.com\/embed\//.test(getAttr(element, 'src')) && !element.hasAttribute('data-keepplaying')) {
  1491. element.contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*');
  1492. }
  1493. });
  1494. }
  1495. /*
  1496. * Enables the Youtube videos API so we can control their flow if necessary.
  1497. */
  1498. function enableYoutubeAPI() {
  1499. $('iframe[src*="youtube.com/embed/"]', getContainer()).forEach(function (item) {
  1500. addURLParam(item, 'enablejsapi=1');
  1501. });
  1502. }
  1503. /**
  1504. * Adds a new parameter and its value to the `src` of a given element
  1505. */
  1506. function addURLParam(element, newParam) {
  1507. var originalSrc = getAttr(element, 'src');
  1508. element.setAttribute('src', originalSrc + getUrlParamSign(originalSrc) + newParam);
  1509. }
  1510. /*
  1511. * Returns the prefix sign to use for a new parameter in an existen URL.
  1512. *
  1513. * @return {String} ? | &
  1514. */
  1515. function getUrlParamSign(url) {
  1516. return !/\?/.test(url) ? '?' : '&';
  1517. }
  1518. /**
  1519. * Lazy loads image, video and audio elements.
  1520. */
  1521. function lazyLoad(destiny) {
  1522. if (!getOptions().lazyLoading) {
  1523. return;
  1524. }
  1525. var panel = getSlideOrSection(destiny);
  1526. $('img[data-src], img[data-srcset], source[data-src], source[data-srcset], video[data-src], audio[data-src], iframe[data-src]', panel).forEach(function (element) {
  1527. ['src', 'srcset'].forEach(function (type) {
  1528. var attribute = getAttr(element, 'data-' + type);
  1529. if (attribute != null && attribute) {
  1530. setSrc(element, type);
  1531. element.addEventListener('load', function () {
  1532. });
  1533. }
  1534. });
  1535. if (matches(element, 'source')) {
  1536. var elementToPlay = closest(element, 'video, audio');
  1537. if (elementToPlay) {
  1538. elementToPlay.load();
  1539. elementToPlay.onloadeddata = function () {
  1540. };
  1541. }
  1542. }
  1543. });
  1544. }
  1545. /**
  1546. * Sets a class for the body of the page depending on the active section / slide
  1547. */
  1548. function setBodyClass() {
  1549. var section = getState().activeSection.item;
  1550. var slide = getState().activeSection.activeSlide;
  1551. var sectionAnchor = getAnchor(section);
  1552. var text = String(sectionAnchor);
  1553. if (slide) {
  1554. var slideAnchor = getAnchor(slide.item);
  1555. text = text + '-' + slideAnchor;
  1556. } //changing slash for dash to make it a valid CSS style
  1557. text = text.replace('/', '-').replace('#', ''); //removing previous anchor classes
  1558. var classRe = new RegExp('\\b\\s?' + VIEWING_PREFIX + '-[^\\s]+\\b', "g");
  1559. $body.className = $body.className.replace(classRe, ''); //adding the current anchor
  1560. addClass($body, VIEWING_PREFIX + '-' + text);
  1561. }
  1562. /**
  1563. * Gets the anchor for the given slide / section. Its index will be used if there's none.
  1564. */
  1565. function getAnchor(element) {
  1566. if (!element) {
  1567. return null;
  1568. }
  1569. var anchor = getAttr(element, 'data-anchor');
  1570. var elementIndex = index(element); //Slide without anchor link? We take the index instead.
  1571. if (anchor == null) {
  1572. anchor = elementIndex;
  1573. }
  1574. return anchor;
  1575. }
  1576. /**
  1577. * Sets the state of the website depending on the active section/slide.
  1578. * It changes the URL hash when needed and updates the body class.
  1579. */
  1580. function setPageStatus(slideIndex, slideAnchor, anchorLink) {
  1581. var sectionHash = '';
  1582. if (getOptions().anchors.length && !getOptions().lockAnchors) {
  1583. //isn't it the first slide?
  1584. if (slideIndex) {
  1585. if (anchorLink != null) {
  1586. sectionHash = anchorLink;
  1587. } //slide without anchor link? We take the index instead.
  1588. if (slideAnchor == null) {
  1589. slideAnchor = slideIndex;
  1590. }
  1591. setState({
  1592. lastScrolledSlide: slideAnchor
  1593. });
  1594. setUrlHash(sectionHash + '/' + slideAnchor); //first slide won't have slide anchor, just the section one
  1595. } else if (slideIndex != null) {
  1596. setState({
  1597. lastScrolledSlide: slideAnchor
  1598. });
  1599. setUrlHash(anchorLink);
  1600. } //section without slides
  1601. else {
  1602. setUrlHash(anchorLink);
  1603. }
  1604. }
  1605. setBodyClass();
  1606. }
  1607. /**
  1608. * Sets the URL hash.
  1609. */
  1610. function setUrlHash(url) {
  1611. if (getOptions().recordHistory) {
  1612. location.hash = url;
  1613. } else {
  1614. //Mobile Chrome doesn't work the normal way, so... lets use HTML5 for phones :)
  1615. if (isTouchDevice || isTouch) {
  1616. win.history.replaceState(undefined, undefined, '#' + url);
  1617. } else {
  1618. var baseUrl = win.location.href.split('#')[0];
  1619. win.location.replace(baseUrl + '#' + url);
  1620. }
  1621. }
  1622. }
  1623. /**
  1624. * Gets the name for screen readers for a section/slide navigation bullet.
  1625. */
  1626. function getBulletLinkName(i, defaultName, item) {
  1627. var anchor = defaultName === 'Section' ? getOptions().anchors[i] : getAttr(item, 'data-anchor');
  1628. return encodeURI(getOptions().navigationTooltips[i] || anchor || defaultName + ' ' + (i + 1));
  1629. }
  1630. function slideBulletHandler(e) {
  1631. // not all events are cancellable
  1632. // https://www.uriports.com/blog/easy-fix-for-intervention-ignored-attempt-to-cancel-a-touchmove-event-with-cancelable-false/
  1633. if (e.cancelable) {
  1634. preventDefault(e);
  1635. }
  1636. setState({
  1637. scrollTrigger: 'horizontalNav'
  1638. });
  1639. /*jshint validthis:true */
  1640. var sectionElem = closest(this, SECTION_SEL);
  1641. var slides = $(SLIDES_WRAPPER_SEL, closest(this, SECTION_SEL))[0];
  1642. var section = getPanelByElement(getState().sections, sectionElem);
  1643. var destiny = section.slides[index(closest(this, 'li'))];
  1644. EventEmitter.emit(events.landscapeScroll, {
  1645. slides: slides,
  1646. destination: destiny.item
  1647. });
  1648. }
  1649. /**
  1650. * Sets the state for the horizontal bullet navigations.
  1651. */
  1652. function activeSlidesNavigation(slidesNav, slideIndex) {
  1653. if (getOptions().slidesNavigation && slidesNav != null) {
  1654. removeClass($(ACTIVE_SEL, slidesNav), ACTIVE);
  1655. addClass($('a', $('li', slidesNav)[slideIndex]), ACTIVE);
  1656. }
  1657. }
  1658. /**
  1659. * Creates a landscape navigation bar with dots for horizontal sliders.
  1660. */
  1661. function addSlidesNavigation(section) {
  1662. var sectionElem = section.item;
  1663. var numSlides = section.slides.length;
  1664. appendTo(createElementFromHTML('<div class="' + SLIDES_NAV + '"><ul></ul></div>'), sectionElem);
  1665. var nav = $(SLIDES_NAV_SEL, sectionElem)[0]; //top or bottom
  1666. addClass(nav, 'fp-' + getOptions().slidesNavPosition);
  1667. for (var i = 0; i < numSlides; i++) {
  1668. var slide = $(SLIDE_SEL, sectionElem)[i];
  1669. appendTo(createElementFromHTML('<li><a href="#"><span class="fp-sr-only">' + getBulletLinkName(i, 'Slide', slide) + '</span><span></span></a></li>'), $('ul', nav)[0]);
  1670. } //centering it
  1671. css(nav, {
  1672. 'margin-left': '-' + nav.innerWidth / 2 + 'px'
  1673. });
  1674. var activeSlideIndex = section.activeSlide ? section.activeSlide.index() : 0;
  1675. addClass($('a', $('li', nav)[activeSlideIndex]), ACTIVE);
  1676. }
  1677. var isScrollAllowed = {};
  1678. isScrollAllowed.m = {
  1679. 'up': true,
  1680. 'down': true,
  1681. 'left': true,
  1682. 'right': true
  1683. };
  1684. isScrollAllowed.k = deepExtend({}, isScrollAllowed.m);
  1685. /**
  1686. * Allowing or disallowing the mouse/swipe scroll in a given direction. (not for keyboard)
  1687. * @param type m (mouse) or k (keyboard)
  1688. */
  1689. function setIsScrollAllowed(value, direction, type) {
  1690. //up, down, left, right
  1691. if (direction !== 'all') {
  1692. isScrollAllowed[type][direction] = value;
  1693. } //all directions?
  1694. else {
  1695. Object.keys(isScrollAllowed[type]).forEach(function (key) {
  1696. isScrollAllowed[type][key] = value;
  1697. });
  1698. }
  1699. }
  1700. function getIsScrollAllowed() {
  1701. return isScrollAllowed;
  1702. }
  1703. EventEmitter.on(events.onClickOrTouch, onClickOrTouch$2);
  1704. function onClickOrTouch$2(params) {
  1705. var target = params.target;
  1706. if (matches(target, SLIDES_ARROW_SEL) || closest(target, SLIDES_ARROW_SEL)) {
  1707. slideArrowHandler.call(target, params);
  1708. }
  1709. } //Scrolling horizontally when clicking on the slider controls.
  1710. function slideArrowHandler() {
  1711. /*jshint validthis:true */
  1712. var section = closest(this, SECTION_SEL);
  1713. /*jshint validthis:true */
  1714. if (hasClass(this, SLIDES_PREV)) {
  1715. if (getIsScrollAllowed().m.left) {
  1716. setState({
  1717. scrollTrigger: 'slideArrow'
  1718. });
  1719. EventEmitter.emit(events.moveSlideLeft, {
  1720. section: section
  1721. });
  1722. }
  1723. } else {
  1724. if (getIsScrollAllowed().m.right) {
  1725. setState({
  1726. scrollTrigger: 'slideArrow'
  1727. });
  1728. EventEmitter.emit(events.moveSlideRight, {
  1729. section: section
  1730. });
  1731. }
  1732. }
  1733. }
  1734. /**
  1735. * Creates the control arrows for the given section
  1736. */
  1737. function createSlideArrows(section) {
  1738. var sectionElem = section.item;
  1739. var arrows = [createElementFromHTML(getOptions().controlArrowsHTML[0]), createElementFromHTML(getOptions().controlArrowsHTML[1])];
  1740. after($(SLIDES_WRAPPER_SEL, sectionElem)[0], arrows);
  1741. addClass(arrows, SLIDES_ARROW);
  1742. addClass(arrows[0], SLIDES_PREV);
  1743. addClass(arrows[1], SLIDES_NEXT);
  1744. if (getOptions().controlArrowColor !== '#fff') {
  1745. css($(SLIDES_ARROW_NEXT_SEL, sectionElem), {
  1746. 'border-color': 'transparent transparent transparent ' + getOptions().controlArrowColor
  1747. });
  1748. css($(SLIDES_ARROW_PREV_SEL, sectionElem), {
  1749. 'border-color': 'transparent ' + getOptions().controlArrowColor + ' transparent transparent'
  1750. });
  1751. }
  1752. if (!getOptions().loopHorizontal) {
  1753. hide($(SLIDES_ARROW_PREV_SEL, sectionElem));
  1754. }
  1755. }
  1756. function toggleControlArrows(v) {
  1757. if (!getOptions().loopHorizontal && getOptions().controlArrows) {
  1758. //hidding it for the fist slide, showing for the rest
  1759. toggle($(SLIDES_ARROW_PREV_SEL, v.section), v.slideIndex !== 0); //hidding it for the last slide, showing for the rest
  1760. toggle($(SLIDES_ARROW_NEXT_SEL, v.section), next(v.destiny) != null);
  1761. }
  1762. }
  1763. FP.setRecordHistory = setRecordHistory;
  1764. /**
  1765. * Defines wheter to record the history for each hash change in the URL.
  1766. */
  1767. function setRecordHistory(value, type) {
  1768. setVariableState('recordHistory', value, type);
  1769. }
  1770. FP.setAutoScrolling = setAutoScrolling;
  1771. FP.test.setAutoScrolling = setAutoScrolling;
  1772. /**
  1773. * Sets the autoScroll option.
  1774. * It changes the scroll bar visibility and the history of the site as a result.
  1775. */
  1776. function setAutoScrolling(value, type) {
  1777. //removing the transformation
  1778. if (!value) {
  1779. silentScroll(0);
  1780. }
  1781. setVariableState('autoScrolling', value, type);
  1782. var element = getState().activeSection.item;
  1783. if (getOptions().autoScrolling && !getOptions().scrollBar) {
  1784. css($htmlBody, {
  1785. 'overflow': 'hidden',
  1786. 'height': '100%'
  1787. });
  1788. removeClass($body, 'fp-scrollable');
  1789. setRecordHistory(getOriginals().recordHistory, 'internal'); //for IE touch devices
  1790. css(getContainer(), {
  1791. '-ms-touch-action': 'none',
  1792. 'touch-action': 'none'
  1793. });
  1794. if (element != null) {
  1795. //moving the container up
  1796. silentScroll(element.offsetTop);
  1797. }
  1798. } else {
  1799. css($htmlBody, {
  1800. 'overflow': 'visible',
  1801. 'height': 'initial'
  1802. });
  1803. addClass($body, 'fp-scrollable');
  1804. var recordHistory = !getOptions().autoScrolling ? false : getOriginals().recordHistory;
  1805. setRecordHistory(recordHistory, 'internal'); //for IE touch devices
  1806. css(getContainer(), {
  1807. '-ms-touch-action': '',
  1808. 'touch-action': ''
  1809. }); //scrolling the page to the section with no animation
  1810. if (element != null) {
  1811. var scrollSettings = getScrollSettings(element.offsetTop);
  1812. scrollSettings.element.scrollTo(0, scrollSettings.options);
  1813. }
  1814. }
  1815. }
  1816. //@ts-check
  1817. /**
  1818. * Adds sections before or after the current one to create the infinite effect.
  1819. */
  1820. function createInfiniteSections(v) {
  1821. setState({
  1822. isDoingContinousVertical: true
  1823. });
  1824. var activeSectionItem = getState().activeSection.item; // Scrolling down
  1825. if (!v.isMovementUp) {
  1826. // Move all previous sections to after the active section
  1827. after(activeSectionItem, prevAll(activeSectionItem, SECTION_SEL).reverse());
  1828. } else {
  1829. // Scrolling up
  1830. // Move all next sections to before the active section
  1831. before(activeSectionItem, nextAll(activeSectionItem, SECTION_SEL));
  1832. } // Maintain the displayed position (now that we changed the element order)
  1833. silentScroll(getState().activeSection.item.offsetTop); // Maintain the active slides visible in the viewport
  1834. keepSlidesPosition$1(); // save for later the elements that still need to be reordered
  1835. v.wrapAroundElements = activeSectionItem; // Recalculate animation variables
  1836. v.dtop = v.element.offsetTop;
  1837. v.yMovement = getYmovement(getState().activeSection, v.element);
  1838. return v;
  1839. }
  1840. /**
  1841. * Maintains the active slides in the viewport
  1842. * (Because the `scroll` animation might get lost with some actions, such as when using continuousVertical)
  1843. */
  1844. function keepSlidesPosition$1() {
  1845. var activeSlides = $(SLIDE_ACTIVE_SEL);
  1846. for (var i = 0; i < activeSlides.length; i++) {
  1847. silentLandscapeScroll(activeSlides[i], 'internal');
  1848. }
  1849. }
  1850. //@ts-check
  1851. /**
  1852. * Maintains the active slides in the viewport
  1853. * (Because the `scroll` animation might get lost with some actions, such as when using continuousVertical)
  1854. */
  1855. function keepSlidesPosition() {
  1856. var activeSlides = $(SLIDE_ACTIVE_SEL);
  1857. for (var i = 0; i < activeSlides.length; i++) {
  1858. silentLandscapeScroll(activeSlides[i], 'internal');
  1859. }
  1860. }
  1861. /**
  1862. * Fix section order after continuousVertical changes have been animated
  1863. */
  1864. function continuousVerticalFixSectionOrder(v) {
  1865. // If continuousVertical is in effect (and autoScrolling would also be in effect then),
  1866. // finish moving the elements around so the direct navigation will function more simply
  1867. if (v.wrapAroundElements == null) {
  1868. return;
  1869. }
  1870. if (v.isMovementUp) {
  1871. before($(SECTION_SEL)[0], v.wrapAroundElements);
  1872. } else {
  1873. after($(SECTION_SEL)[getState().sections.length - 1], v.wrapAroundElements);
  1874. }
  1875. silentScroll(getState().activeSection.item.offsetTop); // Maintain the active slides visible in the viewport
  1876. keepSlidesPosition();
  1877. setState({
  1878. isDoingContinousVertical: false
  1879. });
  1880. }
  1881. /**
  1882. * Makes sure lazyload is done for other sections in the viewport that are not the
  1883. * active one.
  1884. */
  1885. function lazyLoadOthers() {
  1886. var hasAutoHeightSections = $(AUTO_HEIGHT_SEL)[0] || isResponsiveMode() && $(AUTO_HEIGHT_RESPONSIVE_SEL)[0]; //quitting when it doesn't apply
  1887. if (!getOptions().lazyLoading || !hasAutoHeightSections) {
  1888. return;
  1889. } //making sure to lazy load auto-height sections that are in the viewport
  1890. $(SECTION_SEL + ':not(' + ACTIVE_SEL + ')').forEach(function (section) {
  1891. if (isSectionInViewport(section)) {
  1892. lazyLoad(section);
  1893. }
  1894. });
  1895. }
  1896. /**
  1897. * Determines whether a section is in the viewport or not.
  1898. */
  1899. function isSectionInViewport(el) {
  1900. var rect = el.getBoundingClientRect();
  1901. var top = rect.top;
  1902. var bottom = rect.bottom; //sometimes there's a 1px offset on the bottom of the screen even when the
  1903. //section's height is the window.innerHeight one. I guess because pixels won't allow decimals.
  1904. //using this prevents from lazyLoading the section that is not yet visible
  1905. //(only 1 pixel offset is)
  1906. var pixelOffset = 2;
  1907. var isTopInView = top + pixelOffset < state.windowsHeight && top > 0;
  1908. var isBottomInView = bottom > pixelOffset && bottom < state.windowsHeight;
  1909. return isTopInView || isBottomInView;
  1910. }
  1911. function tooltipTextHandler() {
  1912. /*jshint validthis:true */
  1913. trigger(prev(this), 'click');
  1914. }
  1915. /**
  1916. * Activating the vertical navigation bullets according to the given slide name.
  1917. */
  1918. function activateNavDots(name, sectionIndex) {
  1919. var nav = $(SECTION_NAV_SEL)[0];
  1920. if (getOptions().navigation && nav != null && nav.style.display !== 'none') {
  1921. removeClass($(ACTIVE_SEL, nav), ACTIVE);
  1922. if (name) {
  1923. addClass($('a[href="#' + name + '"]', nav), ACTIVE);
  1924. } else {
  1925. addClass($('a', $('li', nav)[sectionIndex]), ACTIVE);
  1926. }
  1927. }
  1928. }
  1929. /**
  1930. * Creates a vertical navigation bar.
  1931. */
  1932. function addVerticalNavigation() {
  1933. remove($(SECTION_NAV_SEL));
  1934. var navigation = doc.createElement('div');
  1935. navigation.setAttribute('id', SECTION_NAV);
  1936. var divUl = doc.createElement('ul');
  1937. navigation.appendChild(divUl);
  1938. appendTo(navigation, $body);
  1939. var nav = $(SECTION_NAV_SEL)[0];
  1940. addClass(nav, 'fp-' + getOptions().navigationPosition);
  1941. if (getOptions().showActiveTooltip) {
  1942. addClass(nav, SHOW_ACTIVE_TOOLTIP);
  1943. }
  1944. var li = '';
  1945. for (var i = 0; i < getState().sections.length; i++) {
  1946. var section = getState().sections[i];
  1947. var link = '';
  1948. if (getOptions().anchors.length) {
  1949. link = section.anchor;
  1950. }
  1951. li += '<li><a href="#' + encodeURI(link) + '"><span class="fp-sr-only">' + getBulletLinkName(section.index(), 'Section') + '</span><span></span></a>'; // Only add tooltip if needed (defined by user)
  1952. var tooltip = getOptions().navigationTooltips[section.index()];
  1953. if (typeof tooltip !== 'undefined' && tooltip !== '') {
  1954. li += '<div class="' + SECTION_NAV_TOOLTIP + ' fp-' + getOptions().navigationPosition + '">' + tooltip + '</div>';
  1955. }
  1956. li += '</li>';
  1957. }
  1958. $('ul', nav)[0].innerHTML = li; //activating the current active section
  1959. var bullet = $('li', $(SECTION_NAV_SEL)[0])[getState().activeSection.index()];
  1960. addClass($('a', bullet), ACTIVE);
  1961. } //Scrolls to the section when clicking the navigation bullet
  1962. function sectionBulletHandler(e) {
  1963. if (e.preventDefault) {
  1964. preventDefault(e);
  1965. }
  1966. setState({
  1967. scrollTrigger: 'verticalNav'
  1968. });
  1969. /*jshint validthis:true */
  1970. // @ts-ignore
  1971. var indexBullet = index(closest(this, SECTION_NAV_SEL + ' li'));
  1972. EventEmitter.emit(events.scrollPage, {
  1973. destination: getState().sections[indexBullet]
  1974. });
  1975. }
  1976. /**
  1977. * Sets to active the current menu and vertical nav items.
  1978. */
  1979. function activateMenuAndNav(anchor, index) {
  1980. activateMenuElement(anchor);
  1981. activateNavDots(anchor, index);
  1982. }
  1983. /**
  1984. * Activating the website main menu elements according to the given slide name.
  1985. */
  1986. function activateMenuElement(name) {
  1987. if (getOptions().menu && getOptions().menu.length) {
  1988. $(getOptions().menu).forEach(function (menu) {
  1989. if (menu != null) {
  1990. removeClass($(ACTIVE_SEL, menu), ACTIVE);
  1991. addClass($('[data-menuanchor="' + name + '"]', menu), ACTIVE);
  1992. }
  1993. });
  1994. }
  1995. }
  1996. new Date().getTime();
  1997. /**
  1998. * Triggers the callback once per scroll wheel action.
  1999. * Based on scrolling speed delay.
  2000. */
  2001. var oncePerScroll = function () {
  2002. var canTriggerEvent = true;
  2003. var prevWheelTime = new Date().getTime();
  2004. var result;
  2005. var isScrollingOnInit = !win.fullpage_api;
  2006. return function (scrollTrigger, callback) {
  2007. var currentTime = new Date().getTime();
  2008. var timeThreshold = scrollTrigger === 'wheel' ? getOptions().scrollingSpeed : 100;
  2009. canTriggerEvent = isScrollingOnInit || currentTime - prevWheelTime >= timeThreshold;
  2010. isScrollingOnInit = !win.fullpage_api;
  2011. if (canTriggerEvent) {
  2012. result = callback();
  2013. prevWheelTime = currentTime;
  2014. }
  2015. return typeof result !== 'undefined' ? result : true;
  2016. };
  2017. }();
  2018. /**
  2019. * Fires the wheel event once per mouse wheel trigger.
  2020. */
  2021. function fireCallbackOncePerScroll(callbackName, params) {
  2022. if (!isFunction(getOptions().beforeLeave)) {
  2023. return;
  2024. }
  2025. var result = oncePerScroll(getState().scrollTrigger, function () {
  2026. return fireCallback(callbackName, params);
  2027. });
  2028. return result;
  2029. }
  2030. FP.moveTo = moveTo;
  2031. FP.getScrollY = function () {
  2032. return state.scrollY;
  2033. };
  2034. var g_afterSectionLoadsId;
  2035. var g_transitionLapseId;
  2036. EventEmitter.on(events.onDestroy, onDestroy$8);
  2037. /**
  2038. * Scrolls the site to the given element and scrolls to the slide if a callback is given.
  2039. */
  2040. function scrollPage(section, callback, isMovementUp) {
  2041. var element = section.item;
  2042. if (element == null) {
  2043. return;
  2044. } //there's no element to scroll, leaving the function
  2045. var dtop = getDestinationPosition(element);
  2046. var slideAnchorLink;
  2047. var slideIndex; //local variables
  2048. var v = {
  2049. "element": element,
  2050. "callback": callback,
  2051. "isMovementUp": isMovementUp,
  2052. "dtop": dtop,
  2053. "yMovement": getYmovement(getState().activeSection, element),
  2054. "anchorLink": section.anchor,
  2055. "sectionIndex": section.index(),
  2056. "activeSlide": section.activeSlide ? section.activeSlide.item : null,
  2057. "leavingSection": getState().activeSection.index() + 1,
  2058. //caching the value of isResizing at the momment the function is called
  2059. //because it will be checked later inside a setTimeout and the value might change
  2060. "localIsResizing": state.isResizing,
  2061. "items": {
  2062. "origin": getState().activeSection,
  2063. "destination": section
  2064. },
  2065. "direction": null
  2066. }; //quiting when destination scroll is the same as the current one
  2067. if (getState().activeSection.item == element && !state.isResizing || getOptions().scrollBar && getScrollTop() === v.dtop && !hasClass(element, AUTO_HEIGHT)) {
  2068. return;
  2069. }
  2070. if (v.activeSlide != null) {
  2071. slideAnchorLink = getAttr(v.activeSlide, 'data-anchor');
  2072. slideIndex = index(v.activeSlide, null);
  2073. } //callback (onLeave) if the site is not just resizing and readjusting the slides
  2074. if (!v.localIsResizing) {
  2075. var direction = v.yMovement; //required for continousVertical
  2076. if (typeof isMovementUp !== 'undefined') {
  2077. direction = isMovementUp ? 'up' : 'down';
  2078. } //for the callback
  2079. v.direction = direction;
  2080. if (isFunction(getOptions().beforeLeave)) {
  2081. if (fireCallbackOncePerScroll('beforeLeave', v) === false) {
  2082. return;
  2083. }
  2084. }
  2085. if (isFunction(getOptions().onLeave)) {
  2086. if (!fireCallback('onLeave', v)) {
  2087. return;
  2088. }
  2089. }
  2090. } // If continuousVertical && we need to wrap around
  2091. if (getOptions().autoScrolling && getOptions().continuousVertical && typeof v.isMovementUp !== "undefined" && (!v.isMovementUp && v.yMovement == 'up' || // Intending to scroll down but about to go up or
  2092. v.isMovementUp && v.yMovement == 'down')) {
  2093. // intending to scroll up but about to go down
  2094. v = createInfiniteSections(v);
  2095. } //pausing media of the leaving section (if we are not just resizing, as destinatino will be the same one)
  2096. if (!v.localIsResizing) {
  2097. stopMedia(getState().activeSection.item);
  2098. }
  2099. addClass(element, ACTIVE);
  2100. removeClass(siblings(element), ACTIVE);
  2101. updateState();
  2102. lazyLoad(element); //preventing from activating the MouseWheelHandler event
  2103. //more than once if the page is scrolling
  2104. setState({
  2105. canScroll: FP.test.isTesting
  2106. });
  2107. setPageStatus(slideIndex, slideAnchorLink, v.anchorLink);
  2108. EventEmitter.emit(events.onLeave, v);
  2109. performMovement(v); //flag to avoid callingn `scrollPage()` twice in case of using anchor links
  2110. setState({
  2111. lastScrolledDestiny: v.anchorLink
  2112. }); //avoid firing it twice (as it does also on scroll)
  2113. activateMenuAndNav(v.anchorLink, v.sectionIndex);
  2114. }
  2115. function onDestroy$8() {
  2116. clearTimeout(g_afterSectionLoadsId);
  2117. clearTimeout(g_transitionLapseId);
  2118. }
  2119. /**
  2120. * Returns the destination Y position based on the scrolling direction and
  2121. * the height of the section.
  2122. */
  2123. function getDestinationPosition(element) {
  2124. var elementHeight = element.offsetHeight;
  2125. var elementTop = element.offsetTop; //top of the desination will be at the top of the viewport
  2126. var position = elementTop;
  2127. var isScrollingDown = elementTop > state.previousDestTop;
  2128. var sectionBottom = position - getWindowHeight() + elementHeight;
  2129. var bigSectionsDestination = getOptions().bigSectionsDestination; //is the destination element bigger than the viewport?
  2130. if (elementHeight > getWindowHeight()) {
  2131. //scrolling up?
  2132. if (!isScrollingDown && !bigSectionsDestination || bigSectionsDestination === 'bottom') {
  2133. position = sectionBottom;
  2134. }
  2135. } //sections equal or smaller than the viewport height && scrolling down? || is resizing and its in the last section
  2136. else if (isScrollingDown || state.isResizing && next(element) == null) {
  2137. //The bottom of the destination will be at the bottom of the viewport
  2138. position = sectionBottom;
  2139. }
  2140. /*
  2141. Keeping record of the last scrolled position to determine the scrolling direction.
  2142. No conventional methods can be used as the scroll bar might not be present
  2143. AND the section might not be active if it is auto-height and didnt reach the middle
  2144. of the viewport.
  2145. */
  2146. setState({
  2147. previousDestTop: position
  2148. });
  2149. return position;
  2150. }
  2151. /**
  2152. * Performs the vertical movement (by CSS3 or by jQuery)
  2153. */
  2154. function performMovement(v) {
  2155. var isFastSpeed = getOptions().scrollingSpeed < 700;
  2156. var transitionLapse = isFastSpeed ? 700 : getOptions().scrollingSpeed;
  2157. setState({
  2158. touchDirection: 'none',
  2159. scrollY: Math.round(v.dtop)
  2160. });
  2161. EventEmitter.emit(events.onPerformMovement); // using CSS3 translate functionality
  2162. if (getOptions().css3 && getOptions().autoScrolling && !getOptions().scrollBar) {
  2163. // The first section can have a negative value in iOS 10. Not quite sure why: -0.0142822265625
  2164. // that's why we round it to 0.
  2165. var translate3d = 'translate3d(0px, -' + Math.round(v.dtop) + 'px, 0px)';
  2166. transformContainer(translate3d, true); //even when the scrollingSpeed is 0 there's a little delay, which might cause the
  2167. //scrollingSpeed to change in case of using silentMoveTo();ç
  2168. if (getOptions().scrollingSpeed) {
  2169. clearTimeout(g_afterSectionLoadsId);
  2170. g_afterSectionLoadsId = setTimeout(function () {
  2171. afterSectionLoads$1(v); //disabling canScroll when using fastSpeed
  2172. setState({
  2173. canScroll: !isFastSpeed || FP.test.isTesting
  2174. });
  2175. }, getOptions().scrollingSpeed);
  2176. } else {
  2177. afterSectionLoads$1(v);
  2178. }
  2179. } // using JS to animate
  2180. else {
  2181. var scrollSettings = getScrollSettings(v.dtop);
  2182. FP.test.top = -v.dtop + 'px';
  2183. clearTimeout(g_afterSectionLoadsId);
  2184. scrollTo(scrollSettings.element, scrollSettings.options, getOptions().scrollingSpeed, function () {
  2185. if (getOptions().scrollBar) {
  2186. /* Hack!
  2187. The timeout prevents setting the most dominant section in the viewport as "active" when the user
  2188. scrolled to a smaller section by using the mousewheel (auto scrolling) rather than draging the scroll bar.
  2189. When using scrollBar:true It seems like the scroll events still getting propagated even after the scrolling animation has finished.
  2190. */
  2191. g_afterSectionLoadsId = setTimeout(function () {
  2192. afterSectionLoads$1(v);
  2193. }, 30);
  2194. } else {
  2195. afterSectionLoads$1(v); //disabling canScroll when using fastSpeed
  2196. setState({
  2197. canScroll: !isFastSpeed || FP.test.isTesting
  2198. });
  2199. }
  2200. });
  2201. } // enabling canScroll after the minimum transition laps
  2202. if (isFastSpeed) {
  2203. clearTimeout(g_transitionLapseId);
  2204. g_transitionLapseId = setTimeout(function () {
  2205. setState({
  2206. canScroll: true
  2207. });
  2208. }, transitionLapse);
  2209. }
  2210. }
  2211. /**
  2212. * Actions to do once the section is loaded.
  2213. */
  2214. function afterSectionLoads$1(v) {
  2215. setState({
  2216. isBeyondFullpage: false
  2217. });
  2218. continuousVerticalFixSectionOrder(v); //callback (afterLoad) if the site is not just resizing and readjusting the slides
  2219. if (isFunction(getOptions().afterLoad) && !v.localIsResizing) {
  2220. fireCallback('afterLoad', v);
  2221. }
  2222. updateState();
  2223. if (!v.localIsResizing) {
  2224. playMedia(v.element);
  2225. }
  2226. addClass(v.element, COMPLETELY);
  2227. removeClass(siblings(v.element), COMPLETELY);
  2228. lazyLoadOthers();
  2229. setState({
  2230. canScroll: true
  2231. });
  2232. EventEmitter.emit(events.afterSectionLoads, v);
  2233. if (isFunction(v.callback)) {
  2234. v.callback();
  2235. }
  2236. }
  2237. FP.setFitToSection = setFitToSection;
  2238. FP.fitToSection = fitToSection;
  2239. /**
  2240. * Sets fitToSection
  2241. */
  2242. function setFitToSection(value, type) {
  2243. setVariableState('fitToSection', value, type);
  2244. }
  2245. /**
  2246. * Fits the site to the nearest active section
  2247. */
  2248. function fitToSection() {
  2249. //checking fitToSection again in case it was set to false before the timeout delay
  2250. if (state.canScroll) {
  2251. //allows to scroll to an active section and
  2252. //if the section is already active, we prevent firing callbacks
  2253. setState({
  2254. isResizing: true
  2255. });
  2256. scrollPage(state.activeSection);
  2257. setState({
  2258. isResizing: false
  2259. });
  2260. }
  2261. }
  2262. FP.setResponsive = setResponsive;
  2263. /**
  2264. * Checks if the site needs to get responsive and disables autoScrolling if so.
  2265. * A class `fp-responsive` is added to the plugin's container in case the user wants to use it for his own responsive CSS.
  2266. */
  2267. function responsive() {
  2268. var widthLimit = getOptions().responsive || getOptions().responsiveWidth; //backwards compatiblity
  2269. var heightLimit = getOptions().responsiveHeight; //only calculating what we need. Remember its called on the resize event.
  2270. var isBreakingPointWidth = widthLimit && win.innerWidth < widthLimit;
  2271. var isBreakingPointHeight = heightLimit && win.innerHeight < heightLimit;
  2272. if (widthLimit && heightLimit) {
  2273. setResponsive(isBreakingPointWidth || isBreakingPointHeight);
  2274. } else if (widthLimit) {
  2275. setResponsive(isBreakingPointWidth);
  2276. } else if (heightLimit) {
  2277. setResponsive(isBreakingPointHeight);
  2278. }
  2279. }
  2280. /**
  2281. * Turns fullPage.js to normal scrolling mode when the viewport `width` or `height`
  2282. * are smaller than the set limit values.
  2283. */
  2284. function setResponsive(active) {
  2285. var isResponsive = isResponsiveMode();
  2286. if (active) {
  2287. if (!isResponsive) {
  2288. setAutoScrolling(false, 'internal');
  2289. setFitToSection(false, 'internal');
  2290. hide($(SECTION_NAV_SEL));
  2291. addClass($body, RESPONSIVE);
  2292. if (isFunction(getOptions().afterResponsive)) {
  2293. getOptions().afterResponsive.call(getContainer(), active);
  2294. }
  2295. }
  2296. } else if (isResponsive) {
  2297. setAutoScrolling(getOriginals().autoScrolling, 'internal');
  2298. setFitToSection(getOriginals().autoScrolling, 'internal');
  2299. show($(SECTION_NAV_SEL));
  2300. removeClass($body, RESPONSIVE);
  2301. if (isFunction(getOptions().afterResponsive)) {
  2302. getOptions().afterResponsive.call(getContainer(), active);
  2303. }
  2304. }
  2305. }
  2306. /**
  2307. * Determines whether fullpage.js is in responsive mode or not.
  2308. */
  2309. function isResponsiveMode() {
  2310. return hasClass($body, RESPONSIVE);
  2311. }
  2312. function addTableClass(element) {
  2313. if (!getOptions().verticalCentered) {
  2314. return;
  2315. } // Overflowing sections when scrollOverflow is disabled will be autoHeight
  2316. // and won't require vertical aligment
  2317. if (!getOptions().scrollOverflow && scrollOverflowHandler.shouldBeScrollable(element.item)) {
  2318. return;
  2319. }
  2320. if (!scrollOverflowHandler.isScrollable(element)) {
  2321. //In case we are styling for the 2nd time as in with reponsiveSlides
  2322. if (!hasClass(element.item, TABLE)) {
  2323. addClass(element.item, TABLE);
  2324. }
  2325. }
  2326. }
  2327. var startingSection = null;
  2328. FP.getActiveSection = getActiveSection;
  2329. function getStartingSection() {
  2330. return startingSection;
  2331. }
  2332. /**
  2333. * Styling vertical sections
  2334. */
  2335. function styleSection(section) {
  2336. var sectionElem = section.item;
  2337. var hasSlides = section.allSlidesItems.length;
  2338. var index = section.index(); //if no active section is defined, the 1st one will be the default one
  2339. if (!getState().activeSection && section.isVisible) {
  2340. addClass(sectionElem, ACTIVE);
  2341. updateState();
  2342. startingSection = getState().activeSection.item;
  2343. }
  2344. if (getOptions().paddingTop) {
  2345. css(sectionElem, {
  2346. 'padding-top': getOptions().paddingTop
  2347. });
  2348. }
  2349. if (getOptions().paddingBottom) {
  2350. css(sectionElem, {
  2351. 'padding-bottom': getOptions().paddingBottom
  2352. });
  2353. }
  2354. if (typeof getOptions().sectionsColor[index] !== 'undefined') {
  2355. css(sectionElem, {
  2356. 'background-color': getOptions().sectionsColor[index]
  2357. });
  2358. }
  2359. if (typeof getOptions().anchors[index] !== 'undefined') {
  2360. sectionElem.setAttribute('data-anchor', section.anchor);
  2361. }
  2362. if (!hasSlides) {
  2363. addTableClass(section);
  2364. }
  2365. }
  2366. /**
  2367. * Gets the active section.
  2368. */
  2369. function getActiveSection() {
  2370. return getState().activeSection;
  2371. }
  2372. function getSectionFromPanel(panel) {
  2373. return panel.isSection ? panel : panel.parent;
  2374. }
  2375. var g_focusScrollableId;
  2376. EventEmitter.on(events.bindEvents, bindEvents$b);
  2377. function bindEvents$b() {
  2378. // We can't focus scrollOverflow before scrolling
  2379. // to the anchor (if we need to)
  2380. EventEmitter.on(events.onAfterRenderNoAnchor, afterRender);
  2381. EventEmitter.on(events.onLeave, scrollOverflowHandler.onLeave);
  2382. EventEmitter.on(events.onSlideLeave, scrollOverflowHandler.onLeave);
  2383. EventEmitter.on(events.afterSlideLoads, scrollOverflowHandler.afterLoad);
  2384. EventEmitter.on(events.afterSectionLoads, scrollOverflowHandler.afterLoad);
  2385. EventEmitter.on(events.onDestroy, onDestroy$7);
  2386. docAddEvent('keyup', scrollOverflowHandler.keyUpHandler);
  2387. }
  2388. function afterRender() {
  2389. if (getOptions().scrollOverflow && !getOptions().scrollBar) {
  2390. scrollOverflowHandler.makeScrollable();
  2391. scrollOverflowHandler.focusScrollable();
  2392. }
  2393. }
  2394. function onDestroy$7() {
  2395. EventEmitter.removeListener(events.onAfterRenderNoAnchor, afterRender);
  2396. docRemoveEvent('keyup', scrollOverflowHandler.keyUpHandler);
  2397. }
  2398. var scrollOverflowHandler = {
  2399. focusedElem: null,
  2400. shouldFocusScrollable: true,
  2401. isInnerScrollAllowed: true,
  2402. timeBeforeReachingLimit: null,
  2403. timeLastScroll: null,
  2404. preventScrollWithMouseWheel: function preventScrollWithMouseWheel(e) {
  2405. if (!state.canScroll) {
  2406. preventDefault(e);
  2407. return false;
  2408. }
  2409. },
  2410. preventScrollWithKeyboard: function preventScrollWithKeyboard(e) {
  2411. if (!isInsideInput() && getOptions().keyboardScrolling) {
  2412. var directionKeys = [38, 33, 32, 40, 34, 36, 35];
  2413. if (directionKeys.indexOf(e.keyCode) > -1 && !scrollOverflowHandler.isInnerScrollAllowed) {
  2414. preventDefault(e);
  2415. return false;
  2416. }
  2417. }
  2418. },
  2419. keyUpHandler: function keyUpHandler() {
  2420. scrollOverflowHandler.shouldFocusScrollable = state.canScroll;
  2421. },
  2422. // Leaving sections or slides
  2423. onLeave: function onLeave() {
  2424. clearTimeout(g_focusScrollableId);
  2425. scrollOverflowHandler.isInnerScrollAllowed = false;
  2426. },
  2427. // Loading sections or slides
  2428. afterLoad: function afterLoad() {
  2429. scrollOverflowHandler.isInnerScrollAllowed = false; // Delaying it to avoid issues on Safari when focusing elements #4484 & #4493
  2430. clearTimeout(g_focusScrollableId);
  2431. g_focusScrollableId = setTimeout(function () {
  2432. scrollOverflowHandler.shouldFocusScrollable = state.canScroll;
  2433. }, 200);
  2434. },
  2435. // Unfocusing the scrollable element from the orgin section/slide
  2436. unfocusScrollable: function unfocusScrollable() {
  2437. if (doc.activeElement === this.focusedElem) {
  2438. // @ts-ignore
  2439. this.focusedElem.blur();
  2440. scrollOverflowHandler.isInnerScrollAllowed = false;
  2441. }
  2442. },
  2443. focusScrollable: function focusScrollable() {
  2444. if (!getOptions().scrollOverflow || !scrollOverflowHandler.shouldFocusScrollable) {
  2445. return;
  2446. }
  2447. scrollOverflowHandler.unfocusScrollable();
  2448. var scrollableItem = scrollOverflowHandler.getScrollableItem(getState().activeSection.item); // On desktop we focus the scrollable to be able to use the mouse wheel
  2449. // We avoid it on mobile due to a bug in iOS Safari
  2450. if (scrollableItem && !isTouchDevice && !isTouch) {
  2451. this.focusedElem = scrollableItem; // Forcing the focus on the next paint
  2452. // to avoid issue #4484 & #4493 on Safari
  2453. requestAnimationFrame(function () {
  2454. scrollableItem.focus();
  2455. scrollOverflowHandler.isInnerScrollAllowed = true;
  2456. });
  2457. }
  2458. scrollOverflowHandler.shouldFocusScrollable = false;
  2459. },
  2460. makeScrollable: function makeScrollable() {
  2461. if (getOptions().scrollOverflowMacStyle && !isMacDevice) {
  2462. addClass($body, 'fp-scroll-mac');
  2463. }
  2464. getState().panels.forEach(function (el) {
  2465. if (el.slides && el.slides.length) {
  2466. return;
  2467. }
  2468. if (hasClass(el.item, AUTO_HEIGHT_RESPONSIVE) && isResponsiveMode()) {
  2469. return;
  2470. } else {
  2471. var item = getSlideOrSection(el.item);
  2472. var shouldBeScrollable = scrollOverflowHandler.shouldBeScrollable(el.item);
  2473. var section = getSectionFromPanel(el);
  2474. if (isIE11) {
  2475. var toggleAction = shouldBeScrollable ? 'addClass' : 'removeClass';
  2476. utils[toggleAction](section.item, IS_OVERFLOW);
  2477. utils[toggleAction](el.item, IS_OVERFLOW);
  2478. } else {
  2479. addClass(section.item, IS_OVERFLOW);
  2480. addClass(el.item, IS_OVERFLOW);
  2481. }
  2482. if (!el.hasScroll) {
  2483. scrollOverflowHandler.createWrapper(item);
  2484. scrollOverflowHandler.bindEvents(item);
  2485. } // updating the state now in case
  2486. // this is executed on page load (after images load)
  2487. el.hasScroll = true;
  2488. }
  2489. });
  2490. },
  2491. bindEvents: function bindEvents(item) {
  2492. scrollOverflowHandler.getScrollableItem(item).addEventListener('scroll', scrollOverflowHandler.onPanelScroll);
  2493. item.addEventListener('wheel', scrollOverflowHandler.preventScrollWithMouseWheel, {
  2494. passive: false
  2495. });
  2496. item.addEventListener('keydown', scrollOverflowHandler.preventScrollWithKeyboard, {
  2497. passive: false
  2498. });
  2499. },
  2500. createWrapper: function createWrapper(item) {
  2501. var overflowWrapper = document.createElement('div');
  2502. overflowWrapper.className = OVERFLOW;
  2503. wrapInner(item, overflowWrapper);
  2504. overflowWrapper.setAttribute('tabindex', '-1');
  2505. },
  2506. destroyWrapper: function destroyWrapper(item) {
  2507. var overflowWrapper = $(OVERFLOW_SEL, item)[0];
  2508. if (overflowWrapper) {
  2509. unwrap(overflowWrapper);
  2510. item.removeAttribute('tabindex');
  2511. }
  2512. },
  2513. getScrollableItem: function getScrollableItem(sectionItem) {
  2514. var panel = getSlideOrSection(sectionItem);
  2515. return $(OVERFLOW_SEL, panel)[0] || panel;
  2516. },
  2517. hasScroll: function hasScroll(panelItem) {
  2518. return hasClass(panelItem, OVERFLOW) || $(OVERFLOW_SEL, panelItem)[0] != null;
  2519. },
  2520. isScrollable: function isScrollable(panel) {
  2521. return panel.isSection && panel.activeSlide ? panel.activeSlide.hasScroll : panel.hasScroll;
  2522. },
  2523. shouldBeScrollable: function shouldBeScrollable(item) {
  2524. var scrollable = scrollOverflowHandler.getScrollableItem(item);
  2525. return scrollable.scrollHeight > win.innerHeight;
  2526. },
  2527. isScrolled: function isScrolled(direction, el) {
  2528. if (!state.canScroll) {
  2529. return false;
  2530. } // we won't allow scrolloverflow on scrollBar:true
  2531. if (getOptions().scrollBar) {
  2532. return true;
  2533. }
  2534. var scrollableItem = scrollOverflowHandler.getScrollableItem(el);
  2535. if (!getOptions().scrollOverflow || !hasClass(scrollableItem, OVERFLOW) || // Checking the section first
  2536. // In case they apply to both section + slide #4505
  2537. hasClass(el, 'fp-noscroll') || // Checking the slide (in case it has)
  2538. hasClass(getSlideOrSection(el), 'fp-noscroll')) {
  2539. return true;
  2540. } // ie11 wrongly calculates scrollHeight when using the CSS style
  2541. // overflow: auto It adds 1 more pixel compared to offsetHeight
  2542. var ie11offset = isIE11 ? 1 : 0;
  2543. var positionY = scrollableItem.scrollTop;
  2544. var isTopReached = direction === 'up' && positionY <= 0;
  2545. var isBottomReached = direction === 'down' && scrollableItem.scrollHeight <= Math.ceil(scrollableItem.offsetHeight + positionY) + ie11offset;
  2546. var isScrolled = isTopReached || isBottomReached;
  2547. if (!isScrolled) {
  2548. this.timeBeforeReachingLimit = new Date().getTime();
  2549. }
  2550. return isScrolled;
  2551. },
  2552. shouldMovePage: function shouldMovePage() {
  2553. this.timeLastScroll = new Date().getTime();
  2554. var timeDiff = this.timeLastScroll - scrollOverflowHandler.timeBeforeReachingLimit;
  2555. var isUsingTouch = isTouchDevice || isTouch;
  2556. var isGrabbing = isUsingTouch && state.isGrabbing;
  2557. var isNotFirstTimeReachingLimit = state.isUsingWheel && timeDiff > 600;
  2558. return isGrabbing && timeDiff > 400 || isNotFirstTimeReachingLimit;
  2559. },
  2560. onPanelScroll: function () {
  2561. var prevPosition = 0;
  2562. return function (e) {
  2563. var currentPosition = e.target.scrollTop;
  2564. var direction = state.touchDirection !== 'none' ? state.touchDirection : prevPosition < currentPosition ? 'down' : 'up';
  2565. prevPosition = currentPosition;
  2566. if (isFunction(getOptions().onScrollOverflow)) {
  2567. fireCallback('onScrollOverflow', {
  2568. position: currentPosition,
  2569. direction: direction
  2570. });
  2571. }
  2572. if (hasClass(e.target, OVERFLOW) && state.canScroll) {
  2573. if (scrollOverflowHandler.isScrolled(direction, e.target) && scrollOverflowHandler.shouldMovePage()) {
  2574. // Checking again if we have a scrollable content
  2575. // To avoid issues like #4479 where the scroll event gets
  2576. // triggered after removing/hidding content if this was scrolled
  2577. if (scrollOverflowHandler.shouldBeScrollable(getState().activeSection.item)) {
  2578. EventEmitter.emit(events.onScrollOverflowScrolled, {
  2579. direction: direction
  2580. });
  2581. }
  2582. }
  2583. }
  2584. };
  2585. }()
  2586. };
  2587. var g_afterSlideLoadsId;
  2588. FP.landscapeScroll = landscapeScroll;
  2589. EventEmitter.on(events.bindEvents, bindEvents$a);
  2590. function bindEvents$a() {
  2591. EventEmitter.on(events.onPerformMovement, onPerformMovement);
  2592. }
  2593. function onPerformMovement() {
  2594. clearTimeout(g_afterSlideLoadsId);
  2595. setState({
  2596. slideMoving: false
  2597. });
  2598. }
  2599. /**
  2600. * Scrolls horizontal sliders.
  2601. */
  2602. function landscapeScroll(slides, destiny, direction) {
  2603. var sectionElem = closest(slides, SECTION_SEL);
  2604. var section = getState().sections.filter(function (section) {
  2605. return section.item == sectionElem;
  2606. })[0];
  2607. var slide = section.slides.filter(function (slide) {
  2608. return slide.item == destiny;
  2609. })[0];
  2610. var v = {
  2611. "slides": slides,
  2612. "destiny": destiny,
  2613. "direction": direction,
  2614. "destinyPos": {
  2615. "left": destiny.offsetLeft
  2616. },
  2617. "slideIndex": slide.index(),
  2618. "section": sectionElem,
  2619. "sectionIndex": section.index(),
  2620. "anchorLink": section.anchor,
  2621. "slidesNav": $(SLIDES_NAV_SEL, sectionElem)[0],
  2622. "slideAnchor": slide.anchor,
  2623. "prevSlide": section.activeSlide.item,
  2624. "prevSlideIndex": section.activeSlide.index(),
  2625. "items": {
  2626. "section": section,
  2627. "origin": section.activeSlide,
  2628. "destination": slide
  2629. },
  2630. //caching the value of isResizing at the momment the function is called
  2631. //because it will be checked later inside a setTimeout and the value might change
  2632. "localIsResizing": state.isResizing
  2633. };
  2634. v.xMovement = getXmovement(v.prevSlideIndex, v.slideIndex);
  2635. v.direction = v.direction ? v.direction : v.xMovement; //important!! Only do it when not resizing
  2636. if (!v.localIsResizing) {
  2637. //preventing from scrolling to the next/prev section when using scrollHorizontally
  2638. setState({
  2639. canScroll: false
  2640. });
  2641. }
  2642. if (getOptions().onSlideLeave) {
  2643. //if the site is not just resizing and readjusting the slides
  2644. if (!v.localIsResizing && v.xMovement !== 'none') {
  2645. if (isFunction(getOptions().onSlideLeave)) {
  2646. if (fireCallback('onSlideLeave', v) === false) {
  2647. setState({
  2648. slideMoving: false
  2649. });
  2650. return;
  2651. }
  2652. }
  2653. }
  2654. }
  2655. addClass(destiny, ACTIVE);
  2656. removeClass(siblings(destiny), ACTIVE);
  2657. updateState();
  2658. if (!v.localIsResizing) {
  2659. stopMedia(v.prevSlide);
  2660. lazyLoad(destiny);
  2661. }
  2662. toggleControlArrows(v); //only changing the URL if the slides are in the current section (not for resize re-adjusting)
  2663. if (section.isActive && !v.localIsResizing) {
  2664. setPageStatus(v.slideIndex, v.slideAnchor, v.anchorLink);
  2665. }
  2666. EventEmitter.emit(events.onSlideLeave, v);
  2667. performHorizontalMove(slides, v, true);
  2668. }
  2669. /**
  2670. * Performs the horizontal movement. (CSS3 or jQuery)
  2671. *
  2672. * @param fireCallback {Boolean} - determines whether or not to fire the callback
  2673. */
  2674. function performHorizontalMove(slides, v, fireCallback) {
  2675. var destinyPos = v.destinyPos;
  2676. activeSlidesNavigation(v.slidesNav, v.slideIndex);
  2677. setState({
  2678. scrollX: Math.round(destinyPos.left)
  2679. });
  2680. if (getOptions().css3) {
  2681. var translate3d = 'translate3d(-' + Math.round(destinyPos.left) + 'px, 0px, 0px)';
  2682. FP.test.translate3dH[v.sectionIndex] = translate3d;
  2683. css(addAnimation($(SLIDES_CONTAINER_SEL, slides)), getTransforms(translate3d));
  2684. clearTimeout(g_afterSlideLoadsId);
  2685. g_afterSlideLoadsId = setTimeout(function () {
  2686. if (fireCallback) {
  2687. afterSlideLoads(v);
  2688. }
  2689. }, getOptions().scrollingSpeed);
  2690. } else {
  2691. FP.test.left[v.sectionIndex] = Math.round(destinyPos.left);
  2692. scrollTo(slides, Math.round(destinyPos.left), getOptions().scrollingSpeed, function () {
  2693. if (fireCallback) {
  2694. afterSlideLoads(v);
  2695. }
  2696. });
  2697. }
  2698. }
  2699. /**
  2700. * Retuns `right` or `left` depending on the scrolling movement to reach its destination
  2701. * from the current slide.
  2702. */
  2703. function getXmovement(fromIndex, toIndex) {
  2704. if (fromIndex == toIndex) {
  2705. return 'none';
  2706. }
  2707. if (fromIndex > toIndex) {
  2708. return 'left';
  2709. }
  2710. return 'right';
  2711. }
  2712. function onDestroy$6() {
  2713. clearTimeout(g_afterSlideLoadsId);
  2714. }
  2715. function afterSlideLoads(v) {
  2716. //if the site is not just resizing and readjusting the slides
  2717. if (!v.localIsResizing) {
  2718. if (isFunction(getOptions().afterSlideLoad)) {
  2719. fireCallback('afterSlideLoad', v);
  2720. } //needs to be inside the condition to prevent problems with continuousVertical and scrollHorizontally
  2721. //and to prevent double scroll right after a windows resize
  2722. setState({
  2723. canScroll: true
  2724. });
  2725. playMedia(v.destiny);
  2726. EventEmitter.emit(events.afterSlideLoads, v);
  2727. } //letting them slide again
  2728. setState({
  2729. slideMoving: false
  2730. });
  2731. }
  2732. /**
  2733. * Slides silently (with no animation) the active slider to the given slide.
  2734. * @param noCallback {bool} true or defined -> no callbacks
  2735. */
  2736. function silentLandscapeScroll(activeSlide, noCallbacks) {
  2737. setScrollingSpeed(0, 'internal');
  2738. if (typeof noCallbacks !== 'undefined') {
  2739. //preventing firing callbacks afterSlideLoad etc.
  2740. setState({
  2741. isResizing: true
  2742. });
  2743. }
  2744. landscapeScroll(closest(activeSlide, SLIDES_WRAPPER_SEL), activeSlide);
  2745. if (typeof noCallbacks !== 'undefined') {
  2746. setState({
  2747. isResizing: false
  2748. });
  2749. }
  2750. setScrollingSpeed(getOriginals().scrollingSpeed, 'internal');
  2751. }
  2752. var g_prevActiveSectionIndex = null;
  2753. var g_prevActiveSlideIndex = null;
  2754. /**
  2755. * Updates the state of the app.
  2756. */
  2757. function updateState() {
  2758. state.activeSection = null;
  2759. state.sections.map(function (section) {
  2760. var isActive = hasClass(section.item, ACTIVE);
  2761. section.isActive = isActive;
  2762. section.hasScroll = scrollOverflowHandler.hasScroll(section.item);
  2763. if (isActive) {
  2764. state.activeSection = section;
  2765. }
  2766. if (section.slides.length) {
  2767. section.activeSlide = null;
  2768. section.slides.map(function (slide) {
  2769. var isActiveSlide = hasClass(slide.item, ACTIVE);
  2770. slide.hasScroll = scrollOverflowHandler.hasScroll(section.item);
  2771. slide.isActive = isActiveSlide;
  2772. if (isActiveSlide) {
  2773. section.activeSlide = slide;
  2774. }
  2775. });
  2776. }
  2777. });
  2778. scrollToNewActivePanel();
  2779. }
  2780. function updateStructuralState() {
  2781. var allSectionItems = $(getOptions().sectionSelector, getContainer());
  2782. var sectionsItems = getVisible(allSectionItems);
  2783. var allSections = Array.from(allSectionItems).map(function (item) {
  2784. return new SectionPanel(item);
  2785. });
  2786. var sections = allSections.filter(function (item) {
  2787. return item.isVisible;
  2788. });
  2789. var slides = sections.reduce(function (acc, section) {
  2790. return acc.concat(section.slides);
  2791. }, []); // keeping track of the previously active section
  2792. g_prevActiveSectionIndex = getPrevActivePanelIndex(state.activeSection);
  2793. g_prevActiveSlideIndex = getPrevActivePanelIndex(state.activeSection ? state.activeSection.activeSlide : null);
  2794. state.numSections = sectionsItems.length;
  2795. state.numSlides = sections.reduce(function (acc, section) {
  2796. return acc + section.slides.length;
  2797. }, 0);
  2798. state.sections = sections;
  2799. state.sectionsIncludingHidden = allSections;
  2800. state.slides = slides;
  2801. state.panels = state.sections.concat(state.slides);
  2802. }
  2803. function getPrevActivePanelIndex(activePanel) {
  2804. if (!activePanel) {
  2805. return null;
  2806. }
  2807. var prevActivePanelItem = activePanel ? activePanel.item : null;
  2808. var hiddenPanels = activePanel.isSection ? state.sectionsIncludingHidden : state.activeSection.slidesIncludingHidden;
  2809. if (prevActivePanelItem) {
  2810. var panel = getPanelByElement(hiddenPanels, prevActivePanelItem);
  2811. return panel ? panel.index() : null;
  2812. }
  2813. return null;
  2814. }
  2815. /**
  2816. * When changes in the DOM take place there's a change
  2817. * the active section is now hidden or removed.
  2818. * fullPage.js will scroll to the closest section nearby.
  2819. */
  2820. function scrollToNewActivePanel() {
  2821. var activeSection = state.activeSection;
  2822. var activeSectionHasSlides = state.activeSection ? state.activeSection.slides.length : false;
  2823. var activeSlide = state.activeSection ? state.activeSection.activeSlide : null; // Hidding / removing the active section ?
  2824. if (!activeSection && state.sections.length && !getState().isBeyondFullpage && g_prevActiveSectionIndex) {
  2825. var newActiveSection = getNewActivePanel(g_prevActiveSectionIndex, state.sections);
  2826. if (newActiveSection) {
  2827. state.activeSection = newActiveSection;
  2828. state.activeSection.isActive = true;
  2829. addClass(state.activeSection.item, ACTIVE);
  2830. }
  2831. if (state.activeSection) {
  2832. silentScroll(state.activeSection.item.offsetTop);
  2833. }
  2834. }
  2835. if (activeSectionHasSlides && !activeSlide && g_prevActiveSlideIndex) {
  2836. var newActiveSlide = getNewActivePanel(g_prevActiveSlideIndex, state.activeSection.slides);
  2837. if (newActiveSlide) {
  2838. state.activeSection.activeSlide = newActiveSlide;
  2839. state.activeSection.activeSlide.isActive = true;
  2840. addClass(state.activeSection.activeSlide.item, ACTIVE);
  2841. }
  2842. if (state.activeSection.activeSlide) {
  2843. silentLandscapeScroll(state.activeSection.activeSlide.item, 'internal');
  2844. }
  2845. }
  2846. }
  2847. function getNewActivePanel(prevActivePanelIndex, siblings) {
  2848. var newActiveSection;
  2849. var prevIndex = prevActivePanelIndex - 1;
  2850. var nextIndex = prevActivePanelIndex;
  2851. do {
  2852. newActiveSection = siblings[prevIndex] || siblings[nextIndex];
  2853. if (newActiveSection) {
  2854. break;
  2855. }
  2856. prevIndex = prevIndex - 1;
  2857. nextIndex = nextIndex + 1;
  2858. } while (prevIndex >= 0 || nextIndex < siblings.length);
  2859. return newActiveSection;
  2860. }
  2861. /**
  2862. * Section object
  2863. */
  2864. var SectionPanel = function SectionPanel(el) {
  2865. var _this = this;
  2866. [].push.call(arguments, getOptions().sectionSelector);
  2867. Item.apply(this, arguments);
  2868. this.allSlidesItems = $(getOptions().slideSelector, el);
  2869. this.slidesIncludingHidden = Array.from(this.allSlidesItems).map(function (item) {
  2870. return new SlidePanel(item, _this);
  2871. });
  2872. this.slides = this.slidesIncludingHidden.filter(function (slidePanel) {
  2873. return slidePanel.isVisible;
  2874. });
  2875. this.activeSlide = this.slides.length ? this.slides.filter(function (slide) {
  2876. return slide.isActive;
  2877. })[0] || this.slides[0] : null;
  2878. };
  2879. SectionPanel.prototype = Item.prototype;
  2880. SectionPanel.prototype.constructor = SectionPanel;
  2881. /**
  2882. * Slide object
  2883. */
  2884. var SlidePanel = function SlidePanel(el, section) {
  2885. this.parent = section;
  2886. Item.call(this, el, getOptions().slideSelector);
  2887. };
  2888. SlidePanel.prototype = Item.prototype;
  2889. SlidePanel.prototype.constructor = SectionPanel;
  2890. /**
  2891. * Adds internal classes to be able to provide customizable selectors
  2892. * keeping the link with the style sheet.
  2893. */
  2894. function addInternalSelectors() {
  2895. addClass($(getOptions().sectionSelector, getContainer()), SECTION);
  2896. addClass($(getOptions().slideSelector, getContainer()), SLIDE);
  2897. }
  2898. /**
  2899. * Styles the horizontal slides for a section.
  2900. */
  2901. function styleSlides(section) {
  2902. var numSlides = section.slides.length;
  2903. var slidesElems = section.allSlidesItems;
  2904. var slides = section.slides;
  2905. var sliderWidth = numSlides * 100;
  2906. var slideWidth = 100 / numSlides;
  2907. if (!$(SLIDES_WRAPPER_SEL, section.item)[0]) {
  2908. var slidesWrapper = doc.createElement('div');
  2909. slidesWrapper.className = SLIDES_WRAPPER; //fp-slides
  2910. wrapAll(slidesElems, slidesWrapper);
  2911. var slidesContainer = doc.createElement('div');
  2912. slidesContainer.className = SLIDES_CONTAINER; //fp-slidesContainer
  2913. wrapAll(slidesElems, slidesContainer);
  2914. }
  2915. css($(SLIDES_CONTAINER_SEL, section.item), {
  2916. 'width': sliderWidth + '%'
  2917. });
  2918. if (numSlides > 1) {
  2919. if (getOptions().controlArrows) {
  2920. createSlideArrows(section);
  2921. }
  2922. if (getOptions().slidesNavigation) {
  2923. addSlidesNavigation(section);
  2924. }
  2925. }
  2926. slides.forEach(function (slide) {
  2927. css(slide.item, {
  2928. 'width': slideWidth + '%'
  2929. });
  2930. if (getOptions().verticalCentered) {
  2931. addTableClass(slide);
  2932. }
  2933. });
  2934. var startingSlide = section.activeSlide || null; //if the slide won't be an starting point, the default will be the first one
  2935. //the active section isn't the first one? Is not the first slide of the first section? Then we load that section/slide by default.
  2936. if (startingSlide != null && state.activeSection && (state.activeSection.index() !== 0 || state.activeSection.index() === 0 && startingSlide.index() !== 0)) {
  2937. silentLandscapeScroll(startingSlide.item, 'internal');
  2938. } else {
  2939. addClass(slidesElems[0], ACTIVE);
  2940. }
  2941. }
  2942. var g_wrapperObserver;
  2943. var g_wrapperObserveConfig = {
  2944. attributes: false,
  2945. subtree: true,
  2946. childList: true,
  2947. characterData: true
  2948. };
  2949. EventEmitter.on(events.bindEvents, bindEvents$9);
  2950. FP["render"] = onContentChange;
  2951. function bindEvents$9() {
  2952. if (getOptions().observer && "MutationObserver" in window && $(WRAPPER_SEL)[0]) {
  2953. g_wrapperObserver = createObserver($(WRAPPER_SEL)[0], onContentChange, g_wrapperObserveConfig);
  2954. }
  2955. EventEmitter.on(events.contentChanged, onContentChange);
  2956. }
  2957. /**
  2958. * Creates a Mutation observer.
  2959. */
  2960. function createObserver(target, callback, config) {
  2961. var observer = new MutationObserver(callback);
  2962. observer.observe(target, config);
  2963. return observer;
  2964. }
  2965. function didSlidesChange() {
  2966. return getVisible($(getOptions().slideSelector, getContainer())).length !== getState().numSlides;
  2967. }
  2968. function didSectionsChange() {
  2969. return getVisible($(getOptions().sectionSelector, getContainer())).length !== getState().numSections;
  2970. }
  2971. function didSectionsOrSlidesChange() {
  2972. return didSlidesChange() || didSectionsChange();
  2973. }
  2974. /**
  2975. * Listen to changes on sections and fires reBuild
  2976. * when those changes affect the section height.
  2977. */
  2978. function onContentChange(mutations) {
  2979. var _didSlidesChange = didSlidesChange();
  2980. if (didSectionsOrSlidesChange() && !state.isDoingContinousVertical) {
  2981. if (getOptions().observer && g_wrapperObserver) {
  2982. // Temporally disabling the observer while
  2983. // we modidy the DOM again
  2984. g_wrapperObserver.disconnect();
  2985. }
  2986. updateStructuralState();
  2987. updateState(); // Removing navs and anchors options
  2988. getOptions().anchors = [];
  2989. remove($(SECTION_NAV_SEL));
  2990. addInternalSelectors();
  2991. setOptionsFromDOM();
  2992. if (getOptions().navigation) {
  2993. addVerticalNavigation();
  2994. }
  2995. if (_didSlidesChange) {
  2996. remove($(SLIDES_NAV_SEL));
  2997. remove($(SLIDES_ARROW_SEL));
  2998. }
  2999. getState().sections.forEach(function (section) {
  3000. if (section.slides.length) {
  3001. if (_didSlidesChange) {
  3002. styleSlides(section);
  3003. }
  3004. } else {
  3005. styleSection(section);
  3006. }
  3007. });
  3008. }
  3009. if (getOptions().observer && g_wrapperObserver && $(WRAPPER_SEL)[0]) {
  3010. g_wrapperObserver.observe($(WRAPPER_SEL)[0], g_wrapperObserveConfig);
  3011. }
  3012. }
  3013. var supportsPassiveEvents = function () {
  3014. //cheks for passive event support
  3015. var g_supportsPassive = false;
  3016. try {
  3017. var opts = Object.defineProperty({}, 'passive', {
  3018. get: function get() {
  3019. g_supportsPassive = true;
  3020. }
  3021. });
  3022. windowAddEvent("testPassive", null, opts);
  3023. windowRemoveEvent("testPassive", null, opts);
  3024. } catch (e) {}
  3025. return function () {
  3026. return g_supportsPassive;
  3027. };
  3028. }();
  3029. function getPassiveOptionsIfPossible() {
  3030. return supportsPassiveEvents() ? {
  3031. passive: false
  3032. } : false;
  3033. }
  3034. var wheelDataHandler = function () {
  3035. var _prevTime = new Date().getTime();
  3036. var _scrollings = [];
  3037. var isScrollingVertically;
  3038. var direction;
  3039. return {
  3040. registerEvent: function registerEvent(e) {
  3041. e = e || win.event;
  3042. var value = e.wheelDelta || -e.deltaY || -e.detail;
  3043. var delta = Math.max(-1, Math.min(1, value));
  3044. var horizontalDetection = typeof e.wheelDeltaX !== 'undefined' || typeof e.deltaX !== 'undefined';
  3045. isScrollingVertically = Math.abs(e.wheelDeltaX) < Math.abs(e.wheelDelta) || Math.abs(e.deltaX) < Math.abs(e.deltaY) || !horizontalDetection;
  3046. var curTime = new Date().getTime();
  3047. direction = delta < 0 ? 'down' : 'up'; //Limiting the array to 150 (lets not waste memory!)
  3048. if (_scrollings.length > 149) {
  3049. _scrollings.shift();
  3050. } //keeping record of the previous scrollings
  3051. _scrollings.push(Math.abs(value)); //time difference between the last scroll and the current one
  3052. var timeDiff = curTime - _prevTime;
  3053. _prevTime = curTime; //haven't they scrolled in a while?
  3054. //(enough to be consider a different scrolling action to scroll another section)
  3055. if (timeDiff > 200) {
  3056. //emptying the array, we dont care about old scrollings for our averages
  3057. _scrollings = [];
  3058. }
  3059. },
  3060. isAccelerating: function isAccelerating() {
  3061. var averageEnd = getAverage(_scrollings, 10);
  3062. var averageMiddle = getAverage(_scrollings, 70);
  3063. var isAccelerating = averageEnd >= averageMiddle;
  3064. return _scrollings.length ? isAccelerating && isScrollingVertically : false;
  3065. },
  3066. getDirection: function getDirection() {
  3067. return direction;
  3068. }
  3069. };
  3070. }();
  3071. function scrollBeyondFullPage() {
  3072. var dtop = getDestinationOffset();
  3073. var scrollSettings = getScrollSettings(dtop);
  3074. FP.test.top = -dtop + 'px';
  3075. setState({
  3076. canScroll: false
  3077. });
  3078. scrollTo(scrollSettings.element, scrollSettings.options, getOptions().scrollingSpeed, function () {
  3079. setTimeout(function () {
  3080. setState({
  3081. isBeyondFullpage: true
  3082. });
  3083. setState({
  3084. canScroll: true
  3085. });
  3086. }, 30);
  3087. });
  3088. }
  3089. function onKeyDown() {
  3090. if (!isFullPageAbove()) {
  3091. return;
  3092. } else {
  3093. scrollUpToFullpage();
  3094. }
  3095. }
  3096. function scrollUpToFullpage() {
  3097. var scrollSettings = getScrollSettings(getLast(getState().sections).item.offsetTop);
  3098. setState({
  3099. canScroll: false
  3100. });
  3101. scrollTo(scrollSettings.element, scrollSettings.options, getOptions().scrollingSpeed, function () {
  3102. setState({
  3103. canScroll: true
  3104. });
  3105. setState({
  3106. isBeyondFullpage: false
  3107. });
  3108. setState({
  3109. isAboutToScrollToFullPage: false
  3110. });
  3111. });
  3112. }
  3113. function getDestinationOffset() {
  3114. if (!getOptions().css3) {
  3115. return getLast(getState().sections).item.offsetTop + getLast(getState().sections).item.offsetHeight;
  3116. }
  3117. return getScrollTop() + getWindowHeight();
  3118. }
  3119. function beyondFullPageHandler(container, e) {
  3120. new Date().getTime();
  3121. var pauseScroll = getState().isBeyondFullpage && container.getBoundingClientRect().bottom >= 0 && wheelDataHandler.getDirection() === 'up';
  3122. var g_isAboutToScrollToFullPage = getState().isAboutToScrollToFullPage;
  3123. if (g_isAboutToScrollToFullPage) {
  3124. preventDefault(e);
  3125. return false;
  3126. }
  3127. if (getState().isBeyondFullpage) {
  3128. if (!pauseScroll) {
  3129. keyframeTime('set', 'beyondFullpage', 1000);
  3130. } else {
  3131. var shouldSetFixedPosition = !g_isAboutToScrollToFullPage && (!keyframeTime('isNewKeyframe', 'beyondFullpage') || !wheelDataHandler.isAccelerating());
  3132. var scrollSettings;
  3133. if (shouldSetFixedPosition) {
  3134. scrollSettings = getScrollSettings(getLast(getState().sections).item.offsetTop + getLast(getState().sections).item.offsetHeight);
  3135. scrollSettings.element.scrollTo(0, scrollSettings.options);
  3136. setState({
  3137. isAboutToScrollToFullPage: false
  3138. });
  3139. preventDefault(e);
  3140. return false;
  3141. } else if (wheelDataHandler.isAccelerating()) {
  3142. pauseScroll = false;
  3143. setState({
  3144. isAboutToScrollToFullPage: true
  3145. });
  3146. setState({
  3147. scrollTrigger: 'wheel'
  3148. });
  3149. scrollUpToFullpage();
  3150. preventDefault(e);
  3151. return false;
  3152. }
  3153. }
  3154. if (!g_isAboutToScrollToFullPage) {
  3155. // allow normal scrolling, but quitting
  3156. if (!pauseScroll) {
  3157. return true;
  3158. }
  3159. }
  3160. }
  3161. }
  3162. var keyframeTime = function () {
  3163. var isNew = false;
  3164. var frames = {};
  3165. var timeframes = {};
  3166. return function (action, name, timeframe) {
  3167. switch (action) {
  3168. case 'set':
  3169. frames[name] = new Date().getTime();
  3170. timeframes[name] = timeframe;
  3171. break;
  3172. case 'isNewKeyframe':
  3173. var current = new Date().getTime();
  3174. isNew = current - frames[name] > timeframes[name];
  3175. break;
  3176. }
  3177. return isNew;
  3178. };
  3179. }();
  3180. FP.moveSectionDown = moveSectionDown;
  3181. /**
  3182. * Moves the page down one section.
  3183. */
  3184. function moveSectionDown() {
  3185. var next = getState().activeSection.next(); //looping to the top if there's no more sections below
  3186. if (!next && (getOptions().loopBottom || getOptions().continuousVertical)) {
  3187. next = getState().sections[0];
  3188. }
  3189. if (next != null) {
  3190. scrollPage(next, null, false);
  3191. } else if (hasContentBeyondFullPage()) {
  3192. EventEmitter.emit(events.scrollBeyondFullpage);
  3193. }
  3194. }
  3195. function hasContentBeyondFullPage() {
  3196. return getContainer().scrollHeight < $body.scrollHeight && getOptions().scrollBar && getOptions().scrollBeyondFullpage;
  3197. }
  3198. FP.moveSectionUp = moveSectionUp;
  3199. /**
  3200. * Moves the page up one section.
  3201. */
  3202. function moveSectionUp() {
  3203. var prev = getState().activeSection.prev(); //looping to the bottom if there's no more sections above
  3204. if (!prev && (getOptions().loopTop || getOptions().continuousVertical)) {
  3205. prev = getLast(getState().sections);
  3206. }
  3207. if (prev != null) {
  3208. scrollPage(prev, null, true);
  3209. }
  3210. }
  3211. var oldPageY = 0;
  3212. /**
  3213. * Detecting the direction of the mouse movement.
  3214. * Used only for the middle button of the mouse.
  3215. */
  3216. function mouseMoveHandler(e) {
  3217. if (!getOptions().autoScrolling) {
  3218. return;
  3219. }
  3220. if (state.canScroll) {
  3221. // moving up
  3222. if (e.pageY < oldPageY && getIsScrollAllowed().m.up) {
  3223. moveSectionUp();
  3224. } // moving down
  3225. else if (e.pageY > oldPageY && getIsScrollAllowed().m.down) {
  3226. moveSectionDown();
  3227. }
  3228. }
  3229. oldPageY = e.pageY;
  3230. }
  3231. function setOldPageY(value) {
  3232. oldPageY = value;
  3233. }
  3234. /**
  3235. * Determines the way of scrolling up or down:
  3236. * by 'automatically' scrolling a section or by using the default and normal scrolling.
  3237. */
  3238. function scrolling(type) {
  3239. if (!getIsScrollAllowed().m[type]) {
  3240. return;
  3241. }
  3242. var scrollSection = type === 'down' ? moveSectionDown : moveSectionUp;
  3243. if (getOptions().scrollOverflow && scrollOverflowHandler.isScrollable(getState().activeSection)) {
  3244. //is the scrollbar at the start/end of the scroll?
  3245. if (scrollOverflowHandler.isScrolled(type, getState().activeSection.item) && scrollOverflowHandler.shouldMovePage()) {
  3246. scrollSection();
  3247. }
  3248. } else {
  3249. scrollSection();
  3250. }
  3251. }
  3252. var touchStartY = 0;
  3253. var touchStartX = 0;
  3254. var touchEndY = 0;
  3255. var touchEndX = 0;
  3256. var MSPointer = getMSPointer();
  3257. var pointers = {
  3258. touchmove: 'ontouchmove' in window ? 'touchmove' : MSPointer ? MSPointer.move : null,
  3259. touchstart: 'ontouchstart' in window ? 'touchstart' : MSPointer ? MSPointer.down : null
  3260. };
  3261. /**
  3262. * Adds the possibility to auto scroll through sections on touch devices.
  3263. */
  3264. function addTouchHandler() {
  3265. if (!pointers.touchmove) {
  3266. return;
  3267. }
  3268. if (isTouchDevice || isTouch) {
  3269. if (getOptions().autoScrolling) {
  3270. $body.removeEventListener(pointers.touchmove, preventBouncing, {
  3271. passive: false
  3272. });
  3273. $body.addEventListener(pointers.touchmove, preventBouncing, {
  3274. passive: false
  3275. });
  3276. }
  3277. var touchWrapper = getOptions().touchWrapper;
  3278. touchWrapper.removeEventListener(pointers.touchstart, touchStartHandler);
  3279. touchWrapper.removeEventListener(pointers.touchmove, touchMoveHandler, {
  3280. passive: false
  3281. });
  3282. touchWrapper.addEventListener(pointers.touchstart, touchStartHandler);
  3283. touchWrapper.addEventListener(pointers.touchmove, touchMoveHandler, {
  3284. passive: false
  3285. });
  3286. }
  3287. }
  3288. /**
  3289. * Removes the auto scrolling for touch devices.
  3290. */
  3291. function removeTouchHandler() {
  3292. if (!pointers.touchmove) {
  3293. return;
  3294. }
  3295. if (isTouchDevice || isTouch) {
  3296. // normalScrollElements requires it off #2691
  3297. if (getOptions().autoScrolling) {
  3298. $body.removeEventListener(pointers.touchmove, touchMoveHandler, {
  3299. passive: false
  3300. });
  3301. $body.removeEventListener(pointers.touchmove, preventBouncing, {
  3302. passive: false
  3303. });
  3304. }
  3305. var touchWrapper = getOptions().touchWrapper;
  3306. touchWrapper.removeEventListener(pointers.touchstart, touchStartHandler);
  3307. touchWrapper.removeEventListener(pointers.touchmove, touchMoveHandler, {
  3308. passive: false
  3309. });
  3310. }
  3311. }
  3312. /* Detecting touch events
  3313. * As we are changing the top property of the page on scrolling, we can not use the traditional way to detect it.
  3314. * This way, the touchstart and the touch moves shows an small difference between them which is the
  3315. * used one to determine the direction.
  3316. */
  3317. function touchMoveHandler(e) {
  3318. var activeSection = closest(e.target, SECTION_SEL) || getState().activeSection.item;
  3319. var hasActiveSectionOverflow = scrollOverflowHandler.isScrollable(getState().activeSection);
  3320. if (isReallyTouch(e)) {
  3321. setState({
  3322. isGrabbing: true,
  3323. isUsingWheel: false
  3324. });
  3325. if (getOptions().autoScrolling) {
  3326. if (hasActiveSectionOverflow && !state.canScroll || getOptions().scrollBar) {
  3327. //preventing the easing on iOS devices
  3328. preventDefault(e);
  3329. }
  3330. }
  3331. var touchEvents = getEventsPage(e);
  3332. touchEndY = touchEvents.y;
  3333. touchEndX = touchEvents.x;
  3334. var isVerticalMovementEnough = Math.abs(touchStartY - touchEndY) > win.innerHeight / 100 * getOptions().touchSensitivity;
  3335. var isHorizontalMovementEnough = Math.abs(touchStartX - touchEndX) > getWindowWidth() / 100 * getOptions().touchSensitivity;
  3336. var isHorizontalPredominantMove = $(SLIDES_WRAPPER_SEL, activeSection).length && Math.abs(touchStartX - touchEndX) > Math.abs(touchStartY - touchEndY);
  3337. var directionH = touchStartX > touchEndX ? 'right' : 'left';
  3338. var directionV = touchStartY > touchEndY ? 'down' : 'up';
  3339. var direction = isHorizontalPredominantMove ? directionH : directionV;
  3340. setState({
  3341. touchDirection: direction
  3342. }); //if movement in the X axys is greater than in the Y and the currect section has slides...
  3343. if (isHorizontalPredominantMove) {
  3344. //is the movement greater than the minimum resistance to scroll?
  3345. if (!state.slideMoving && isHorizontalMovementEnough) {
  3346. if (touchStartX > touchEndX) {
  3347. if (getIsScrollAllowed().m.right) {
  3348. EventEmitter.emit(events.moveSlideRight, {
  3349. section: activeSection
  3350. });
  3351. }
  3352. } else {
  3353. if (getIsScrollAllowed().m.left) {
  3354. EventEmitter.emit(events.moveSlideLeft, {
  3355. section: activeSection
  3356. });
  3357. }
  3358. }
  3359. }
  3360. } //vertical scrolling (only when autoScrolling is enabled)
  3361. else if (getOptions().autoScrolling && state.canScroll) {
  3362. //is the movement greater than the minimum resistance to scroll?
  3363. if (isVerticalMovementEnough) {
  3364. scrolling(directionV);
  3365. }
  3366. }
  3367. }
  3368. }
  3369. /**
  3370. * As IE >= 10 fires both touch and mouse events when using a mouse in a touchscreen
  3371. * this way we make sure that is really a touch event what IE is detecting.
  3372. */
  3373. function isReallyTouch(e) {
  3374. //if is not IE || IE is detecting `touch` or `pen`
  3375. return typeof e.pointerType === 'undefined' || e.pointerType != 'mouse';
  3376. }
  3377. /**
  3378. * Handler for the touch start event.
  3379. */
  3380. function touchStartHandler(e) {
  3381. //stopping the auto scroll to adjust to a section
  3382. if (getOptions().fitToSection) {
  3383. setState({
  3384. activeAnimation: false
  3385. });
  3386. }
  3387. if (isReallyTouch(e)) {
  3388. var touchEvents = getEventsPage(e);
  3389. touchStartY = touchEvents.y;
  3390. touchStartX = touchEvents.x;
  3391. }
  3392. windowAddEvent('touchend', touchEndHandler);
  3393. }
  3394. /**
  3395. * Handler for the touch end event.
  3396. */
  3397. function touchEndHandler() {
  3398. windowRemoveEvent('touchend', touchEndHandler);
  3399. setState({
  3400. isGrabbing: false
  3401. });
  3402. }
  3403. /**
  3404. * Gets the pageX and pageY properties depending on the browser.
  3405. * https://github.com/alvarotrigo/fullPage.js/issues/194#issuecomment-34069854
  3406. */
  3407. function getEventsPage(e) {
  3408. var events = {};
  3409. events.y = typeof e.pageY !== 'undefined' && (e.pageY || e.pageX) ? e.pageY : e.touches[0].pageY;
  3410. events.x = typeof e.pageX !== 'undefined' && (e.pageY || e.pageX) ? e.pageX : e.touches[0].pageX; //in touch devices with scrollBar:true, e.pageY is detected, but we have to deal with touch events. #1008
  3411. if (isTouch && isReallyTouch(e) && getOptions().scrollBar && typeof e.touches !== 'undefined') {
  3412. events.y = e.touches[0].pageY;
  3413. events.x = e.touches[0].pageX;
  3414. }
  3415. return events;
  3416. }
  3417. /*
  3418. * Returns and object with Microsoft pointers (for IE<11 and for IE >= 11)
  3419. * http://msdn.microsoft.com/en-us/library/ie/dn304886(v=vs.85).aspx
  3420. */
  3421. function getMSPointer() {
  3422. var pointer; //IE >= 11 & rest of browsers
  3423. if (win.PointerEvent) {
  3424. pointer = {
  3425. down: 'pointerdown',
  3426. move: 'pointermove'
  3427. };
  3428. }
  3429. return pointer;
  3430. }
  3431. /*
  3432. * Preventing bouncing in iOS #2285
  3433. */
  3434. function preventBouncing(e) {
  3435. if (getOptions().autoScrolling && isReallyTouch(e) && getIsScrollAllowed().m.up) {
  3436. //preventing the easing on iOS devices
  3437. if (!state.canScroll) {
  3438. preventDefault(e);
  3439. }
  3440. }
  3441. }
  3442. FP.moveSlideLeft = moveSlideLeft;
  3443. FP.moveSlideRight = moveSlideRight;
  3444. /**
  3445. * Slides a slider to the given direction.
  3446. * Optional `section` param.
  3447. */
  3448. function moveSlide(direction, section) {
  3449. var activeSectionItem = section == null ? getState().activeSection.item : section;
  3450. var activeSection = getPanelByElement(state.sections, activeSectionItem);
  3451. var slides = $(SLIDES_WRAPPER_SEL, activeSectionItem)[0]; // more than one slide needed and nothing should be sliding
  3452. if (slides == null || state.slideMoving || activeSection.slides.length < 2) {
  3453. return;
  3454. }
  3455. var currentSlide = activeSection.activeSlide;
  3456. var destiny = direction === 'left' ? currentSlide.prev() : currentSlide.next(); //isn't there a next slide in the secuence?
  3457. if (!destiny) {
  3458. //respect loopHorizontal setting
  3459. if (!getOptions().loopHorizontal) return;
  3460. destiny = direction === 'left' ? getLast(activeSection.slides) : activeSection.slides[0];
  3461. }
  3462. setState({
  3463. slideMoving: !FP.test.isTesting
  3464. });
  3465. landscapeScroll(slides, destiny.item, direction);
  3466. }
  3467. /**
  3468. * Slides left the slider of the active section.
  3469. * Optional `section` param.
  3470. */
  3471. function moveSlideLeft(section) {
  3472. moveSlide('left', section);
  3473. }
  3474. /**
  3475. * Slides right the slider of the active section.
  3476. * Optional `section` param.
  3477. */
  3478. function moveSlideRight(section) {
  3479. moveSlide('right', section);
  3480. }
  3481. /**
  3482. * Gets a section by its anchor / index
  3483. */
  3484. function getSectionByAnchor(sectionAnchor) {
  3485. var section = getState().sections.filter(function (section) {
  3486. return section.anchor === sectionAnchor;
  3487. })[0];
  3488. if (!section) {
  3489. var sectionIndex = typeof sectionAnchor !== 'undefined' ? sectionAnchor - 1 : 0;
  3490. section = getState().sections[sectionIndex];
  3491. }
  3492. return section;
  3493. }
  3494. /**
  3495. * Scrolls the slider to the given slide destination for the given section
  3496. */
  3497. function scrollSlider(slideElem) {
  3498. if (slideElem != null) {
  3499. landscapeScroll(closest(slideElem, SLIDES_WRAPPER_SEL), slideElem);
  3500. }
  3501. }
  3502. /**
  3503. * Scrolls to the given section and slide anchors
  3504. */
  3505. function scrollPageAndSlide(sectionAnchor, slideAnchor) {
  3506. var section = getSectionByAnchor(sectionAnchor); //do nothing if there's no section with the given anchor name
  3507. if (section == null) return;
  3508. var slideElem = getSlideByAnchor(slideAnchor, section); //we need to scroll to the section and then to the slide
  3509. if ((!section.anchor || section.anchor !== state.lastScrolledDestiny) && !hasClass(section.item, ACTIVE)) {
  3510. scrollPage(section, function () {
  3511. scrollSlider(slideElem);
  3512. });
  3513. } //if we were already in the section
  3514. else {
  3515. scrollSlider(slideElem);
  3516. }
  3517. }
  3518. /**
  3519. * Gets a slide inside a given section by its anchor / index
  3520. */
  3521. function getSlideByAnchor(slideAnchor, section) {
  3522. var slide = section.slides.filter(function (slide) {
  3523. return slide.anchor === slideAnchor;
  3524. })[0];
  3525. if (slide == null) {
  3526. slideAnchor = typeof slideAnchor !== 'undefined' ? slideAnchor : 0;
  3527. slide = section.slides[slideAnchor];
  3528. }
  3529. return slide ? slide.item : null;
  3530. }
  3531. FP.moveTo = moveTo$1;
  3532. /**
  3533. * Moves the page to the given section and slide.
  3534. * Anchors or index positions can be used as params.
  3535. */
  3536. function moveTo$1(sectionAnchor, slideAnchor) {
  3537. var destiny = getSectionByAnchor(sectionAnchor);
  3538. if (typeof slideAnchor !== 'undefined') {
  3539. scrollPageAndSlide(sectionAnchor, slideAnchor);
  3540. } else if (destiny != null) {
  3541. scrollPage(destiny);
  3542. }
  3543. }
  3544. //@ts-check
  3545. var g_controlPressed;
  3546. var g_keydownId;
  3547. var g_elToFocus;
  3548. EventEmitter.on(events.bindEvents, bindEvents$8);
  3549. function bindEvents$8() {
  3550. //when opening a new tab (ctrl + t), `control` won't be pressed when coming back.
  3551. windowAddEvent('blur', blurHandler); //Sliding with arrow keys, both, vertical and horizontal
  3552. docAddEvent('keydown', keydownHandler); //to prevent scrolling while zooming
  3553. docAddEvent('keyup', keyUpHandler);
  3554. EventEmitter.on(events.onDestroy, onDestroy$5);
  3555. EventEmitter.on(events.afterSlideLoads, onAfterSlideLoads);
  3556. EventEmitter.on(events.afterSectionLoads, afterSectionLoads);
  3557. }
  3558. function onDestroy$5() {
  3559. clearTimeout(g_keydownId);
  3560. docRemoveEvent('keydown', keydownHandler);
  3561. docRemoveEvent('keyup', keyUpHandler);
  3562. } //Sliding with arrow keys, both, vertical and horizontal
  3563. function keydownHandler(e) {
  3564. clearTimeout(g_keydownId);
  3565. var keyCode = e.keyCode;
  3566. var isPressingHorizontalArrows = [37, 39].indexOf(keyCode) > -1;
  3567. var canScrollWithKeyboard = getOptions().autoScrolling || getOptions().fitToSection || isPressingHorizontalArrows; //tab?
  3568. if (keyCode === 9) {
  3569. onTab(e);
  3570. } else if (!isInsideInput() && getOptions().keyboardScrolling && canScrollWithKeyboard) {
  3571. g_controlPressed = e.ctrlKey;
  3572. g_keydownId = setTimeout(function () {
  3573. onkeydown(e);
  3574. }, 0);
  3575. }
  3576. }
  3577. /**
  3578. * Keydown event
  3579. */
  3580. function onkeydown(e) {
  3581. var shiftPressed = e.shiftKey;
  3582. var activeElement = doc.activeElement;
  3583. var isMediaFocused = matches(activeElement, 'video') || matches(activeElement, 'audio');
  3584. var isScrolled = {
  3585. up: scrollOverflowHandler.isScrolled('up', getState().activeSection.item),
  3586. down: scrollOverflowHandler.isScrolled('down', getState().activeSection.item)
  3587. };
  3588. var isUsingHorizontalArrowKeys = [37, 39].indexOf(e.keyCode) > -1;
  3589. cancelDirectionKeyEvents(e); //do nothing if we can not scroll or we are not using horizotnal key arrows.
  3590. if (!state.canScroll && !isUsingHorizontalArrowKeys) {
  3591. return;
  3592. }
  3593. setState({
  3594. scrollTrigger: 'keydown'
  3595. });
  3596. switch (e.keyCode) {
  3597. //up
  3598. case 38:
  3599. case 33:
  3600. if (getIsScrollAllowed().k.up && isScrolled.up) {
  3601. if (state.isBeyondFullpage) {
  3602. EventEmitter.emit(events.onKeyDown, {
  3603. e: e
  3604. });
  3605. } else {
  3606. moveSectionUp();
  3607. }
  3608. } else {
  3609. scrollOverflowHandler.focusScrollable();
  3610. }
  3611. break;
  3612. //down
  3613. case 32:
  3614. //spacebar
  3615. if (shiftPressed && getIsScrollAllowed().k.up && !isMediaFocused && isScrolled.up) {
  3616. moveSectionUp();
  3617. break;
  3618. }
  3619. /* falls through */
  3620. case 40:
  3621. case 34:
  3622. if (getIsScrollAllowed().k.down && isScrolled.down) {
  3623. if (state.isBeyondFullpage) {
  3624. return;
  3625. } // space bar?
  3626. if (e.keyCode !== 32 || !isMediaFocused) {
  3627. moveSectionDown();
  3628. }
  3629. } else {
  3630. scrollOverflowHandler.focusScrollable();
  3631. }
  3632. break;
  3633. //Home
  3634. case 36:
  3635. if (getIsScrollAllowed().k.up) {
  3636. moveTo$1(1);
  3637. }
  3638. break;
  3639. //End
  3640. case 35:
  3641. if (getIsScrollAllowed().k.down) {
  3642. moveTo$1(getState().sections.length);
  3643. }
  3644. break;
  3645. //left
  3646. case 37:
  3647. if (getIsScrollAllowed().k.left) {
  3648. moveSlideLeft();
  3649. }
  3650. break;
  3651. //right
  3652. case 39:
  3653. if (getIsScrollAllowed().k.right) {
  3654. moveSlideRight();
  3655. }
  3656. break;
  3657. default:
  3658. return;
  3659. // exit this handler for other keys
  3660. }
  3661. } //to prevent scrolling while zooming
  3662. function keyUpHandler(e) {
  3663. if (state.isWindowFocused) {
  3664. //the keyup gets fired on new tab ctrl + t in Firefox
  3665. g_controlPressed = e.ctrlKey;
  3666. }
  3667. } //when opening a new tab (ctrl + t), `control` won't be pressed when coming back.
  3668. function blurHandler() {
  3669. setState({
  3670. isWindowFocused: false
  3671. });
  3672. g_controlPressed = false;
  3673. }
  3674. /**
  3675. * Makes sure the tab key will only focus elements within the current section/slide
  3676. * preventing this way from breaking the page.
  3677. * Based on "Modals and keyboard traps"
  3678. * from https://developers.google.com/web/fundamentals/accessibility/focus/using-tabindex
  3679. */
  3680. function onTab(e) {
  3681. var isShiftPressed = e.shiftKey;
  3682. var activeElement = doc.activeElement;
  3683. var focusableElements = getFocusables(getSlideOrSection(getState().activeSection.item));
  3684. function preventAndFocusFirst(e) {
  3685. preventDefault(e);
  3686. return focusableElements[0] ? focusableElements[0].focus() : null;
  3687. } // deactivating tab while scrolling #4550
  3688. if (!state.canScroll) {
  3689. preventDefault(e);
  3690. return;
  3691. } //outside any section or slide? Let's not hijack the tab!
  3692. if (isFocusOutside(e)) {
  3693. return;
  3694. } //is there an element with focus?
  3695. if (activeElement) {
  3696. if (closest(activeElement, SECTION_ACTIVE_SEL + ',' + SECTION_ACTIVE_SEL + ' ' + SLIDE_ACTIVE_SEL) == null) {
  3697. activeElement = preventAndFocusFirst(e);
  3698. }
  3699. } //no element if focused? Let's focus the first one of the section/slide
  3700. else {
  3701. preventAndFocusFirst(e);
  3702. } //when reached the first or last focusable element of the section/slide
  3703. //we prevent the tab action to keep it in the last focusable element
  3704. var isFirstFocusableInSection = activeElement == focusableElements[0];
  3705. var isLastFocusableInSection = activeElement == focusableElements[focusableElements.length - 1];
  3706. var isNextItem = !isShiftPressed && isLastFocusableInSection;
  3707. var isPrevItem = isShiftPressed && isFirstFocusableInSection;
  3708. if (isPrevItem || isNextItem) {
  3709. preventDefault(e);
  3710. var focusInfo = getPanelWithFocusable(isPrevItem);
  3711. var destinationPanel = focusInfo ? focusInfo.panel : null;
  3712. if (destinationPanel) {
  3713. var destinationSection = destinationPanel.isSection ? destinationPanel : destinationPanel.parent;
  3714. EventEmitter.emit(events.onScrollPageAndSlide, {
  3715. sectionAnchor: destinationSection.index() + 1,
  3716. slideAnchor: destinationPanel.isSection ? 0 : destinationPanel.index()
  3717. });
  3718. g_elToFocus = focusInfo.itemToFocus;
  3719. preventDefault(e);
  3720. }
  3721. }
  3722. }
  3723. function onAfterSlideLoads(v) {
  3724. focusItem();
  3725. }
  3726. function afterSectionLoads(v) {
  3727. if (!closest(g_elToFocus, SLIDE_SEL) || closest(g_elToFocus, SLIDE_ACTIVE_SEL)) {
  3728. focusItem();
  3729. }
  3730. }
  3731. function focusItem() {
  3732. if (g_elToFocus) {
  3733. g_elToFocus.focus();
  3734. g_elToFocus = null;
  3735. }
  3736. }
  3737. /**
  3738. * Get's the panel containing the element to focus.
  3739. *
  3740. */
  3741. function getPanelWithFocusable(isPrevItem) {
  3742. var action = isPrevItem ? 'prevPanel' : 'nextPanel';
  3743. var focusableElements = [];
  3744. var panelWithFocusables;
  3745. var currentPanel = getSlideOrSectionPanel(getActivePanel()[action]());
  3746. do {
  3747. focusableElements = getFocusables(currentPanel.item);
  3748. if (focusableElements.length) {
  3749. panelWithFocusables = {
  3750. panel: currentPanel,
  3751. itemToFocus: focusableElements[isPrevItem ? focusableElements.length - 1 : 0]
  3752. };
  3753. }
  3754. currentPanel = getSlideOrSectionPanel(currentPanel[action]());
  3755. } while (currentPanel && focusableElements.length === 0);
  3756. return panelWithFocusables;
  3757. }
  3758. /**
  3759. * Gets all the focusable elements inside the passed element.
  3760. */
  3761. function getFocusables(el) {
  3762. return [].slice.call($(focusableElementsString, el)).filter(function (item) {
  3763. return getAttr(item, 'tabindex') !== '-1' && //are also not hidden elements (or with hidden parents)
  3764. item.offsetParent !== null;
  3765. });
  3766. }
  3767. /**
  3768. * Determines whether the focus is outside fullpage.js sections/slides or not.
  3769. */
  3770. function isFocusOutside(e) {
  3771. var allFocusables = getFocusables(doc);
  3772. var currentFocusIndex = allFocusables.indexOf(doc.activeElement);
  3773. var focusDestinationIndex = e.shiftKey ? currentFocusIndex - 1 : currentFocusIndex + 1;
  3774. var focusDestination = allFocusables[focusDestinationIndex];
  3775. var destinationItemSlide = closest(focusDestination, SLIDE_SEL);
  3776. var destinationItemSection = closest(focusDestination, SECTION_SEL);
  3777. return !destinationItemSlide && !destinationItemSection;
  3778. }
  3779. function shouldCancelKeyboardNavigation(e) {
  3780. // https://keycode.info/for/34
  3781. // 40 = arrow down
  3782. // 38 = arrow up
  3783. // 32 = spacebar
  3784. // 33 = PageUp
  3785. // 34 = PageDown
  3786. var keyControls = [40, 38, 32, 33, 34];
  3787. return keyControls.indexOf(e.keyCode) > -1 && !state.isBeyondFullpage;
  3788. } //preventing the scroll with arrow keys & spacebar & Page Up & Down keys
  3789. function cancelDirectionKeyEvents(e) {
  3790. if (shouldCancelKeyboardNavigation(e) && !closest(e.target, OVERFLOW_SEL)) {
  3791. e.preventDefault();
  3792. }
  3793. }
  3794. function getControlPressed() {
  3795. return g_controlPressed;
  3796. }
  3797. var prevTime = new Date().getTime();
  3798. var scrollings = [];
  3799. FP.setMouseWheelScrolling = setMouseWheelScrolling;
  3800. /**
  3801. * Adds or remove the possibility of scrolling through sections by using the mouse wheel or the trackpad.
  3802. */
  3803. function setMouseWheelScrolling(value) {
  3804. if (value) {
  3805. addMouseWheelHandler();
  3806. addMiddleWheelHandler();
  3807. } else {
  3808. removeMouseWheelHandler();
  3809. removeMiddleWheelHandler();
  3810. }
  3811. }
  3812. /**
  3813. * Adds the auto scrolling action for the mouse wheel and trackpad.
  3814. * After this function is called, the mousewheel and trackpad movements will scroll through sections
  3815. * https://developer.mozilla.org/en-US/docs/Web/Events/wheel
  3816. */
  3817. function addMouseWheelHandler() {
  3818. var prefix = '';
  3819. var _addEventListener;
  3820. if (win.addEventListener) {
  3821. _addEventListener = "addEventListener";
  3822. } else {
  3823. _addEventListener = "attachEvent";
  3824. prefix = 'on';
  3825. } // detect available wheel event
  3826. var support = 'onwheel' in doc.createElement('div') ? 'wheel' : // Modern browsers support "wheel"
  3827. // @ts-ignore
  3828. doc.onmousewheel !== undefined ? 'mousewheel' : // Webkit and IE support at least "mousewheel"
  3829. 'DOMMouseScroll'; // let's assume that remaining browsers are older Firefox
  3830. var passiveEvent = getPassiveOptionsIfPossible();
  3831. if (support == 'DOMMouseScroll') {
  3832. doc[_addEventListener](prefix + 'MozMousePixelScroll', MouseWheelHandler, passiveEvent);
  3833. } //handle MozMousePixelScroll in older Firefox
  3834. else {
  3835. doc[_addEventListener](prefix + support, MouseWheelHandler, passiveEvent);
  3836. }
  3837. }
  3838. /**
  3839. * Binding the mousemove when the mouse's middle button is pressed
  3840. */
  3841. function addMiddleWheelHandler() {
  3842. getContainer().addEventListener('mousedown', mouseDownHandler);
  3843. getContainer().addEventListener('mouseup', mouseUpHandler);
  3844. }
  3845. /**
  3846. * Removes the auto scrolling action fired by the mouse wheel and trackpad.
  3847. * After this function is called, the mousewheel and trackpad movements won't scroll through sections.
  3848. */
  3849. function removeMouseWheelHandler() {
  3850. if (doc.addEventListener) {
  3851. docRemoveEvent('mousewheel', MouseWheelHandler, false); //IE9, Chrome, Safari, Oper
  3852. docRemoveEvent('wheel', MouseWheelHandler, false); //Firefox
  3853. docRemoveEvent('MozMousePixelScroll', MouseWheelHandler, false); //old Firefox
  3854. } else {
  3855. // @ts-ignore
  3856. doc.detachEvent('onmousewheel', MouseWheelHandler); //IE 6/7/8
  3857. }
  3858. }
  3859. /**
  3860. * Unbinding the mousemove when the mouse's middle button is released
  3861. */
  3862. function removeMiddleWheelHandler() {
  3863. getContainer().removeEventListener('mousedown', mouseDownHandler);
  3864. getContainer().removeEventListener('mouseup', mouseUpHandler);
  3865. }
  3866. /**
  3867. * Detecting mousewheel scrolling
  3868. *
  3869. * http://blogs.sitepointstatic.com/examples/tech/mouse-wheel/index.html
  3870. * http://www.sitepoint.com/html5-javascript-mouse-wheel/
  3871. */
  3872. function MouseWheelHandler(e) {
  3873. var curTime = new Date().getTime();
  3874. var isNormalScroll = hasClass($(COMPLETELY_SEL)[0], NORMAL_SCROLL);
  3875. var isScrollAllowedBeyondFullPage = beyondFullPageHandler(getContainer(), e);
  3876. if (!state.isUsingWheel) {
  3877. setState({
  3878. isGrabbing: false,
  3879. isUsingWheel: true,
  3880. touchDirection: 'none'
  3881. });
  3882. } //is scroll allowed?
  3883. if (!getIsScrollAllowed().m.down && !getIsScrollAllowed().m.up) {
  3884. preventDefault(e);
  3885. return false;
  3886. }
  3887. if (isScrollAllowedBeyondFullPage) {
  3888. return true;
  3889. } else if (isScrollAllowedBeyondFullPage === false) {
  3890. preventDefault(e);
  3891. return false;
  3892. } //autoscrolling and not zooming?
  3893. if (getOptions().autoScrolling && !getControlPressed() && !isNormalScroll) {
  3894. // cross-browser wheel delta
  3895. e = e || win.event;
  3896. var value = e.wheelDelta || -e.deltaY || -e.detail;
  3897. var delta = Math.max(-1, Math.min(1, value));
  3898. var horizontalDetection = typeof e.wheelDeltaX !== 'undefined' || typeof e.deltaX !== 'undefined';
  3899. var isScrollingVertically = Math.abs(e.wheelDeltaX) < Math.abs(e.wheelDelta) || Math.abs(e.deltaX) < Math.abs(e.deltaY) || !horizontalDetection;
  3900. var direction = delta < 0 ? 'down' : delta > 0 ? 'up' : 'none'; //Limiting the array to 150 (lets not waste memory!)
  3901. if (scrollings.length > 149) {
  3902. scrollings.shift();
  3903. } //keeping record of the previous scrollings
  3904. scrollings.push(Math.abs(value)); //preventing to scroll the site on mouse wheel when scrollbar is present
  3905. if (getOptions().scrollBar) {
  3906. preventDefault(e);
  3907. } //time difference between the last scroll and the current one
  3908. var timeDiff = curTime - prevTime;
  3909. prevTime = curTime; //haven't they scrolled in a while?
  3910. //(enough to be consider a different scrolling action to scroll another section)
  3911. if (timeDiff > 200) {
  3912. //emptying the array, we dont care about old scrollings for our averages
  3913. scrollings = [];
  3914. }
  3915. setState({
  3916. wheelDirection: direction
  3917. });
  3918. if (state.canScroll) {
  3919. var averageEnd = getAverage(scrollings, 10);
  3920. var averageMiddle = getAverage(scrollings, 70);
  3921. var isAccelerating = averageEnd >= averageMiddle; //to avoid double swipes...
  3922. if (isAccelerating && isScrollingVertically) {
  3923. setState({
  3924. scrollTrigger: 'wheel'
  3925. }); //scrolling down?
  3926. if (delta < 0) {
  3927. scrolling('down');
  3928. } //scrolling up?
  3929. else {
  3930. scrolling('up');
  3931. }
  3932. }
  3933. }
  3934. return false;
  3935. }
  3936. if (getOptions().fitToSection) {
  3937. //stopping the auto scroll to adjust to a section
  3938. setState({
  3939. activeAnimation: false
  3940. });
  3941. }
  3942. } //binding the mousemove when the mouse's middle button is released
  3943. function mouseDownHandler(e) {
  3944. //middle button
  3945. if (e.which == 2) {
  3946. setOldPageY(e.pageY);
  3947. getContainer().addEventListener('mousemove', mouseMoveHandler);
  3948. }
  3949. } //unbinding the mousemove when the mouse's middle button is released
  3950. function mouseUpHandler(e) {
  3951. //middle button
  3952. if (e.which == 2) {
  3953. getContainer().removeEventListener('mousemove', mouseMoveHandler);
  3954. }
  3955. }
  3956. /**
  3957. * Adds or remove the mouse wheel hijacking
  3958. */
  3959. function setMouseHijack(value) {
  3960. if (value) {
  3961. setMouseWheelScrolling(true);
  3962. addTouchHandler();
  3963. } else {
  3964. setMouseWheelScrolling(false);
  3965. removeTouchHandler();
  3966. }
  3967. }
  3968. var g_canFireMouseEnterNormalScroll = true;
  3969. EventEmitter.on(events.bindEvents, bindEvents$7);
  3970. function bindEvents$7() {
  3971. /**
  3972. * Applying normalScroll elements.
  3973. * Ignoring the scrolls over the specified selectors.
  3974. */
  3975. if (getOptions().normalScrollElements) {
  3976. ['mouseenter', 'touchstart'].forEach(function (eventName) {
  3977. forMouseLeaveOrTouch(eventName, false);
  3978. });
  3979. ['mouseleave', 'touchend'].forEach(function (eventName) {
  3980. forMouseLeaveOrTouch(eventName, true);
  3981. });
  3982. }
  3983. EventEmitter.on(events.onDestroy, onDestroy$4);
  3984. }
  3985. function onDestroy$4() {
  3986. ['mouseenter', 'touchstart', 'mouseleave', 'touchend'].forEach(function (eventName) {
  3987. docRemoveEvent(eventName, onMouseEnterOrLeave, true); //true is required!
  3988. });
  3989. }
  3990. function forMouseLeaveOrTouch(eventName, allowScrolling) {
  3991. //a way to pass arguments to the onMouseEnterOrLeave function
  3992. document['fp_' + eventName] = allowScrolling;
  3993. docAddEvent(eventName, onMouseEnterOrLeave, true); //capturing phase
  3994. }
  3995. function onMouseEnterOrLeave(e) {
  3996. var type = e.type;
  3997. var isInsideOneNormalScroll = false; //onMouseLeave will use the destination target, not the one we are moving away from
  3998. var target = type === 'mouseleave' ? e.toElement || e.relatedTarget : e.target; //coming from closing a normalScrollElements modal or moving outside viewport?
  3999. if (target == document || !target) {
  4000. setMouseHijack(true);
  4001. return;
  4002. }
  4003. if (type === 'touchend') {
  4004. g_canFireMouseEnterNormalScroll = false;
  4005. setTimeout(function () {
  4006. g_canFireMouseEnterNormalScroll = true;
  4007. }, 800);
  4008. } //preventing mouseenter event to do anything when coming from a touchEnd event
  4009. //fixing issue #3576
  4010. if (type === 'mouseenter' && !g_canFireMouseEnterNormalScroll) {
  4011. return;
  4012. }
  4013. var normalSelectors = getOptions().normalScrollElements.split(',');
  4014. normalSelectors.forEach(function (normalSelector) {
  4015. if (!isInsideOneNormalScroll) {
  4016. var isNormalScrollTarget = matches(target, normalSelector); //leaving a child inside the normalScoll element is not leaving the normalScroll #3661
  4017. var isNormalScrollChildFocused = closest(target, normalSelector);
  4018. if (isNormalScrollTarget || isNormalScrollChildFocused) {
  4019. if (!FP.shared.isNormalScrollElement) {
  4020. setMouseHijack(false);
  4021. }
  4022. FP.shared.isNormalScrollElement = true;
  4023. isInsideOneNormalScroll = true;
  4024. }
  4025. }
  4026. }); //not inside a single normal scroll element anymore?
  4027. if (!isInsideOneNormalScroll && FP.shared.isNormalScrollElement) {
  4028. setMouseHijack(true);
  4029. FP.shared.isNormalScrollElement = false;
  4030. }
  4031. }
  4032. FP.silentMoveTo = silentMoveTo;
  4033. /**
  4034. * Moves the page to the given section and slide with no animation.
  4035. * Anchors or index positions can be used as params.
  4036. */
  4037. function silentMoveTo(sectionAnchor, slideAnchor) {
  4038. setScrollingSpeed(0, 'internal');
  4039. moveTo$1(sectionAnchor, slideAnchor);
  4040. setScrollingSpeed(getOriginals().scrollingSpeed, 'internal');
  4041. }
  4042. var previousHeight = getWindowHeight();
  4043. var windowsWidth = getWindowWidth();
  4044. var g_resizeId;
  4045. var g_isConsecutiveResize = false;
  4046. var g_resizeMobileHandlerId;
  4047. FP.reBuild = reBuild;
  4048. EventEmitter.on(events.bindEvents, bindEvents$6);
  4049. function bindEvents$6() {
  4050. // Setting VH correctly in mobile devices
  4051. resizeHandler(); //when resizing the site, we adjust the heights of the sections, slimScroll...
  4052. windowAddEvent('resize', resizeHandler);
  4053. EventEmitter.on(events.onDestroy, onDestroy$3);
  4054. }
  4055. function onDestroy$3() {
  4056. clearTimeout(g_resizeId);
  4057. clearTimeout(g_resizeMobileHandlerId);
  4058. windowRemoveEvent('resize', resizeHandler);
  4059. }
  4060. /*
  4061. * Resize event handler.
  4062. */
  4063. function resizeHandler() {
  4064. if (!g_isConsecutiveResize) {
  4065. if (getOptions().autoScrolling && !getOptions().scrollBar || !getOptions().fitToSection) {
  4066. setSectionsHeight(getWindowHeight());
  4067. }
  4068. }
  4069. fitToActiveSection();
  4070. g_isConsecutiveResize = true; //in order to call the functions only when the resize is finished
  4071. //http://stackoverflow.com/questions/4298612/jquery-how-to-call-resize-event-only-once-its-finished-resizing
  4072. clearTimeout(g_resizeId);
  4073. g_resizeId = setTimeout(function () {
  4074. //issue #3336
  4075. //(some apps or browsers, like Chrome/Firefox for Mobile take time to report the real height)
  4076. //so we check it 3 times with intervals in that case
  4077. // for(var i = 0; i< 4; i++){
  4078. resizeActions();
  4079. g_isConsecutiveResize = false; // }
  4080. }, 400);
  4081. }
  4082. function fitToActiveSection() {
  4083. if (isTouchDevice) {
  4084. // Issue #4393 and previously in v3, #3336
  4085. // (some apps or browsers, like Chrome/Firefox will delay a bit to scroll
  4086. // to the focused input
  4087. for (var i = 0; i < 4; i++) {
  4088. g_resizeMobileHandlerId = setTimeout(function () {
  4089. window.requestAnimationFrame(function () {
  4090. // on Android devices the browser scrolls to the focused element
  4091. // messing up the whole page structure. So we need to update the
  4092. // translate3d value when the keyboard shows/hides
  4093. if (getOptions().autoScrolling && !getOptions().scrollBar) {
  4094. setState({
  4095. isResizing: true
  4096. });
  4097. silentMoveTo(state.activeSection.index() + 1);
  4098. setState({
  4099. isResizing: false
  4100. });
  4101. }
  4102. });
  4103. }, 200 * i);
  4104. }
  4105. }
  4106. }
  4107. /**
  4108. * When resizing the site, we adjust the heights of the sections, slimScroll...
  4109. */
  4110. function resizeActions() {
  4111. setState({
  4112. isResizing: true
  4113. });
  4114. setSectionsHeight('');
  4115. if (!getOptions().autoScrolling && !state.isBeyondFullpage) {
  4116. setVhUnits();
  4117. }
  4118. EventEmitter.emit(events.contentChanged);
  4119. updateState(); //checking if it needs to get responsive
  4120. responsive(); // rebuild immediately on touch devices
  4121. if (isTouchDevice) {
  4122. var activeElement = doc.activeElement; //if the keyboard is NOT visible
  4123. if (!matches(activeElement, 'textarea') && !matches(activeElement, 'input') && !matches(activeElement, 'select')) {
  4124. var currentHeight = getWindowHeight(); //making sure the change in the viewport size is enough to force a rebuild. (20 % of the window to avoid problems when hidding scroll bars)
  4125. if (Math.abs(currentHeight - previousHeight) > 20 * Math.max(previousHeight, currentHeight) / 100) {
  4126. reBuild(true);
  4127. previousHeight = currentHeight;
  4128. }
  4129. }
  4130. } else {
  4131. adjustToNewViewport();
  4132. }
  4133. setState({
  4134. isResizing: false
  4135. });
  4136. }
  4137. /**
  4138. * When resizing is finished, we adjust the slides sizes and positions
  4139. */
  4140. function reBuild(resizing) {
  4141. if (hasClass(getContainer(), DESTROYED)) {
  4142. return;
  4143. } //nothing to do if the plugin was destroyed
  4144. //updating global vars
  4145. setState({
  4146. isResizing: true,
  4147. windowsHeight: getWindowHeight(),
  4148. windowsWidth: getWindowWidth()
  4149. });
  4150. var sections = getState().sections;
  4151. for (var i = 0; i < sections.length; ++i) {
  4152. var section = sections[i];
  4153. var slidesWrap = $(SLIDES_WRAPPER_SEL, section.item)[0];
  4154. var slides = section.slides; //adjusting the position fo the FULL WIDTH slides...
  4155. if (slides.length > 1) {
  4156. landscapeScroll(slidesWrap, section.activeSlide.item);
  4157. }
  4158. }
  4159. if (getOptions().scrollOverflow) {
  4160. scrollOverflowHandler.makeScrollable();
  4161. }
  4162. var sectionIndex = getState().activeSection.index();
  4163. if (!state.isBeyondFullpage) {
  4164. //isn't it the first section?
  4165. if (sectionIndex) {
  4166. //adjusting the position for the current section
  4167. silentMoveTo(sectionIndex + 1);
  4168. }
  4169. }
  4170. setState({
  4171. isResizing: false
  4172. });
  4173. if (isFunction(getOptions().afterResize) && resizing) {
  4174. getOptions().afterResize.call(getContainer(), win.innerWidth, win.innerHeight);
  4175. }
  4176. if (isFunction(getOptions().afterReBuild) && !resizing) {
  4177. getOptions().afterReBuild.call(getContainer());
  4178. }
  4179. trigger(getContainer(), 'afterRebuild');
  4180. }
  4181. /**
  4182. * Adjusts a section to the viewport if it has changed.
  4183. */
  4184. function adjustToNewViewport() {
  4185. var newWindowHeight = getWindowHeight();
  4186. var newWindowWidth = getWindowWidth();
  4187. if (state.windowsHeight !== newWindowHeight || windowsWidth !== newWindowWidth) {
  4188. setState({
  4189. windowsHeight: newWindowHeight
  4190. });
  4191. windowsWidth = newWindowWidth;
  4192. reBuild(true);
  4193. }
  4194. }
  4195. function setSectionsHeight(value) {
  4196. var propertyValue = value === '' ? '' : value + 'px';
  4197. getState().sections.forEach(function (section) {
  4198. css(section.item, {
  4199. 'height': propertyValue
  4200. });
  4201. });
  4202. }
  4203. /**
  4204. * Defining the value in px of a VH unit. (Used for autoScrolling: false)
  4205. * To fix the height issue on mobile devices when using VH units.
  4206. * https://css-tricks.com/the-trick-to-viewport-units-on-mobile/
  4207. */
  4208. function setVhUnits() {
  4209. if (!getOptions().autoScrolling || getOptions().scrollBar) {
  4210. // First we get the viewport height and we multiple it by 1% to get a value for a vh unit
  4211. var vh = win.innerHeight * 0.01; // Then we set the value in the --vh custom property to the root of the document
  4212. doc.documentElement.style.setProperty('--vh', "".concat(vh, "px"));
  4213. }
  4214. }
  4215. function getAnchorsURL() {
  4216. var section;
  4217. var slide;
  4218. var hash = win.location.hash;
  4219. if (hash.length) {
  4220. //getting the anchor link in the URL and deleting the `#`
  4221. var anchorsParts = hash.replace('#', '').split('/'); //using / for visual reasons and not as a section/slide separator #2803
  4222. var isFunkyAnchor = hash.indexOf('#/') > -1;
  4223. section = isFunkyAnchor ? '/' + anchorsParts[1] : decodeURIComponent(anchorsParts[0]);
  4224. var slideAnchor = isFunkyAnchor ? anchorsParts[2] : anchorsParts[1];
  4225. if (slideAnchor && slideAnchor.length) {
  4226. slide = decodeURIComponent(slideAnchor);
  4227. }
  4228. }
  4229. return {
  4230. section: section,
  4231. slide: slide
  4232. };
  4233. }
  4234. FP.setLockAnchors = setLockAnchors;
  4235. EventEmitter.on(events.bindEvents, bindEvents$5);
  4236. function bindEvents$5() {
  4237. //detecting any change on the URL to scroll to the given anchor link
  4238. //(a way to detect back history button as we play with the hashes on the URL)
  4239. windowAddEvent('hashchange', hashChangeHandler);
  4240. EventEmitter.on(events.onDestroy, onDestroy$2);
  4241. }
  4242. function onDestroy$2() {
  4243. windowRemoveEvent('hashchange', hashChangeHandler);
  4244. }
  4245. /**
  4246. * Sets lockAnchors
  4247. */
  4248. function setLockAnchors(value) {
  4249. getOptions().lockAnchors = value;
  4250. }
  4251. /**
  4252. * Detecting any change on the URL to scroll to the given anchor link
  4253. * (a way to detect back history button as we play with the hashes on the URL)
  4254. */
  4255. function hashChangeHandler() {
  4256. if (!state.isScrolling && !getOptions().lockAnchors) {
  4257. var anchors = getAnchorsURL();
  4258. var sectionAnchor = anchors.section;
  4259. var slideAnchor = anchors.slide; //when moving to a slide in the first section for the first time (first time to add an anchor to the URL)
  4260. var isFirstSlideMove = typeof state.lastScrolledDestiny === 'undefined';
  4261. var isFirstScrollMove = typeof state.lastScrolledDestiny === 'undefined' && typeof slideAnchor === 'undefined' && !state.slideMoving;
  4262. if (sectionAnchor && sectionAnchor.length) {
  4263. /*in order to call scrollpage() only once for each destination at a time
  4264. It is called twice for each scroll otherwise, as in case of using anchorlinks `hashChange`
  4265. event is fired on every scroll too.*/
  4266. if (sectionAnchor && sectionAnchor !== state.lastScrolledDestiny && !isFirstSlideMove || isFirstScrollMove || !state.slideMoving && state.lastScrolledSlide != slideAnchor) {
  4267. EventEmitter.emit(events.onScrollPageAndSlide, {
  4268. sectionAnchor: sectionAnchor,
  4269. slideAnchor: slideAnchor
  4270. });
  4271. }
  4272. }
  4273. }
  4274. }
  4275. EventEmitter.on(events.bindEvents, bindEvents$4);
  4276. function bindEvents$4() {
  4277. docAddEvent('wheel', wheelDataHandler.registerEvent, getPassiveOptionsIfPossible());
  4278. EventEmitter.on(events.scrollBeyondFullpage, scrollBeyondFullPage);
  4279. EventEmitter.on(events.onKeyDown, onKeyDown);
  4280. }
  4281. EventEmitter.on(events.bindEvents, bindEvents$3);
  4282. function bindEvents$3() {
  4283. EventEmitter.on(events.onClickOrTouch, onClickOrTouch$1);
  4284. }
  4285. function onClickOrTouch$1(params) {
  4286. var target = params.target;
  4287. if (closest(target, getOptions().menu + ' [data-menuanchor]')) {
  4288. menuItemsHandler.call(target, params);
  4289. }
  4290. } //Menu item handler when not using anchors or using lockAnchors:true
  4291. function menuItemsHandler(e) {
  4292. setState({
  4293. scrollTrigger: 'menu'
  4294. });
  4295. if ($(getOptions().menu)[0] && (getOptions().lockAnchors || !getOptions().anchors.length)) {
  4296. preventDefault(e);
  4297. /*jshint validthis:true */
  4298. EventEmitter.emit(events.onMenuClick, {
  4299. anchor: getAttr(this, 'data-menuanchor')
  4300. });
  4301. }
  4302. }
  4303. EventEmitter.on(events.bindEvents, bindEvents$2);
  4304. function bindEvents$2() {
  4305. EventEmitter.on(events.onClickOrTouch, onClickOrTouch);
  4306. }
  4307. function onClickOrTouch(params) {
  4308. var target = params.target;
  4309. if (target && closest(target, SECTION_NAV_SEL + ' a')) {
  4310. sectionBulletHandler.call(target, params.e);
  4311. } else if (matches(target, SECTION_NAV_TOOLTIP_SEL)) {
  4312. tooltipTextHandler.call(target);
  4313. } else if (matches(target, SLIDES_NAV_LINK_SEL) || closest(target, SLIDES_NAV_LINK_SEL) != null) {
  4314. slideBulletHandler.call(target, params.e);
  4315. }
  4316. }
  4317. var lastScroll = 0;
  4318. var g_scrollId;
  4319. var g_scrollId2;
  4320. EventEmitter.on(events.onDestroy, onDestroy$1); //when scrolling...
  4321. function scrollHandler(e) {
  4322. var currentSection;
  4323. var currentSectionElem;
  4324. if (state.isResizing || !getState().activeSection) {
  4325. return;
  4326. }
  4327. getLast(getState().sections);
  4328. if (getState().isBeyondFullpage || getState().isAboutToScrollToFullPage) {
  4329. return;
  4330. }
  4331. if (!getOptions().autoScrolling || getOptions().scrollBar) {
  4332. var currentScroll = getScrollTop();
  4333. var scrollDirection = getScrollDirection(currentScroll);
  4334. var visibleSectionIndex = 0;
  4335. var screen_mid = currentScroll + getWindowHeight() / 2.0;
  4336. var isAtBottom = $body.scrollHeight - getWindowHeight() === currentScroll;
  4337. var sections = getState().sections;
  4338. setState({
  4339. scrollY: currentScroll
  4340. }); //when using `auto-height` for a small last section it won't be centered in the viewport
  4341. if (isAtBottom) {
  4342. visibleSectionIndex = sections.length - 1;
  4343. } //is at top? when using `auto-height` for a small first section it won't be centered in the viewport
  4344. else if (!currentScroll) {
  4345. visibleSectionIndex = 0;
  4346. } //taking the section which is showing more content in the viewport
  4347. else {
  4348. for (var i = 0; i < sections.length; ++i) {
  4349. var section = sections[i].item; // Pick the the last section which passes the middle line of the screen.
  4350. if (section.offsetTop <= screen_mid) {
  4351. visibleSectionIndex = i;
  4352. }
  4353. }
  4354. }
  4355. if (isCompletelyInViewPort(scrollDirection)) {
  4356. if (!hasClass(getState().activeSection.item, COMPLETELY)) {
  4357. addClass(getState().activeSection.item, COMPLETELY);
  4358. removeClass(siblings(getState().activeSection.item), COMPLETELY);
  4359. }
  4360. } //geting the last one, the current one on the screen
  4361. currentSection = sections[visibleSectionIndex];
  4362. currentSectionElem = currentSection.item; //setting the visible section as active when manually scrolling
  4363. //executing only once the first time we reach the section
  4364. if (!currentSection.isActive) {
  4365. setState({
  4366. isScrolling: true
  4367. });
  4368. var leavingSection = getState().activeSection.item;
  4369. var leavingSectionIndex = getState().activeSection.index() + 1;
  4370. var yMovement = getYmovement(getState().activeSection, currentSectionElem);
  4371. var anchorLink = currentSection.anchor;
  4372. var sectionIndex = currentSection.index() + 1;
  4373. var activeSlide = currentSection.activeSlide;
  4374. var slideIndex;
  4375. var slideAnchorLink;
  4376. var callbacksParams = {
  4377. activeSection: leavingSection,
  4378. sectionIndex: sectionIndex - 1,
  4379. anchorLink: anchorLink,
  4380. element: currentSectionElem,
  4381. leavingSection: leavingSectionIndex,
  4382. direction: yMovement,
  4383. items: {
  4384. origin: getState().activeSection,
  4385. destination: currentSection
  4386. }
  4387. };
  4388. if (activeSlide) {
  4389. slideAnchorLink = activeSlide.anchor;
  4390. slideIndex = activeSlide.index();
  4391. }
  4392. if (state.canScroll) {
  4393. addClass(currentSectionElem, ACTIVE);
  4394. removeClass(siblings(currentSectionElem), ACTIVE);
  4395. if (isFunction(getOptions().beforeLeave)) {
  4396. fireCallbackOncePerScroll('beforeLeave', callbacksParams);
  4397. }
  4398. if (isFunction(getOptions().onLeave)) {
  4399. fireCallback('onLeave', callbacksParams);
  4400. }
  4401. if (isFunction(getOptions().afterLoad)) {
  4402. fireCallback('afterLoad', callbacksParams);
  4403. }
  4404. stopMedia(leavingSection);
  4405. lazyLoad(currentSectionElem);
  4406. playMedia(currentSectionElem);
  4407. activateMenuAndNav(anchorLink, sectionIndex - 1);
  4408. if (getOptions().anchors.length) {
  4409. //needed to enter in hashChange event when using the menu with anchor links
  4410. setState({
  4411. lastScrolledDestiny: anchorLink
  4412. });
  4413. }
  4414. updateState();
  4415. setPageStatus(slideIndex, slideAnchorLink, anchorLink);
  4416. } //small timeout in order to avoid entering in hashChange event when scrolling is not finished yet
  4417. clearTimeout(g_scrollId);
  4418. g_scrollId = setTimeout(function () {
  4419. setState({
  4420. isScrolling: false
  4421. });
  4422. }, 100);
  4423. }
  4424. if (getOptions().fitToSection && state.canScroll) {
  4425. clearTimeout(g_scrollId2);
  4426. g_scrollId2 = setTimeout(function () {
  4427. var fixedSections = state.sections.filter(function (section) {
  4428. var sectionValues = section.item.getBoundingClientRect();
  4429. return Math.round(sectionValues.bottom) === Math.round(getWindowHeight()) || Math.round(sectionValues.top) === 0;
  4430. }); // No section is fitting the viewport? Let's fix that!
  4431. if (!fixedSections.length) {
  4432. fitToSection();
  4433. }
  4434. }, getOptions().fitToSectionDelay);
  4435. }
  4436. }
  4437. }
  4438. function onDestroy$1() {
  4439. clearTimeout(g_scrollId);
  4440. clearTimeout(g_scrollId2);
  4441. }
  4442. /**
  4443. * Gets the directon of the the scrolling fired by the scroll event.
  4444. */
  4445. function getScrollDirection(currentScroll) {
  4446. var direction = currentScroll > lastScroll ? 'down' : 'up';
  4447. lastScroll = currentScroll; //needed for auto-height sections to determine if we want to scroll to the top or bottom of the destination
  4448. setState({
  4449. previousDestTop: currentScroll
  4450. });
  4451. return direction;
  4452. }
  4453. /**
  4454. * Determines whether the active section has seen in its whole or not.
  4455. */
  4456. function isCompletelyInViewPort(movement) {
  4457. var top = getState().activeSection.item.offsetTop;
  4458. var bottom = top + getWindowHeight();
  4459. if (movement == 'up') {
  4460. return bottom >= getScrollTop() + getWindowHeight();
  4461. }
  4462. return top <= getScrollTop();
  4463. }
  4464. EventEmitter.on(events.bindEvents, bindEvents$1);
  4465. EventEmitter.on(events.onDestroy, onDestroy);
  4466. function onDestroy() {
  4467. windowRemoveEvent('scroll', scrollHandler);
  4468. }
  4469. function bindEvents$1() {
  4470. windowAddEvent('scroll', scrollHandler);
  4471. doc.body.addEventListener('scroll', scrollHandler);
  4472. EventEmitter.on(events.onScrollPageAndSlide, function (params) {
  4473. scrollPageAndSlide(params.sectionAnchor, params.slideAnchor);
  4474. });
  4475. EventEmitter.on(events.onMenuClick, function (params) {
  4476. moveTo$1(params.anchor, undefined);
  4477. });
  4478. EventEmitter.on(events.onScrollOverflowScrolled, function (params) {
  4479. var scrollSection = params.direction === 'down' ? moveSectionDown : moveSectionUp;
  4480. scrollSection();
  4481. });
  4482. EventEmitter.on(events.scrollPage, function (params) {
  4483. scrollPage(params.destination);
  4484. });
  4485. }
  4486. FP.getActiveSlide = getActiveSlide;
  4487. FP.getScrollX = function () {
  4488. return state.scrollX;
  4489. };
  4490. EventEmitter.on(events.bindEvents, bindEvents);
  4491. function bindEvents() {
  4492. EventEmitter.on(events.onDestroy, onDestroy$6);
  4493. EventEmitter.on(events.landscapeScroll, function (params) {
  4494. landscapeScroll(params.slides, params.destination);
  4495. });
  4496. EventEmitter.on(events.moveSlideRight, function (params) {
  4497. moveSlideRight(params.section);
  4498. });
  4499. EventEmitter.on(events.moveSlideLeft, function (params) {
  4500. moveSlideLeft(params.section);
  4501. });
  4502. }
  4503. /**
  4504. * Gets the active slide.
  4505. */
  4506. function getActiveSlide() {
  4507. return nullOrSlide(getState().activeSection.activeSlide);
  4508. }
  4509. EventEmitter.on(events.bindEvents, init$1);
  4510. function init$1() {
  4511. var position = getOptions().credits.position || 'right';
  4512. var positionStyle = ['left', 'right'].indexOf(position) > -1 ? "".concat(position, ": 0;") : '';
  4513. var waterMark = "\n <div class=\"fp-watermark\" style=\"".concat(positionStyle, "\">\n <a href=\"https://alvarotrigo.com/fullPage/\" \n rel=\"nofollow noopener\" \n target=\"_blank\" \n style=\"text-decoration:none; color: #000;\">\n ").concat(getOptions().credits.label || 'Made with fullPage.js', "\n </a>\n </div>\n ");
  4514. var lastSection = getLast(state.sections);
  4515. var shouldUseWaterMark = !state.isValid || getOptions().credits.enabled;
  4516. if (lastSection && lastSection.item && shouldUseWaterMark) {
  4517. lastSection.item.insertAdjacentHTML('beforeend', waterMark);
  4518. }
  4519. }
  4520. !function () {
  4521. EventEmitter.on(events.onInitialise, function () {
  4522. var n, a, l;
  4523. setState({
  4524. isValid: (getOptions().licenseKey, n = getOptions().licenseKey, a = function (n) {
  4525. var e = parseInt("\x35\x31\x34").toString(16);
  4526. if (!n || n.length < 29 || 4 === n.split(t[0]).length) return null;
  4527. var r = ["\x45\x61\x63\x68", "\x66\x6f\x72"][i()]().join(""),
  4528. a = n[["\x73\x70\x6c\x69\x74"]]("-"),
  4529. l = [];
  4530. a[r](function (t, n) {
  4531. if (n < 4) {
  4532. var r = function (t) {
  4533. var n = t[t.length - 1],
  4534. e = ["\x4e\x61\x4e", "\x69\x73"][i()]().join("");
  4535. return window[e](n) ? o(n) : function (t) {
  4536. return t - ACTIVE.length;
  4537. }(n);
  4538. }(t);
  4539. l.push(r);
  4540. var s = o(t[r]);
  4541. if (1 === n) {
  4542. var a = ["\x70\x61", "\x64\x53", "\x74", "\x61\x72\x74"].join("");
  4543. s = s.toString()[a](2, "0");
  4544. }
  4545. e += s, 0 !== n && 1 !== n || (e += "-");
  4546. }
  4547. });
  4548. var m = 0,
  4549. f = "";
  4550. return n.split("-").forEach(function (t, n) {
  4551. if (n < 4) {
  4552. var _i = 0;
  4553. for (var e = 0; e < 4; e++) {
  4554. e !== l[n] && (_i += Math.abs(o(t[e])), isNaN(t[e]) || m++);
  4555. }
  4556. var r = s(_i);
  4557. f += r;
  4558. }
  4559. }), f += s(m), {
  4560. v: new Date(e + "T00:00"),
  4561. o: e.split("-")[2] === 8 * (ACTIVE.length - 2) + "",
  4562. l: f
  4563. };
  4564. }(n), l = function (t) {
  4565. var n = r[i()]().join("");
  4566. return t && 0 === n.indexOf(t) && t.length === n.length;
  4567. }(n), (a || l) && (a && e <= a.v && a.l === n.split(t[0])[4] || l || a.o) || !1)
  4568. });
  4569. });
  4570. var t = ["-"];
  4571. var n = "\x32\x30\x32\x33\x2d\x34\x2d\x32\x39".split("-"),
  4572. e = new Date(n[0], n[1], n[2]),
  4573. r = ["se", "licen", "-", "v3", "l", "gp"];
  4574. function i() {
  4575. return [["\x72\x65", "\x76\x65\x72\x73\x65"].join("")]["".length];
  4576. }
  4577. function o(t) {
  4578. return t ? isNaN(t) ? t.charCodeAt(0) - 72 : t : "";
  4579. }
  4580. function s(t) {
  4581. var n = 72 + t;
  4582. return n > 90 && n < 97 && (n += 15), String.fromCharCode(n).toUpperCase();
  4583. }
  4584. }();
  4585. //@ts-check
  4586. FP.setKeyboardScrolling = setKeyboardScrolling;
  4587. /**
  4588. * Adds or remove the possibility of scrolling through sections by using the keyboard arrow keys
  4589. */
  4590. function setKeyboardScrolling(value, directions) {
  4591. if (typeof directions !== 'undefined') {
  4592. directions = directions.replace(/ /g, '').split(',');
  4593. directions.forEach(function (direction) {
  4594. setIsScrollAllowed(value, direction, 'k');
  4595. });
  4596. } else {
  4597. setIsScrollAllowed(value, 'all', 'k');
  4598. getOptions().keyboardScrolling = value;
  4599. }
  4600. }
  4601. /**
  4602. * Sets the data-anchor attributes to the menu elements and activates the current one.
  4603. */
  4604. function styleMenu(section) {
  4605. var index = section.index();
  4606. if (typeof getOptions().anchors[index] !== 'undefined') {
  4607. //activating the menu / nav element on load
  4608. if (section.isActive) {
  4609. activateMenuAndNav(getOptions().anchors[index], index);
  4610. }
  4611. } //moving the menu outside the main container if it is inside (avoid problems with fixed positions when using CSS3 tranforms)
  4612. if (getOptions().menu && getOptions().css3 && closest($(getOptions().menu)[0], WRAPPER_SEL) != null) {
  4613. $(getOptions().menu).forEach(function (menu) {
  4614. $body.appendChild(menu);
  4615. });
  4616. }
  4617. }
  4618. /**
  4619. * Works over the DOM structure to set it up for the current fullpage getOptions().
  4620. */
  4621. function prepareDom() {
  4622. css(getParentsUntil(getContainer(), 'body'), {
  4623. 'height': '100%',
  4624. 'position': 'relative'
  4625. }); //adding a class to recognize the container internally in the code
  4626. addClass(getContainer(), WRAPPER);
  4627. addClass($html, ENABLED); //due to https://github.com/alvarotrigo/fullPage.js/issues/1502
  4628. setState({
  4629. windowsHeight: getWindowHeight()
  4630. });
  4631. removeClass(getContainer(), DESTROYED); //in case it was destroyed before initializing it again
  4632. addInternalSelectors();
  4633. var sections = getState().sectionsIncludingHidden; //styling the sections / slides / menu
  4634. for (var i = 0; i < sections.length; i++) {
  4635. var section = sections[i];
  4636. var slides = section.allSlidesItems; //caching the original styles to add them back on destroy('all')
  4637. var originalStyles = getAttr(section.item, 'style');
  4638. if (originalStyles) {
  4639. section.item.setAttribute('data-fp-styles', originalStyles);
  4640. }
  4641. styleSection(section);
  4642. styleMenu(section); // if there's any slide
  4643. if (slides.length > 0) {
  4644. styleSlides(section);
  4645. }
  4646. } //fixed elements need to be moved out of the plugin container due to problems with CSS3.
  4647. if (getOptions().fixedElements && getOptions().css3) {
  4648. $(getOptions().fixedElements).forEach(function (item) {
  4649. $body.appendChild(item);
  4650. });
  4651. } //vertical centered of the navigation + active bullet
  4652. if (getOptions().navigation) {
  4653. addVerticalNavigation();
  4654. }
  4655. enableYoutubeAPI();
  4656. if (getOptions().scrollOverflow) {
  4657. scrollOverflowHandler.makeScrollable();
  4658. }
  4659. }
  4660. FP.shared.afterRenderActions = afterRenderActions;
  4661. /**
  4662. * Actions and callbacks to fire afterRender
  4663. */
  4664. function afterRenderActions() {
  4665. var section = getState().activeSection;
  4666. var sectionElem = getState().activeSection.item;
  4667. addClass(sectionElem, COMPLETELY);
  4668. lazyLoad(sectionElem);
  4669. lazyLoadOthers();
  4670. playMedia(sectionElem);
  4671. if (isDestinyTheStartingSection() && isFunction(getOptions().afterLoad)) {
  4672. fireCallback('afterLoad', {
  4673. activeSection: sectionElem,
  4674. element: sectionElem,
  4675. direction: null,
  4676. //for backwards compatibility callback (to be removed in a future!)
  4677. anchorLink: section.anchor,
  4678. sectionIndex: section.index(),
  4679. items: {
  4680. origin: getState().activeSection,
  4681. destination: getState().activeSection
  4682. }
  4683. });
  4684. }
  4685. if (isFunction(getOptions().afterRender)) {
  4686. fireCallback('afterRender');
  4687. }
  4688. }
  4689. /**
  4690. * Determines if the URL anchor destiny is the starting section (the one using 'active' class before initialization)
  4691. */
  4692. function isDestinyTheStartingSection() {
  4693. var anchor = getAnchorsURL();
  4694. var destinationSection = getSectionByAnchor(anchor.section);
  4695. return !anchor.section || !destinationSection || typeof destinationSection !== 'undefined' && destinationSection.index() === index(getStartingSection());
  4696. }
  4697. FP.setAllowScrolling = setAllowScrolling;
  4698. /**
  4699. * Adds or remove the possibility of scrolling through sections by using the mouse wheel/trackpad or touch gestures.
  4700. * Optionally a second parameter can be used to specify the direction for which the action will be applied.
  4701. *
  4702. * @param directions string containing the direction or directions separated by comma.
  4703. */
  4704. function setAllowScrolling(value, directions) {
  4705. if (typeof directions !== 'undefined') {
  4706. directions = directions.replace(/ /g, '').split(',');
  4707. directions.forEach(function (direction) {
  4708. setIsScrollAllowed(value, direction, 'm');
  4709. });
  4710. } else {
  4711. setIsScrollAllowed(value, 'all', 'm');
  4712. }
  4713. }
  4714. /**
  4715. * Scrolls to the anchor in the URL when loading the site
  4716. */
  4717. function scrollToAnchor() {
  4718. var anchors = getAnchorsURL();
  4719. var sectionAnchor = anchors.section;
  4720. var slideAnchor = anchors.slide;
  4721. if (sectionAnchor) {
  4722. //if theres any #
  4723. if (getOptions().animateAnchor) {
  4724. scrollPageAndSlide(sectionAnchor, slideAnchor);
  4725. } else {
  4726. silentMoveTo(sectionAnchor, slideAnchor);
  4727. }
  4728. } else {
  4729. EventEmitter.emit(events.onAfterRenderNoAnchor, null);
  4730. }
  4731. }
  4732. /*
  4733. * Removes inline styles added by fullpage.js
  4734. */
  4735. function destroyStructure() {
  4736. //reseting the `top` or `translate` properties to 0
  4737. silentScroll(0); //loading all the lazy load content
  4738. $('img[data-src], source[data-src], audio[data-src], iframe[data-src]', getContainer()).forEach(function (item) {
  4739. setSrc(item, 'src');
  4740. });
  4741. $('img[data-srcset]').forEach(function (item) {
  4742. setSrc(item, 'srcset');
  4743. });
  4744. remove($(SECTION_NAV_SEL + ', ' + SLIDES_NAV_SEL + ', ' + SLIDES_ARROW_SEL)); //removing inline styles
  4745. css(getNodes(getState().sections), {
  4746. 'height': '',
  4747. 'background-color': '',
  4748. 'padding': ''
  4749. });
  4750. css(getNodes(getState().slides), {
  4751. 'width': ''
  4752. });
  4753. css(getContainer(), {
  4754. 'height': '',
  4755. 'position': '',
  4756. '-ms-touch-action': '',
  4757. 'touch-action': ''
  4758. });
  4759. css($htmlBody, {
  4760. 'overflow': '',
  4761. 'height': ''
  4762. }); // remove .fp-enabled class
  4763. removeClass($html, ENABLED); // remove .fp-responsive class & .fp-scrollable
  4764. removeClass($body, RESPONSIVE + ' ' + SCROLLABLE); // remove all of the .fp-viewing- classes
  4765. $body.className.split(/\s+/).forEach(function (className) {
  4766. if (className.indexOf(VIEWING_PREFIX) === 0) {
  4767. removeClass($body, className);
  4768. }
  4769. }); //removing added classes
  4770. getNodes(getState().panels).forEach(function (item) {
  4771. if (getOptions().scrollOverflow) {
  4772. scrollOverflowHandler.destroyWrapper(item);
  4773. }
  4774. removeClass(item, TABLE + ' ' + ACTIVE + ' ' + COMPLETELY + ' ' + IS_OVERFLOW);
  4775. var previousStyles = getAttr(item, 'data-fp-styles');
  4776. if (previousStyles) {
  4777. item.setAttribute('style', previousStyles);
  4778. } //removing anchors if they were not set using the HTML markup
  4779. if (hasClass(item, SECTION) && !getInitialAnchorsInDom()) {
  4780. item.removeAttribute('data-anchor');
  4781. }
  4782. }); //removing the applied transition from the fullpage wrapper
  4783. removeAnimation(getContainer()); //Unwrapping content
  4784. [TABLE_CELL_SEL, SLIDES_CONTAINER_SEL, SLIDES_WRAPPER_SEL].forEach(function (selector) {
  4785. $(selector, getContainer()).forEach(function (item) {
  4786. //unwrap not being use in case there's no child element inside and its just text
  4787. unwrap(item);
  4788. });
  4789. }); //removing the applied transition from the fullpage wrapper
  4790. css(getContainer(), {
  4791. '-webkit-transition': 'none',
  4792. 'transition': 'none'
  4793. });
  4794. removeClass(getContainer(), WRAPPER); //scrolling the page to the top with no animation
  4795. win.scrollTo(0, 0); //removing selectors
  4796. var usedSelectors = [SECTION, SLIDE, SLIDES_CONTAINER];
  4797. usedSelectors.forEach(function (item) {
  4798. removeClass($('.' + item), item);
  4799. });
  4800. }
  4801. FP.destroy = destroy;
  4802. function init() {
  4803. updateStructuralState();
  4804. updateState();
  4805. getOptions().scrollBar = getOptions().scrollBar || getOptions().hybrid;
  4806. setOptionsFromDOM();
  4807. prepareDom();
  4808. setAllowScrolling(true);
  4809. setMouseHijack(true);
  4810. setAutoScrolling(getOptions().autoScrolling, 'internal');
  4811. responsive(); //setting the class for the body element
  4812. setBodyClass();
  4813. if (doc.readyState === 'complete') {
  4814. scrollToAnchor();
  4815. }
  4816. windowAddEvent('load', scrollToAnchor);
  4817. afterRenderActions(); // Updating the state again with the new DOM
  4818. updateStructuralState();
  4819. updateState();
  4820. }
  4821. /*
  4822. * Destroys fullpage.js plugin events and optinally its html markup and styles
  4823. */
  4824. function destroy(all) {
  4825. setAutoScrolling(false, 'internal');
  4826. setAllowScrolling(true);
  4827. setMouseHijack(false);
  4828. setKeyboardScrolling(false);
  4829. addClass(getContainer(), DESTROYED);
  4830. EventEmitter.emit(events.onDestroy); //lets make a mess!
  4831. if (all) {
  4832. destroyStructure();
  4833. }
  4834. }
  4835. var isOK = function isOK() {
  4836. return getOptions() && state.isValid || doc.domain.indexOf('al' + 'varotri' + 'go' + '.' + 'com') > -1;
  4837. };
  4838. /**
  4839. * Displays warnings
  4840. */
  4841. function displayWarnings() {
  4842. var l = getOptions()['li' + 'c' + 'enseK' + 'e' + 'y'];
  4843. var msgStyle = 'font-size: 15px;background:yellow;';
  4844. if (hasClass($html, ENABLED)) {
  4845. showError('error', 'Fullpage.js can only be initialized once and you are doing it multiple times!');
  4846. return;
  4847. } // Disable mutually exclusive settings
  4848. if (getOptions().continuousVertical && (getOptions().loopTop || getOptions().loopBottom)) {
  4849. getOptions().continuousVertical = false;
  4850. showError('warn', 'Option `loopTop/loopBottom` is mutually exclusive with `continuousVertical`; `continuousVertical` disabled');
  4851. }
  4852. if (getOptions().scrollOverflow && (getOptions().scrollBar || !getOptions().autoScrolling)) {
  4853. showError('warn', 'Options scrollBar:true and autoScrolling:false are mutually exclusive with scrollOverflow:true. Sections with scrollOverflow might not work well in Firefox');
  4854. }
  4855. if (getOptions().continuousVertical && (getOptions().scrollBar || !getOptions().autoScrolling)) {
  4856. getOptions().continuousVertical = false;
  4857. showError('warn', 'Scroll bars (`scrollBar:true` or `autoScrolling:false`) are mutually exclusive with `continuousVertical`; `continuousVertical` disabled');
  4858. } //using extensions? Wrong file!
  4859. extensions.forEach(function (extension) {
  4860. //is the option set to true?
  4861. if (getOptions()[extension]) {
  4862. showError('warn', 'fullpage.js extensions require fullpage.extensions.min.js file instead of the usual fullpage.js. Requested: ' + extension);
  4863. }
  4864. }); //anchors can not have the same value as any element ID or NAME
  4865. getOptions().anchors.forEach(function (name) {
  4866. //case insensitive selectors (http://stackoverflow.com/a/19465187/1081396)
  4867. var nameAttr = [].slice.call($('[name]')).filter(function (item) {
  4868. return getAttr(item, 'name') && getAttr(item, 'name').toLowerCase() == name.toLowerCase();
  4869. });
  4870. var idAttr = [].slice.call($('[id]')).filter(function (item) {
  4871. return getAttr(item, 'id') && getAttr(item, 'id').toLowerCase() == name.toLowerCase();
  4872. });
  4873. if (idAttr.length || nameAttr.length) {
  4874. showError('error', 'data-anchor tags can not have the same value as any `id` element on the site (or `name` element for IE).');
  4875. var propertyName = idAttr.length ? 'id' : 'name';
  4876. if (idAttr.length || nameAttr.length) {
  4877. showError('error', '"' + name + '" is is being used by another element `' + propertyName + '` property');
  4878. }
  4879. }
  4880. });
  4881. }
  4882. function fullpage(containerSelector, options) {
  4883. setCache(); //only once my friend!
  4884. if (hasClass($html, ENABLED)) {
  4885. displayWarnings();
  4886. return;
  4887. }
  4888. setOption('touchWrapper', typeof containerSelector === 'string' ? $(containerSelector)[0] : containerSelector); // Creating some defaults, extending them with any options that were provided
  4889. setOptions(options);
  4890. setContainer(typeof containerSelector === 'string' ? $(containerSelector)[0] : containerSelector);
  4891. EventEmitter.emit(events.onInitialise);
  4892. displayWarnings();
  4893. setAPI();
  4894. if (getContainer()) {
  4895. EventEmitter.emit(events.beforeInit);
  4896. init();
  4897. EventEmitter.emit(events.bindEvents);
  4898. } // @ts-ignore
  4899. return win.fullpage_api;
  4900. }
  4901. function setAPI() {
  4902. FP.getFullpageData = function () {
  4903. return {
  4904. options: getOptions()
  4905. };
  4906. }; //public functions
  4907. FP.version = '4.0.20';
  4908. FP.test = Object.assign(FP.test, {
  4909. top: '0px',
  4910. translate3d: 'translate3d(0px, 0px, 0px)',
  4911. translate3dH: function () {
  4912. var a = [];
  4913. for (var i = 0; i < $(getOptions().sectionSelector, getContainer()).length; i++) {
  4914. a.push('translate3d(0px, 0px, 0px)');
  4915. }
  4916. return a;
  4917. }(),
  4918. left: function () {
  4919. var a = [];
  4920. for (var i = 0; i < $(getOptions().sectionSelector, getContainer()).length; i++) {
  4921. a.push(0);
  4922. }
  4923. return a;
  4924. }(),
  4925. options: getOptions(),
  4926. setAutoScrolling: null
  4927. }); //functions we want to share across files but which are not
  4928. //mean to be used on their own by developers
  4929. FP.shared = Object.assign(FP.shared, {
  4930. afterRenderActions: null,
  4931. isNormalScrollElement: false
  4932. }); // @ts-ignore
  4933. win.fullpage_api = FP;
  4934. }
  4935. // @ts-ignore
  4936. win.fp_easings = deepExtend(win.fp_easings, {
  4937. easeInOutCubic: function easeInOutCubic(t, b, c, d) {
  4938. if ((t /= d / 2) < 1) return c / 2 * t * t * t + b;
  4939. return c / 2 * ((t -= 2) * t * t + 2) + b;
  4940. }
  4941. });
  4942. /**
  4943. * jQuery adapter for fullPage.js 3.0.0
  4944. */
  4945. // @ts-ignore
  4946. if (win.jQuery) {
  4947. (function ($, fullpage) {
  4948. if (!$ || !fullpage) {
  4949. showError('error', 'jQuery is required to use the jQuery fullpage adapter!');
  4950. return;
  4951. }
  4952. $.fn.fullpage = function (options) {
  4953. options = $.extend({}, options, {
  4954. '$': $
  4955. });
  4956. new fullpage(this[0], options); // Creating the $.fn.fullpage object
  4957. Object.keys(FP).forEach(function (key) {
  4958. getOptions().$.fn.fullpage[key] = FP[key];
  4959. });
  4960. }; // @ts-ignore
  4961. })(win.jQuery, fullpage);
  4962. }
  4963. return fullpage;
  4964. }));