mpa-enhancer
Advanced tools
Comparing version 2.2.5 to 2.2.6
@@ -82,3 +82,9 @@ // @ts-check | ||
let active = (t.q && query(t.q)) || (m.q && query(m.q)) | ||
let active | ||
let elY = | ||
(t.q && (active = query(t.q))) | ||
? t.y | ||
: (m.q && (active = query(m.q))) | ||
? m.y | ||
: 0 | ||
if (!hasAttr(active, 'mpa-skip-focus')) { | ||
@@ -97,3 +103,3 @@ run('focus', active) | ||
+ calculateY(active) | ||
- (t.q && t.y || m.q && m.y || 0) | ||
- elY | ||
}) | ||
@@ -128,2 +134,1 @@ } else { | ||
@@ -161,3 +161,3 @@ // node_modules/idb-keyval/dist/index.js | ||
<!-- This footer should be hidden by default and shown when there are todos --> | ||
<footer id="footer" class="footer ${!count ? "hidden" : ""}}"> | ||
<footer id="footer" mpa-miss="#footer" class="footer ${!count ? "hidden" : ""}}"> | ||
<span class="todo-count"> | ||
@@ -174,3 +174,3 @@ <strong>${"" + activeCount}</strong> item${activeCount === 1 ? "" : "s"} left | ||
<!--Hidden if no completed items are left ↓ --> | ||
$${count - activeCount === 0 ? "" : async_generator_html_default`<form method="post" action="?handler=clear-completed"> | ||
${count - activeCount === 0 ? "" : async_generator_html_default`<form method="post" action="?handler=clear-completed"> | ||
<button id="clear-completed" class="clear-completed">Clear completed</button> | ||
@@ -177,0 +177,0 @@ </form>`} |
{ | ||
"name": "mpa-enhancer", | ||
"version": "2.2.5", | ||
"version": "2.2.6", | ||
"description": "Minimalist JavaScript to make your MPA work that much better", | ||
@@ -5,0 +5,0 @@ "bugs": { |
@@ -72,3 +72,3 @@ # MPA Enhancer | ||
**2.2.2/3/4** | ||
**2.2.2/3/4/6** | ||
@@ -75,0 +75,0 @@ Improved scrolling location. |
@@ -69,3 +69,3 @@ import html from "html-template-tag-stream" | ||
<!-- This footer should be hidden by default and shown when there are todos --> | ||
<footer id="footer" class="footer ${!count ? 'hidden' : ''}}"> | ||
<footer id="footer" mpa-miss="#footer" class="footer ${!count ? 'hidden' : ''}}"> | ||
<span class="todo-count"> | ||
@@ -82,3 +82,3 @@ <strong>${"" + activeCount}</strong> item${activeCount === 1 ? '' : 's'} left | ||
<!--Hidden if no completed items are left ↓ --> | ||
$${ count - activeCount === 0 | ||
${ count - activeCount === 0 | ||
? '' | ||
@@ -85,0 +85,0 @@ : html`<form method="post" action="?handler=clear-completed"> |
@@ -82,3 +82,9 @@ // @ts-check | ||
let active = (t.q && query(t.q)) || (m.q && query(m.q)) | ||
let active | ||
let elY = | ||
(t.q && (active = query(t.q))) | ||
? t.y | ||
: (m.q && (active = query(m.q))) | ||
? m.y | ||
: 0 | ||
if (!hasAttr(active, 'mpa-skip-focus')) { | ||
@@ -97,3 +103,3 @@ run('focus', active) | ||
+ calculateY(active) | ||
- (t.q && t.y || m.q && m.y || 0) | ||
- elY | ||
}) | ||
@@ -100,0 +106,0 @@ } else { |
@@ -1,1 +0,1 @@ | ||
(()=>{let l=document,i=window,o=l.querySelector.bind(l);function c(t,e){return t?.hasAttribute(e)}function d(t,e){return t?.getAttribute(e)}function f(){let t=d(l.body,"mpa-page-name");return t||new URL(l.location.href).pathname.replace(/\/$/,"")}let m=null;i.addEventListener("click",t=>{m=t.target});function s(t){return t?.getBoundingClientRect().top}i.addEventListener("unload",()=>{let t=g()||{},e=new Set(t.__||[]),n=f();c(l.body,"mpa-persist")&&(e.add(n),t.__=Array.from(e));for(let u in Object.keys(t))e.has(u)||u==="__"||delete t[u];let r=l.activeElement,a=r===l.body?m:r,y=d(a?.closest("[mpa-miss]"),"mpa-miss"),q=a?.getAttribute("name");t[n]={y:i.scrollY,a:{t:{y:s(a),q:a?.id&&`#${a.id}`||q&&`[name="${q}"]`},m:{y:s(o(y)),q:y}}},localStorage._mpa=JSON.stringify(t)});function b(){if(o("[autofocus]"))return;let t=g(f());if(!t)return;let{y:e,a:{t:n,m:r}}=t,a=n.q&&o(n.q)||r.q&&o(r.q);c(a,"mpa-skip-focus")||(p("focus",a),p("select",a)),!c(l.body,"mpa-skip-scroll")&&e&&(a?i.scrollTo({top:i.scrollY+s(a)-(n.q&&n.y||r.q&&r.y||0)}):i.scrollTo({top:e}))}function p(t,e){e&&e[t]&&e[t]()}function g(t){let e=localStorage._mpa;return e=e&&JSON.parse(e),t==null?e:e&&e[t]}b()})(); | ||
(()=>{let l=document,n=window,o=l.querySelector.bind(l);function s(t,e){return t?.hasAttribute(e)}function f(t,e){return t?.getAttribute(e)}function m(){let t=f(l.body,"mpa-page-name");return t||new URL(l.location.href).pathname.replace(/\/$/,"")}let p=null;n.addEventListener("click",t=>{p=t.target});function u(t){return t?.getBoundingClientRect().top}n.addEventListener("unload",()=>{let t=y()||{},e=new Set(t.__||[]),r=m();s(l.body,"mpa-persist")&&(e.add(r),t.__=Array.from(e));for(let d in Object.keys(t))e.has(d)||d==="__"||delete t[d];let i=l.activeElement,a=i===l.body?p:i,c=f(a?.closest("[mpa-miss]"),"mpa-miss"),b=a?.getAttribute("name");t[r]={y:n.scrollY,a:{t:{y:u(a),q:a?.id&&`#${a.id}`||b&&`[name="${b}"]`},m:{y:u(o(c)),q:c}}},localStorage._mpa=JSON.stringify(t)});function q(){if(o("[autofocus]"))return;let t=y(m());if(!t)return;let{y:e,a:{t:r,m:i}}=t,a,c=r.q&&(a=o(r.q))?r.y:i.q&&(a=o(i.q))?i.y:0;s(a,"mpa-skip-focus")||(g("focus",a),g("select",a)),!s(l.body,"mpa-skip-scroll")&&e&&(a?n.scrollTo({top:n.scrollY+u(a)-c}):n.scrollTo({top:e}))}function g(t,e){e&&e[t]&&e[t]()}function y(t){let e=localStorage._mpa;return e=e&&JSON.parse(e),t==null?e:e&&e[t]}q()})(); |
75597
2551