nextH
@@ -17,16 +17,10 @@
// window.pageYOffset
// document.documentElement.scrollTop
// document.body.scrollTop
- const absHPos = (heading.getBoundingClientRect().top + document.body.scrollTop) | 0;
+ const absHPos = Math.trunc(heading.getBoundingClientRect().top + document.body.scrollTop);
if (absHPos > document.body.scrollTop) {
heading.scrollIntoView();
return true;
}
});
-/* DBG
-Array.from(document.body.querySelectorAll([
- Array.from(Array(6).keys(), n => 'h' + (n + 1))
-]), h => console.log(h.tagName, h.textContent.trim(), h.offsetTop, h.getBoundingClientRect()))
-*/
-
Array.from(document.body.querySelectorAll([
Array.from(Array(6).keys(), n => 'h' + (n + 1))
])).some(heading => {
const absHPos = Math.trunc(heading.getBoundingClientRect().top + document.body.scrollTop);
if (absHPos > document.body.scrollTop) {
heading.scrollIntoView();
return true;
}
});
- Permalink
- このページへの個別リンクです。
- RAW
- 書かれたコードへの直接のリンクです。
- Packed
- 文字列が圧縮された書かれたコードへのリンクです。
- Userscript
- Greasemonkey 等で利用する場合の .user.js へのリンクです。
- Loader
- @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
- Metadata
- コード中にコメントで @xxx と書かれたメタデータの JSON です。