mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-19 19:19:03 +00:00
Add percentage distance option
This commit is contained in:
parent
d9ad6aca43
commit
980528699e
@ -27,7 +27,13 @@ module.exports = {
|
|||||||
key: "top",
|
key: "top",
|
||||||
label: "scroll down distance to show button",
|
label: "scroll down distance to show button",
|
||||||
type: "input",
|
type: "input",
|
||||||
value: 100,
|
value: 80,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "percent",
|
||||||
|
label: "set distance as a percentage",
|
||||||
|
type: "toggle",
|
||||||
|
value: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
hacks: {
|
hacks: {
|
||||||
@ -78,13 +84,18 @@ module.exports = {
|
|||||||
addedNodes[0].className === 'notion-scroller'
|
addedNodes[0].className === 'notion-scroller'
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
if (store().top> 0) {
|
let top = store().top;
|
||||||
|
if (top> 0) {
|
||||||
scroll.classList.add('hidden');
|
scroll.classList.add('hidden');
|
||||||
|
|
||||||
|
if (store().percent) {
|
||||||
|
top *= document.querySelector('.notion-page-content').offsetHeight / 100;
|
||||||
|
}
|
||||||
|
|
||||||
document
|
document
|
||||||
.querySelector('.notion-frame > .notion-scroller')
|
.querySelector('.notion-frame > .notion-scroller')
|
||||||
.addEventListener('scroll', (event) => {
|
.addEventListener('scroll', (event) => {
|
||||||
if (event.target.scrollTop < store().top)
|
if (event.target.scrollTop < top)
|
||||||
scroll.classList.add('hidden');
|
scroll.classList.add('hidden');
|
||||||
else
|
else
|
||||||
scroll.classList.remove('hidden');
|
scroll.classList.remove('hidden');
|
||||||
|
Loading…
Reference in New Issue
Block a user