From e649c4769a9a85133d6c8d9c540f85eaac6a0e90 Mon Sep 17 00:00:00 2001 From: bjoern Date: Tue, 10 Sep 2019 02:52:11 +0200 Subject: [PATCH] adding bugfixes --- dist/js/demo-386.js | 2 +- src/TinyOnePage.riot | 21 +++++++-------------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/dist/js/demo-386.js b/dist/js/demo-386.js index 789cd1c..95e7971 100644 --- a/dist/js/demo-386.js +++ b/dist/js/demo-386.js @@ -1 +1 @@ -!function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s=1)}([function(e,t,n){(function(n){var o,r;window.Element&&!Element.prototype.closest&&(Element.prototype.closest=function(e){var t,n=(this.document||this.ownerDocument).querySelectorAll(e),o=this;do{for(t=n.length;0<=--t&&n.item(t)!==o;);}while(t<0&&(o=o.parentElement));return o}),function(){function e(e,t){t=t||{bubbles:!1,cancelable:!1,detail:void 0};var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),n}"function"!=typeof window.CustomEvent&&(e.prototype=window.Event.prototype,window.CustomEvent=e)}(),function(){for(var e=0,t=["ms","moz","webkit","o"],n=0;nb.durationMax?b.durationMax:b.durationMin&&v=S)return h.cancelScroll(!0),a=n,u=m,0===(r=o)&&document.body.focus(),u||(r.focus(),document.activeElement!==r&&(r.setAttribute("tabindex","-1"),r.focus(),r.style.outline="none"),e.scrollTo(0,a)),i("scrollStop",l,o,s),!(d=y=null)}(O,A)||(d=e.requestAnimationFrame(x),y=t)};0===e.pageYOffset&&e.scrollTo(0,0),E=o,M=l,m||history.pushState&&M.updateURL&&history.pushState({smoothScroll:JSON.stringify(M),anchor:E.id},document.title,E===document.documentElement?"#top":"#"+E.id),"matchMedia"in e&&e.matchMedia("(prefers-reduced-motion)").matches?e.scrollTo(0,Math.floor(A)):(i("scrollStart",l,o,s),h.cancelScroll(!0),e.requestAnimationFrame(x))}}},m=function(t){if(!t.defaultPrevented&&!(0!==t.button||t.metaKey||t.ctrlKey||t.shiftKey)&&"closest"in t.target&&(l=t.target.closest(s))&&"a"===l.tagName.toLowerCase()&&!t.target.closest(u.ignore)&&l.hostname===e.location.hostname&&l.pathname===e.location.pathname&&/#/.test(l.href)){var n,r=o(l.hash);if("#"===r){if(!u.topOnEmptyHash)return;n=document.documentElement}else n=document.querySelector(r);(n=n||"#top"!==r?n:document.documentElement)&&(t.preventDefault(),function(t){if(history.replaceState&&t.updateURL&&!history.state){var n=e.location.hash;n=n||"",history.replaceState({smoothScroll:JSON.stringify(t),anchor:n||e.pageYOffset},document.title,n||e.location.href)}}(u),h.animateScroll(n,l))}},f=function(e){if(null!==history.state&&history.state.smoothScroll&&history.state.smoothScroll===JSON.stringify(u)){var t=history.state.anchor;"string"==typeof t&&t&&!(t=document.querySelector(o(history.state.anchor)))||h.animateScroll(t,null,{updateURL:!1})}};return h.destroy=function(){u&&(document.removeEventListener("click",m,!1),e.removeEventListener("popstate",f,!1),h.cancelScroll(),d=c=l=u=null)},function(){if(!("querySelector"in document&&"addEventListener"in e&&"requestAnimationFrame"in e&&"closest"in e.Element.prototype))throw"Smooth Scroll: This browser does not support the required JavaScript methods and browser APIs.";h.destroy(),u=n(t,a||{}),c=u.header?document.querySelector(u.header):null,document.addEventListener("click",m,!1),u.updateURL&&u.popstate&&e.addEventListener("popstate",f,!1)}(),h}}(r)}.apply(t,[]))||(e.exports=o)}).call(this,n(2))},function(e,t,n){n(3),e.exports=n(4)},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";n.r(t);const o=new Map,r=Symbol("riot-component"),i=new Set,s="is",a="value",u=Symbol("attributes"),l=Symbol("template");var c=Object.freeze({COMPONENTS_IMPLEMENTATION_MAP:o,DOM_COMPONENT_INSTANCE_PROPERTY:r,PLUGINS_SET:i,IS_DIRECTIVE:s,VALUE_ATTRIBUTE:a,ATTRIBUTES_KEY_SYMBOL:u,TEMPLATE_KEY_SYMBOL:l});function d(e){Array.from(e).forEach(e=>e.parentNode&&e.parentNode.removeChild(e))}const h=2;var m={EACH:0,IF:1,SIMPLE:h,TAG:3,SLOT:4};const{indexOf:f}=[],p=(e,t,n,o,r,i)=>{const s="selectedIndex"in t;let a=s;for(;oe==t,b=e=>e,v=(e,t,n,o,r,i,s)=>{const a=i-r;if(a<1)return-1;for(;n-t>=a;){let a=t,u=r;for(;an{if(r-o<2)t.removeChild(e(n[o],-1));else{const i=t.ownerDocument.createRange();i.setStartBefore(e(n[o],-1)),i.setEndAfter(e(n[r-1],-1)),i.deleteContents()}},O=(e,t,n)=>{let o=1,r=t;for(;o>>0;n{((e,t,n,o,r,i,s,a,u)=>{const l=new Map,c=e.length;let d=s,h=0;for(;h{const a=n+i,u=[];let l,c,d,h,m,f,p;e:for(l=0;l<=a;l++){if(l>50)return null;for(p=l-1,m=l?u[l-1]:[0,0],f=u[l]=[],c=-l;c<=l;c+=2){for(d=(h=c===-l||c!==l&&m[p+c-1]=0;l--){for(;h>0&&d>0&&s(o[r+h-1],e[t+d-1]);)g[b--]=0,h--,d--;if(!l)break;p=l-1,m=l?u[l-1]:[0,0],(c=h-d)===-l||c!==l&&m[p+c-1]{let u=0,l=os;)--u;l=a+o-u;const m=Array(l);let f=c[u];for(--n;f;){const{newi:e,oldi:t}=f;for(;n>e;)m[--l]=1,--n;for(;s>t;)m[--l]=-1,--s;m[--l]=0,--n,--s,f=f.prev}for(;n>=t;)m[--l]=1,--n;for(;s>=i;)m[--l]=-1,--s;return m})(n,o,r,i,s,a,u,l),e,t,n,o,s,a,c,h)};function M(e){return null==e}function T(e){return!M(e.content)}const A=Object.seal({childrenMap:null,node:null,root:null,condition:null,evaluate:null,template:null,isTemplateTag:!1,nodes:[],getKey:null,indexName:null,itemName:null,afterPlaceholder:null,placeholder:null,mount(e,t){return this.update(e,t)},update(e,t){const{placeholder:n}=this,o=this.evaluate(e),r=o?Array.from(o):[],i=n.parentNode,{newChildrenMap:s,batches:a,futureNodes:u}=function(e,t,n,o){const{condition:r,template:i,childrenMap:s,itemName:a,getKey:u,indexName:l,root:c,isTemplateTag:d}=o,h=new Map,m=[],f=[];return e.forEach((e,o)=>{const p=function(e,t){let{itemName:n,indexName:o,index:r,item:i}=t;e[n]=i,o&&(e[o]=r);return e}(Object.create(t),{itemName:a,indexName:l,index:o,item:e}),g=u?u(p):o,b=s.get(g);if(function(e,t){return!!e&&!1===Boolean(e(t))}(r,p))return;const v=b?b.template:i.clone(),y=b?v.el:c.cloneNode(),w=!b,O=d&&w?function(e){const t=e.dom.cloneNode(!0);return{avoidDOMInjection:!0,fragment:t,children:Array.from(t.childNodes)}}(v):{};w?m.push(()=>v.mount(y,p,n,O)):v.update(p,n),d?f.push(...O.children||v.children):f.push(y),s.delete(g),h.set(g,{template:v,context:p,index:o})}),{newChildrenMap:h,batches:m,futureNodes:f}}(r,e,t,this);return u.length?((e,t,n,o)=>{o||(o={});const r=o.compare||g,i=o.node||b,s=null==o.before?null:i(o.before,0),a=t.length;let u=a,l=0,c=n.length,d=0;for(;l{for(;oe()),this.childrenMap=s,this.nodes=u,this},unmount(e,t){return S(this.childrenMap,t),this.childrenMap=new Map,this.nodes=[],this}});function N(e,t){return(n,o)=>{if(o<0){const{template:n,context:o}=e.pop();n.unmount(o,t,null)}return n}}function S(e,t){return Array.from(e.values()).map(e=>{let{template:n,context:o}=e;return n.unmount(o,t,!0)})}const j=Object.seal({node:null,evaluate:null,parent:null,isTemplateTag:!1,placeholder:null,template:null,mount(e,t){return this.parent.insertBefore(this.placeholder,this.node),this.parent.removeChild(this.node),this.update(e,t)},update(e,t){const n=!!this.evaluate(e),o=!this.value&&n,r=this.value&&!n,i=()=>{const n=this.node.cloneNode();this.parent.insertBefore(n,this.placeholder),this.template=this.template.clone(),this.template.mount(n,e,t)};switch(!0){case o:i();break;case r:this.unmount(e);break;default:n&&this.template.update(e,t)}return this.value=n,this},unmount(e,t){return this.template.unmount(e,t,!0),this}});const C=0;var x={ATTRIBUTE:C,EVENT:1,TEXT:2,VALUE:3};function _(e){return"object"==typeof e}const I="removeAttribute",L="setAttribute";function P(e,t,n,o){let{name:r}=t;r?((function(e){return"boolean"==typeof e}(n)||_(n))&&(e[r]=n),e[function(e){return M(e)||!1===e||""===e||_(e)?I:L}(n)](r,function(e,t){return!0===t?e:t}(r,n))):n?function(e,t){Object.entries(t).forEach(t=>{let[n,o]=t;return P(e,{name:n},o)})}(e,n):o&&function(e,t){Object.keys(t).forEach(t=>e.removeAttribute(t))}(e,o)}const U=/^on/;function D(e){return M(e)?"":e}var q={[C]:P,1:function(e,t,n,o){let{name:r}=t;const i=r.replace(U,"");return o&&e.removeEventListener(i,o),n&&e.addEventListener(i,n,!1),n},2:function(e,t,n){let{childNodeIndex:o}=t;const r=e.childNodes[o],i=D(n);if(r.nodeType===Node.COMMENT_NODE){const t=document.createTextNode(i);e.replaceChild(t,r)}else r.data=D(i)},3:function(e,t,n){e.value=n}};const B=Object.seal({node:null,value:null,mount(e){return this.value=this.evaluate(e),k(this,this.value),this},update(e){const t=this.evaluate(e);return this.value!==t&&(k(this,t),this.value=t),this},unmount(){return 1===this.type&&k(this,null),this}});function k(e,t){return q[e.type](e.node,e,t,e.value)}function H(e,t){return Object.assign({},B,{},t,{node:e})}const $=Object.seal({node:null,name:null,template:null,mount(e,t){const n=!!e.slots&&e.slots.find(e=>{let{id:t}=e;return t===this.name}),{parentNode:o}=this.node;return this.template=n&&G(n.html,n.bindings).createDOM(o),this.template&&(this.template.mount(this.node,t),function e(t){t.firstChild&&(t.parentNode.insertBefore(t.firstChild,t),e(t))}(this.node)),o.removeChild(this.node),this},update(e,t){return this.template&&t&&this.template.update(t),this},unmount(e,t,n){return this.template&&this.template.unmount(t,null,n),this}});function F(e){return e.reduce((e,t)=>{let{bindings:n}=t;return e.concat(n)},[])}const R=Object.seal({node:null,evaluate:null,name:null,slots:null,tag:null,attributes:null,getComponent:null,mount(e){return this.update(e)},update(e,t){const n=this.evaluate(e);return n===this.name?this.tag.update(e):(this.unmount(e,t,!0),this.name=n,this.tag=function(e,t,n){return void 0===t&&(t=[]),void 0===n&&(n=[]),e?e({slots:t,attributes:n}):G(function(e){return e.reduce((e,t)=>e+t.html,"")}(t),[...F(t),{expressions:n.map(e=>Object.assign({type:C},e))}])}(this.getComponent(n),this.slots,this.attributes),this.tag.mount(this.node,e)),this},unmount(e,t,n){return this.tag&&this.tag.unmount(n),this}});var Y={1:function(e,t){let{evaluate:n,template:o}=t;return Object.assign({},j,{node:e,evaluate:n,parent:e.parentNode,placeholder:document.createTextNode(""),template:o.createDOM(e)})},[h]:function(e,t){let{expressions:n}=t;return Object.assign({},(o=n.map(t=>H(e,t)),["mount","update","unmount"].reduce((e,t)=>Object.assign({},e,{[t]:e=>o.map(n=>n[t](e))&&r}),{})));var o,r},0:function(e,t){let{evaluate:n,condition:o,itemName:r,indexName:i,getKey:s,template:a}=t;const u=document.createTextNode(""),l=e.parentNode,c=e.cloneNode();return l.insertBefore(u,e),l.removeChild(e),Object.assign({},A,{childrenMap:new Map,node:e,root:c,condition:o,evaluate:n,isTemplateTag:T(c),template:a.createDOM(e),getKey:s,indexName:i,itemName:r,placeholder:u})},3:function(e,t){let{evaluate:n,getComponent:o,slots:r,attributes:i}=t;return Object.assign({},R,{node:e,evaluate:n,slots:r,attributes:i,getComponent:o})},4:function(e,t){let{name:n}=t;return Object.assign({},$,{node:e,name:n})}};function K(e){const t=e.ownerSVGElement;return!!t||null===t}function Q(e,t){return K(e)?function(e,t){return t.ownerDocument.importNode((new window.DOMParser).parseFromString(`${e}`,"application/xml").documentElement,!0)}(t,e):function(e,t){const n=T(t)?t:document.createElement("template");return n.innerHTML=e,n.content}(t,e)}function z(e,t){switch(!0){case K(e):!function e(t,n){t.firstChild&&(n.appendChild(t.firstChild),e(t,n))}(t,e);break;case T(e):e.parentNode.replaceChild(t,e);break;default:e.appendChild(t)}}const V=Object.freeze({bindings:null,bindingsData:null,html:null,isTemplateTag:!1,fragment:null,children:null,dom:null,el:null,createDOM(e){return this.dom=this.dom||function(e,t){return t&&("string"==typeof t?Q(e,t):t)}(e,this.html),this},mount(e,t,n,o){if(void 0===o&&(o={}),!e)throw new Error("Please provide DOM node to mount properly your template");this.el&&this.unmount(t);const{fragment:r,children:i,avoidDOMInjection:s}=o,{parentNode:a}=i?i[0]:e;return this.isTemplateTag=T(e),this.createDOM(e),this.dom&&(this.fragment=r||this.dom.cloneNode(!0)),this.el=this.isTemplateTag?a:e,this.children=this.isTemplateTag?i||Array.from(this.fragment.childNodes):null,!s&&this.fragment&&z(e,this.fragment),this.bindings=this.bindingsData.map(e=>(function(e,t){const{selector:n,type:o,redundantAttribute:r,expressions:i}=t,s=n?e.querySelector(n):e;return r&&s.removeAttribute(r),(Y[o]||Y[h])(s,Object.assign({},t,{expressions:i||[]}))})(this.el,e)),this.bindings.forEach(e=>e.mount(t,n)),this},update(e,t){return this.bindings.forEach(n=>n.update(e,t)),this},unmount(e,t,n){if(this.el){switch(this.bindings.forEach(o=>o.unmount(e,t,n)),!0){case!0===this.isTemplateTag&&null!==n:d(this.children);break;case!0===n&&null!==this.el.parentNode:this.el.parentNode.removeChild(this.el);break;case null!==n:d(this.el.childNodes)}this.el=null}return this},clone(){return Object.assign({},this,{el:null})}});function G(e,t){return void 0===t&&(t=[]),Object.assign({},V,{html:e,bindingsData:t})}function J(e){return typeof e==="function"}function X(e){throw new Error(e)}function Z(e){return J(e)?e.prototype&&e.prototype.constructor?new e:e():e}function W(e){return e.replace(/-(\w)/g,(e,t)=>t.toUpperCase())}function ee(){return this}function te(e,t,n,o){return void 0===o&&(o={}),Object.defineProperty(e,t,Object.assign({value:n,enumerable:!1,writable:!1,configurable:!0},o)),e}function ne(e,t,n){return Object.entries(t).forEach(t=>{let[o,r]=t;te(e,o,r,n)}),e}function oe(e){return Array.isArray(e)?e:/^\[object (HTMLCollection|NodeList|Object)\]$/.test(Object.prototype.toString.call(e))&&"number"==typeof e.length?Array.from(e):[e]}const re=e=>1===e.length?e[0]:e;function ie(e,t,n){const o="object"==typeof t?t:{[t]:n},r=Object.keys(o);return oe(e).forEach(e=>{r.forEach(t=>e.setAttribute(t,o[t]))}),e}function se(e,t){return function(e,t,n){const o="string"==typeof t?[t]:t;return re(oe(e).map(e=>re(o.map(t=>e[n](t)))))}(e,t,"getAttribute")}function ae(e){return se(e,s)||e.tagName.toLowerCase()}function ue(e,t){return oe("string"==typeof e?(t||document).querySelectorAll(e):e)}const le=new Map,ce=(e=>()=>e||(ie(e=ue("style[riot]")[0]||document.createElement("style"),"type","text/css"),e.parentNode||document.head.appendChild(e),e))();var de={CSS_BY_NAME:le,add(e,t){return le.has(e)||(le.set(e,t),this.inject()),this},inject(){return ce().innerHTML=[...le.values()].join("\n"),this},remove(e){return le.has(e)&&(le.delete(e),this.inject()),this}};const he=Object.freeze({$(e){return ue(e,this.root)[0]},$$(e){return ue(e,this.root)}}),me=Object.freeze({shouldUpdate:ee,onBeforeMount:ee,onMounted:ee,onBeforeUpdate:ee,onUpdated:ee,onBeforeUnmount:ee,onUnmounted:ee}),fe={update:ee,mount:ee,unmount:ee,clone:ee,createDOM:ee};function pe(e){let{css:t,template:n,exports:r,name:i}=e;const s=n?function(e,t){return e(G,x,m,e=>t[e]||o.get(e))}(n,r?function(e){void 0===e&&(e={});return Object.entries(Z(e)).reduce((e,t)=>{let[n,o]=t;return e[function(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}(n)]=pe(o),e},{})}(r.components):{}):fe;return e=>{let{slots:n,attributes:o,props:a}=e;const u=Z(r)||{},l=ge({css:t,template:s,componentAPI:u,name:i})({slots:n,attributes:o,props:a});return{mount:(e,t,n)=>l.mount(e,n,t),update:(e,t)=>l.update(t,e),unmount:e=>l.unmount(e)}}}function ge(e){let{css:t,template:n,componentAPI:o,name:r}=e;return t&&r&&de.add(r,t),function e(t){for(var n=arguments.length,o=new Array(n>1?n-1:0),r=1;r{let[t,n]=e;i[t]||(i[t]=n)}),i),Object.assign({slots:null,root:null},he,{name:r,css:t,template:n})));var i,s}function be(e,t){return void 0===t&&(t=[]),Object.assign({},function(e){return Array.from(e.attributes).reduce((e,t)=>(e[W(t.name)]=t.value,e),{})}(e),{},t.reduce((e,t)=>{const{value:n,type:o}=t;switch(!0){case!t.name&&o===x.ATTRIBUTE:return Object.assign({},e,{},n);case o===x.VALUE:e[a]=t.value;break;default:e[W(t.name)]=t.value}return e},{}))}function ve(e,t){return Object.assign({},e,{},Z(t))}function ye(e,t){let{slots:n,attributes:o,props:s}=t;const a=Z(s);return c=function(e){return[...i].reduce((e,t)=>t(e)||e,e)}(ne(Object.create(e),{mount(t,i,s){return void 0===i&&(i={}),this[u]=function(e,t){void 0===t&&(t=[]);const n=t.map(t=>H(e,t)),o={},r=e=>t=>(n.forEach(n=>n[e](t)),o);return Object.assign(o,{expressions:n,mount:r("mount"),update:r("update"),unmount:r("unmount")})}(t,o).mount(s),this.props=Object.freeze(Object.assign({},a,{},be(t,this[u].expressions))),this.state=ve(this.state,i),this[l]=this.template.createDOM(t).clone(),t[r]=this,e.name&&function(e,t){ae(e)!==t&&ie(e,"is",t)}(t,e.name),te(this,"root",t),te(this,"slots",n),this.onBeforeMount(this.props,this.state),this[l].mount(t,this,s),this.onMounted(this.props,this.state),this},update(e,t){void 0===e&&(e={}),t&&this[u].update(t);const n=be(this.root,this[u].expressions);if(!1!==this.shouldUpdate(n,this.props))return this.props=Object.freeze(Object.assign({},a,{},n)),this.state=ve(this.state,e),this.onBeforeUpdate(this.props,this.state),this[l].update(this,t),this.onUpdated(this.props,this.state),this},unmount(e){return this.onBeforeUnmount(this.props,this.state),this[u].unmount(),this[l].unmount(this,{},null===e?null:!e),this.onUnmounted(this.props,this.state),this}})),Object.keys(e).filter(t=>J(e[t])).forEach(e=>{c[e]=c[e].bind(c)}),c;var c}const{DOM_COMPONENT_INSTANCE_PROPERTY:we,COMPONENTS_IMPLEMENTATION_MAP:Oe,PLUGINS_SET:Ee}=c;var Me,Te,Ae=n(0),Ne=n.n(Ae);!function(e,t){let{css:n,template:o,exports:r}=t;Oe.has(e)&&X(`The component "${e}" was already registered`),Oe.set(e,pe({name:e,css:n,template:o,exports:r}))}("tiny-one-page",{css:null,exports:{onBeforeMount(){this.content=this.root.innerHTML,this.root.innerHTML=""},onMounted(){this.$(".tiny-one-page__inner").innerHTML=this.content,this.scroll=new Ne.a('.tiny-one-page__inner a[href*="#"]'),window.addEventListener("scroll",this.handleScroll.bind(this),!1),window.location.hash?this.$(".tiny-one-page__inner a[href$='"+window.location.hash+"']").click():this.addClass(this.$$(".tiny-one-page__inner a")[0])},addClass(e){e.parentElement.classList.add("current")},removeClass(e){e.parentElement.classList.remove("current")},handleScroll(e){const t=this.$$(".tiny-one-page__inner a");let n=void 0;t.forEach(function(e,o){let r=document.querySelector(e.hash),i=void 0,s=r.offsetTop;t[o+1]&&(i=document.querySelector(t[o+1].hash)),0===o&&(s=0),!n&&s<=window.pageYOffset&&s+r.offsetHeight>window.pageYOffset&&(n=r,i&&swindow.pageYOffset&&i.offsetTop
',[])},name:"tiny-one-page"}),ue("tiny-one-page").map(e=>(function(e,t,n){const r=n||ae(e);return o.has(r)||X(`The component named "${r}" was never registered`),o.get(r)({props:t}).mount(e)})(e,Me,Te))},function(e,t){}]); \ No newline at end of file +!function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s=1)}([function(e,t,n){(function(n){var o,r;window.Element&&!Element.prototype.closest&&(Element.prototype.closest=function(e){var t,n=(this.document||this.ownerDocument).querySelectorAll(e),o=this;do{for(t=n.length;0<=--t&&n.item(t)!==o;);}while(t<0&&(o=o.parentElement));return o}),function(){function e(e,t){t=t||{bubbles:!1,cancelable:!1,detail:void 0};var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),n}"function"!=typeof window.CustomEvent&&(e.prototype=window.Event.prototype,window.CustomEvent=e)}(),function(){for(var e=0,t=["ms","moz","webkit","o"],n=0;nb.durationMax?b.durationMax:b.durationMin&&v=S)return h.cancelScroll(!0),a=n,u=m,0===(r=o)&&document.body.focus(),u||(r.focus(),document.activeElement!==r&&(r.setAttribute("tabindex","-1"),r.focus(),r.style.outline="none"),e.scrollTo(0,a)),i("scrollStop",l,o,s),!(d=y=null)}(O,A)||(d=e.requestAnimationFrame(x),y=t)};0===e.pageYOffset&&e.scrollTo(0,0),E=o,M=l,m||history.pushState&&M.updateURL&&history.pushState({smoothScroll:JSON.stringify(M),anchor:E.id},document.title,E===document.documentElement?"#top":"#"+E.id),"matchMedia"in e&&e.matchMedia("(prefers-reduced-motion)").matches?e.scrollTo(0,Math.floor(A)):(i("scrollStart",l,o,s),h.cancelScroll(!0),e.requestAnimationFrame(x))}}},m=function(t){if(!t.defaultPrevented&&!(0!==t.button||t.metaKey||t.ctrlKey||t.shiftKey)&&"closest"in t.target&&(l=t.target.closest(s))&&"a"===l.tagName.toLowerCase()&&!t.target.closest(u.ignore)&&l.hostname===e.location.hostname&&l.pathname===e.location.pathname&&/#/.test(l.href)){var n,r=o(l.hash);if("#"===r){if(!u.topOnEmptyHash)return;n=document.documentElement}else n=document.querySelector(r);(n=n||"#top"!==r?n:document.documentElement)&&(t.preventDefault(),function(t){if(history.replaceState&&t.updateURL&&!history.state){var n=e.location.hash;n=n||"",history.replaceState({smoothScroll:JSON.stringify(t),anchor:n||e.pageYOffset},document.title,n||e.location.href)}}(u),h.animateScroll(n,l))}},f=function(e){if(null!==history.state&&history.state.smoothScroll&&history.state.smoothScroll===JSON.stringify(u)){var t=history.state.anchor;"string"==typeof t&&t&&!(t=document.querySelector(o(history.state.anchor)))||h.animateScroll(t,null,{updateURL:!1})}};return h.destroy=function(){u&&(document.removeEventListener("click",m,!1),e.removeEventListener("popstate",f,!1),h.cancelScroll(),d=c=l=u=null)},function(){if(!("querySelector"in document&&"addEventListener"in e&&"requestAnimationFrame"in e&&"closest"in e.Element.prototype))throw"Smooth Scroll: This browser does not support the required JavaScript methods and browser APIs.";h.destroy(),u=n(t,a||{}),c=u.header?document.querySelector(u.header):null,document.addEventListener("click",m,!1),u.updateURL&&u.popstate&&e.addEventListener("popstate",f,!1)}(),h}}(r)}.apply(t,[]))||(e.exports=o)}).call(this,n(2))},function(e,t,n){n(3),e.exports=n(4)},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";n.r(t);const o=new Map,r=Symbol("riot-component"),i=new Set,s="is",a="value",u=Symbol("attributes"),l=Symbol("template");var c=Object.freeze({COMPONENTS_IMPLEMENTATION_MAP:o,DOM_COMPONENT_INSTANCE_PROPERTY:r,PLUGINS_SET:i,IS_DIRECTIVE:s,VALUE_ATTRIBUTE:a,ATTRIBUTES_KEY_SYMBOL:u,TEMPLATE_KEY_SYMBOL:l});function d(e){Array.from(e).forEach(e=>e.parentNode&&e.parentNode.removeChild(e))}const h=2;var m={EACH:0,IF:1,SIMPLE:h,TAG:3,SLOT:4};const{indexOf:f}=[],p=(e,t,n,o,r,i)=>{const s="selectedIndex"in t;let a=s;for(;oe==t,b=e=>e,v=(e,t,n,o,r,i,s)=>{const a=i-r;if(a<1)return-1;for(;n-t>=a;){let a=t,u=r;for(;an{if(r-o<2)t.removeChild(e(n[o],-1));else{const i=t.ownerDocument.createRange();i.setStartBefore(e(n[o],-1)),i.setEndAfter(e(n[r-1],-1)),i.deleteContents()}},O=(e,t,n)=>{let o=1,r=t;for(;o>>0;n{((e,t,n,o,r,i,s,a,u)=>{const l=new Map,c=e.length;let d=s,h=0;for(;h{const a=n+i,u=[];let l,c,d,h,m,f,p;e:for(l=0;l<=a;l++){if(l>50)return null;for(p=l-1,m=l?u[l-1]:[0,0],f=u[l]=[],c=-l;c<=l;c+=2){for(d=(h=c===-l||c!==l&&m[p+c-1]=0;l--){for(;h>0&&d>0&&s(o[r+h-1],e[t+d-1]);)g[b--]=0,h--,d--;if(!l)break;p=l-1,m=l?u[l-1]:[0,0],(c=h-d)===-l||c!==l&&m[p+c-1]{let u=0,l=os;)--u;l=a+o-u;const m=Array(l);let f=c[u];for(--n;f;){const{newi:e,oldi:t}=f;for(;n>e;)m[--l]=1,--n;for(;s>t;)m[--l]=-1,--s;m[--l]=0,--n,--s,f=f.prev}for(;n>=t;)m[--l]=1,--n;for(;s>=i;)m[--l]=-1,--s;return m})(n,o,r,i,s,a,u,l),e,t,n,o,s,a,c,h)};function M(e){return null==e}function T(e){return!M(e.content)}const A=Object.seal({childrenMap:null,node:null,root:null,condition:null,evaluate:null,template:null,isTemplateTag:!1,nodes:[],getKey:null,indexName:null,itemName:null,afterPlaceholder:null,placeholder:null,mount(e,t){return this.update(e,t)},update(e,t){const{placeholder:n}=this,o=this.evaluate(e),r=o?Array.from(o):[],i=n.parentNode,{newChildrenMap:s,batches:a,futureNodes:u}=function(e,t,n,o){const{condition:r,template:i,childrenMap:s,itemName:a,getKey:u,indexName:l,root:c,isTemplateTag:d}=o,h=new Map,m=[],f=[];return e.forEach((e,o)=>{const p=function(e,t){let{itemName:n,indexName:o,index:r,item:i}=t;e[n]=i,o&&(e[o]=r);return e}(Object.create(t),{itemName:a,indexName:l,index:o,item:e}),g=u?u(p):o,b=s.get(g);if(function(e,t){return!!e&&!1===Boolean(e(t))}(r,p))return;const v=b?b.template:i.clone(),y=b?v.el:c.cloneNode(),w=!b,O=d&&w?function(e){const t=e.dom.cloneNode(!0);return{avoidDOMInjection:!0,fragment:t,children:Array.from(t.childNodes)}}(v):{};w?m.push(()=>v.mount(y,p,n,O)):v.update(p,n),d?f.push(...O.children||v.children):f.push(y),s.delete(g),h.set(g,{template:v,context:p,index:o})}),{newChildrenMap:h,batches:m,futureNodes:f}}(r,e,t,this);return u.length?((e,t,n,o)=>{o||(o={});const r=o.compare||g,i=o.node||b,s=null==o.before?null:i(o.before,0),a=t.length;let u=a,l=0,c=n.length,d=0;for(;l{for(;oe()),this.childrenMap=s,this.nodes=u,this},unmount(e,t){return S(this.childrenMap,t),this.childrenMap=new Map,this.nodes=[],this}});function N(e,t){return(n,o)=>{if(o<0){const{template:n,context:o}=e.pop();n.unmount(o,t,null)}return n}}function S(e,t){return Array.from(e.values()).map(e=>{let{template:n,context:o}=e;return n.unmount(o,t,!0)})}const j=Object.seal({node:null,evaluate:null,parent:null,isTemplateTag:!1,placeholder:null,template:null,mount(e,t){return this.parent.insertBefore(this.placeholder,this.node),this.parent.removeChild(this.node),this.update(e,t)},update(e,t){const n=!!this.evaluate(e),o=!this.value&&n,r=this.value&&!n,i=()=>{const n=this.node.cloneNode();this.parent.insertBefore(n,this.placeholder),this.template=this.template.clone(),this.template.mount(n,e,t)};switch(!0){case o:i();break;case r:this.unmount(e);break;default:n&&this.template.update(e,t)}return this.value=n,this},unmount(e,t){return this.template.unmount(e,t,!0),this}});const C=0;var x={ATTRIBUTE:C,EVENT:1,TEXT:2,VALUE:3};function _(e){return"object"==typeof e}const I="removeAttribute",L="setAttribute";function P(e,t,n,o){let{name:r}=t;r?((function(e){return"boolean"==typeof e}(n)||_(n))&&(e[r]=n),e[function(e){return M(e)||!1===e||""===e||_(e)?I:L}(n)](r,function(e,t){return!0===t?e:t}(r,n))):n?function(e,t){Object.entries(t).forEach(t=>{let[n,o]=t;return P(e,{name:n},o)})}(e,n):o&&function(e,t){Object.keys(t).forEach(t=>e.removeAttribute(t))}(e,o)}const U=/^on/;function D(e){return M(e)?"":e}var q={[C]:P,1:function(e,t,n,o){let{name:r}=t;const i=r.replace(U,"");return o&&e.removeEventListener(i,o),n&&e.addEventListener(i,n,!1),n},2:function(e,t,n){let{childNodeIndex:o}=t;const r=e.childNodes[o],i=D(n);if(r.nodeType===Node.COMMENT_NODE){const t=document.createTextNode(i);e.replaceChild(t,r)}else r.data=D(i)},3:function(e,t,n){e.value=n}};const B=Object.seal({node:null,value:null,mount(e){return this.value=this.evaluate(e),H(this,this.value),this},update(e){const t=this.evaluate(e);return this.value!==t&&(H(this,t),this.value=t),this},unmount(){return 1===this.type&&H(this,null),this}});function H(e,t){return q[e.type](e.node,e,t,e.value)}function k(e,t){return Object.assign({},B,{},t,{node:e})}const $=Object.seal({node:null,name:null,template:null,mount(e,t){const n=!!e.slots&&e.slots.find(e=>{let{id:t}=e;return t===this.name}),{parentNode:o}=this.node;return this.template=n&&G(n.html,n.bindings).createDOM(o),this.template&&(this.template.mount(this.node,t),function e(t){t.firstChild&&(t.parentNode.insertBefore(t.firstChild,t),e(t))}(this.node)),o.removeChild(this.node),this},update(e,t){return this.template&&t&&this.template.update(t),this},unmount(e,t,n){return this.template&&this.template.unmount(t,null,n),this}});function F(e){return e.reduce((e,t)=>{let{bindings:n}=t;return e.concat(n)},[])}const R=Object.seal({node:null,evaluate:null,name:null,slots:null,tag:null,attributes:null,getComponent:null,mount(e){return this.update(e)},update(e,t){const n=this.evaluate(e);return n===this.name?this.tag.update(e):(this.unmount(e,t,!0),this.name=n,this.tag=function(e,t,n){return void 0===t&&(t=[]),void 0===n&&(n=[]),e?e({slots:t,attributes:n}):G(function(e){return e.reduce((e,t)=>e+t.html,"")}(t),[...F(t),{expressions:n.map(e=>Object.assign({type:C},e))}])}(this.getComponent(n),this.slots,this.attributes),this.tag.mount(this.node,e)),this},unmount(e,t,n){return this.tag&&this.tag.unmount(n),this}});var Y={1:function(e,t){let{evaluate:n,template:o}=t;return Object.assign({},j,{node:e,evaluate:n,parent:e.parentNode,placeholder:document.createTextNode(""),template:o.createDOM(e)})},[h]:function(e,t){let{expressions:n}=t;return Object.assign({},(o=n.map(t=>k(e,t)),["mount","update","unmount"].reduce((e,t)=>Object.assign({},e,{[t]:e=>o.map(n=>n[t](e))&&r}),{})));var o,r},0:function(e,t){let{evaluate:n,condition:o,itemName:r,indexName:i,getKey:s,template:a}=t;const u=document.createTextNode(""),l=e.parentNode,c=e.cloneNode();return l.insertBefore(u,e),l.removeChild(e),Object.assign({},A,{childrenMap:new Map,node:e,root:c,condition:o,evaluate:n,isTemplateTag:T(c),template:a.createDOM(e),getKey:s,indexName:i,itemName:r,placeholder:u})},3:function(e,t){let{evaluate:n,getComponent:o,slots:r,attributes:i}=t;return Object.assign({},R,{node:e,evaluate:n,slots:r,attributes:i,getComponent:o})},4:function(e,t){let{name:n}=t;return Object.assign({},$,{node:e,name:n})}};function K(e){const t=e.ownerSVGElement;return!!t||null===t}function Q(e,t){return K(e)?function(e,t){return t.ownerDocument.importNode((new window.DOMParser).parseFromString(`${e}`,"application/xml").documentElement,!0)}(t,e):function(e,t){const n=T(t)?t:document.createElement("template");return n.innerHTML=e,n.content}(t,e)}function z(e,t){switch(!0){case K(e):!function e(t,n){t.firstChild&&(n.appendChild(t.firstChild),e(t,n))}(t,e);break;case T(e):e.parentNode.replaceChild(t,e);break;default:e.appendChild(t)}}const V=Object.freeze({bindings:null,bindingsData:null,html:null,isTemplateTag:!1,fragment:null,children:null,dom:null,el:null,createDOM(e){return this.dom=this.dom||function(e,t){return t&&("string"==typeof t?Q(e,t):t)}(e,this.html),this},mount(e,t,n,o){if(void 0===o&&(o={}),!e)throw new Error("Please provide DOM node to mount properly your template");this.el&&this.unmount(t);const{fragment:r,children:i,avoidDOMInjection:s}=o,{parentNode:a}=i?i[0]:e;return this.isTemplateTag=T(e),this.createDOM(e),this.dom&&(this.fragment=r||this.dom.cloneNode(!0)),this.el=this.isTemplateTag?a:e,this.children=this.isTemplateTag?i||Array.from(this.fragment.childNodes):null,!s&&this.fragment&&z(e,this.fragment),this.bindings=this.bindingsData.map(e=>(function(e,t){const{selector:n,type:o,redundantAttribute:r,expressions:i}=t,s=n?e.querySelector(n):e;return r&&s.removeAttribute(r),(Y[o]||Y[h])(s,Object.assign({},t,{expressions:i||[]}))})(this.el,e)),this.bindings.forEach(e=>e.mount(t,n)),this},update(e,t){return this.bindings.forEach(n=>n.update(e,t)),this},unmount(e,t,n){if(this.el){switch(this.bindings.forEach(o=>o.unmount(e,t,n)),!0){case!0===this.isTemplateTag&&null!==n:d(this.children);break;case!0===n&&null!==this.el.parentNode:this.el.parentNode.removeChild(this.el);break;case null!==n:d(this.el.childNodes)}this.el=null}return this},clone(){return Object.assign({},this,{el:null})}});function G(e,t){return void 0===t&&(t=[]),Object.assign({},V,{html:e,bindingsData:t})}function J(e){return typeof e==="function"}function X(e){throw new Error(e)}function Z(e){return J(e)?e.prototype&&e.prototype.constructor?new e:e():e}function W(e){return e.replace(/-(\w)/g,(e,t)=>t.toUpperCase())}function ee(){return this}function te(e,t,n,o){return void 0===o&&(o={}),Object.defineProperty(e,t,Object.assign({value:n,enumerable:!1,writable:!1,configurable:!0},o)),e}function ne(e,t,n){return Object.entries(t).forEach(t=>{let[o,r]=t;te(e,o,r,n)}),e}function oe(e){return Array.isArray(e)?e:/^\[object (HTMLCollection|NodeList|Object)\]$/.test(Object.prototype.toString.call(e))&&"number"==typeof e.length?Array.from(e):[e]}const re=e=>1===e.length?e[0]:e;function ie(e,t,n){const o="object"==typeof t?t:{[t]:n},r=Object.keys(o);return oe(e).forEach(e=>{r.forEach(t=>e.setAttribute(t,o[t]))}),e}function se(e,t){return function(e,t,n){const o="string"==typeof t?[t]:t;return re(oe(e).map(e=>re(o.map(t=>e[n](t)))))}(e,t,"getAttribute")}function ae(e){return se(e,s)||e.tagName.toLowerCase()}function ue(e,t){return oe("string"==typeof e?(t||document).querySelectorAll(e):e)}const le=new Map,ce=(e=>()=>e||(ie(e=ue("style[riot]")[0]||document.createElement("style"),"type","text/css"),e.parentNode||document.head.appendChild(e),e))();var de={CSS_BY_NAME:le,add(e,t){return le.has(e)||(le.set(e,t),this.inject()),this},inject(){return ce().innerHTML=[...le.values()].join("\n"),this},remove(e){return le.has(e)&&(le.delete(e),this.inject()),this}};const he=Object.freeze({$(e){return ue(e,this.root)[0]},$$(e){return ue(e,this.root)}}),me=Object.freeze({shouldUpdate:ee,onBeforeMount:ee,onMounted:ee,onBeforeUpdate:ee,onUpdated:ee,onBeforeUnmount:ee,onUnmounted:ee}),fe={update:ee,mount:ee,unmount:ee,clone:ee,createDOM:ee};function pe(e){let{css:t,template:n,exports:r,name:i}=e;const s=n?function(e,t){return e(G,x,m,e=>t[e]||o.get(e))}(n,r?function(e){void 0===e&&(e={});return Object.entries(Z(e)).reduce((e,t)=>{let[n,o]=t;return e[function(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}(n)]=pe(o),e},{})}(r.components):{}):fe;return e=>{let{slots:n,attributes:o,props:a}=e;const u=Z(r)||{},l=ge({css:t,template:s,componentAPI:u,name:i})({slots:n,attributes:o,props:a});return{mount:(e,t,n)=>l.mount(e,n,t),update:(e,t)=>l.update(t,e),unmount:e=>l.unmount(e)}}}function ge(e){let{css:t,template:n,componentAPI:o,name:r}=e;return t&&r&&de.add(r,t),function e(t){for(var n=arguments.length,o=new Array(n>1?n-1:0),r=1;r{let[t,n]=e;i[t]||(i[t]=n)}),i),Object.assign({slots:null,root:null},he,{name:r,css:t,template:n})));var i,s}function be(e,t){return void 0===t&&(t=[]),Object.assign({},function(e){return Array.from(e.attributes).reduce((e,t)=>(e[W(t.name)]=t.value,e),{})}(e),{},t.reduce((e,t)=>{const{value:n,type:o}=t;switch(!0){case!t.name&&o===x.ATTRIBUTE:return Object.assign({},e,{},n);case o===x.VALUE:e[a]=t.value;break;default:e[W(t.name)]=t.value}return e},{}))}function ve(e,t){return Object.assign({},e,{},Z(t))}function ye(e,t){let{slots:n,attributes:o,props:s}=t;const a=Z(s);return c=function(e){return[...i].reduce((e,t)=>t(e)||e,e)}(ne(Object.create(e),{mount(t,i,s){return void 0===i&&(i={}),this[u]=function(e,t){void 0===t&&(t=[]);const n=t.map(t=>k(e,t)),o={},r=e=>t=>(n.forEach(n=>n[e](t)),o);return Object.assign(o,{expressions:n,mount:r("mount"),update:r("update"),unmount:r("unmount")})}(t,o).mount(s),this.props=Object.freeze(Object.assign({},a,{},be(t,this[u].expressions))),this.state=ve(this.state,i),this[l]=this.template.createDOM(t).clone(),t[r]=this,e.name&&function(e,t){ae(e)!==t&&ie(e,"is",t)}(t,e.name),te(this,"root",t),te(this,"slots",n),this.onBeforeMount(this.props,this.state),this[l].mount(t,this,s),this.onMounted(this.props,this.state),this},update(e,t){void 0===e&&(e={}),t&&this[u].update(t);const n=be(this.root,this[u].expressions);if(!1!==this.shouldUpdate(n,this.props))return this.props=Object.freeze(Object.assign({},a,{},n)),this.state=ve(this.state,e),this.onBeforeUpdate(this.props,this.state),this[l].update(this,t),this.onUpdated(this.props,this.state),this},unmount(e){return this.onBeforeUnmount(this.props,this.state),this[u].unmount(),this[l].unmount(this,{},null===e?null:!e),this.onUnmounted(this.props,this.state),this}})),Object.keys(e).filter(t=>J(e[t])).forEach(e=>{c[e]=c[e].bind(c)}),c;var c}const{DOM_COMPONENT_INSTANCE_PROPERTY:we,COMPONENTS_IMPLEMENTATION_MAP:Oe,PLUGINS_SET:Ee}=c;var Me,Te,Ae=n(0),Ne=n.n(Ae);!function(e,t){let{css:n,template:o,exports:r}=t;Oe.has(e)&&X(`The component "${e}" was already registered`),Oe.set(e,pe({name:e,css:n,template:o,exports:r}))}("tiny-one-page",{css:null,exports:{onBeforeMount(){this.content=this.root.innerHTML,this.root.innerHTML=""},onMounted(){this.$(".tiny-one-page__inner").innerHTML=this.content,this.scroll=new Ne.a('.tiny-one-page__inner a[href*="#"]'),window.addEventListener("scroll",this.handleScroll.bind(this),!1),window.location.hash?this.$(".tiny-one-page__inner a[href$='"+window.location.hash+"']").click():this.addClass(this.$$(".tiny-one-page__inner a")[0])},addClass(e){e.parentElement.classList.add("current")},removeClass(e){e.parentElement.classList.remove("current")},handleScroll(e){const t=this.$$(".tiny-one-page__inner a");let n=void 0;t.forEach(function(e,o){let r=document.querySelector(e.hash),i=void 0;r.offsetTop;t[o+1]&&(i=document.querySelector(t[o+1].hash)),!n&&r.offsetTop-window.innerHeight/2<=window.pageYOffset+25&&r.offsetTop+r.offsetHeight-window.innerHeight/2>window.pageYOffset&&(n=r),this.removeClass(e)}.bind(this)),this.addClass(this.$(".tiny-one-page__inner a[href$='"+n.id+"']"))}},template:function(e,t,n,o){return e('
',[])},name:"tiny-one-page"}),ue("tiny-one-page").map(e=>(function(e,t,n){const r=n||ae(e);return o.has(r)||X(`The component named "${r}" was never registered`),o.get(r)({props:t}).mount(e)})(e,Me,Te))},function(e,t){}]); \ No newline at end of file diff --git a/src/TinyOnePage.riot b/src/TinyOnePage.riot index d945c82..bdd4f94 100644 --- a/src/TinyOnePage.riot +++ b/src/TinyOnePage.riot @@ -102,6 +102,9 @@ // get elements const elements = this.$$('.tiny-one-page__inner a'); + // @TODO check offset + const offset = 25; + // if found let hasFound = false; @@ -124,18 +127,11 @@ next = document.querySelector(elements[index + 1].hash); } - if (index === 0) { - offsetTop = 0; - } - // check if element is visible - if (!result && ((offsetTop <= window.pageYOffset) && (offsetTop + target.offsetHeight) > window.pageYOffset)) { + if (!result && + (target.offsetTop - (window.innerHeight / 2)) <= (window.pageYOffset + offset) && + (target.offsetTop + target.offsetHeight) - (window.innerHeight / 2) > window.pageYOffset) { result = target; - - // check if the next element is showing up - if (next && offsetTop < window.pageYOffset && next.offsetTop > window.pageYOffset && next.offsetTop < (window.pageYOffset + (window.innerHeight / 2))) { - result = next; - } } // remove class from each element @@ -143,10 +139,7 @@ }.bind(this)); - // @TODO small workaround to ignore gaps between elements where no one found - if (result) { - this.addClass(this.$(".tiny-one-page__inner a[href$='" + result.id + "']")); - } + this.addClass(this.$(".tiny-one-page__inner a[href$='" + result.id + "']")); } }