mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-10 15:39:01 +00:00
fix: more reliable scroll to top btn initial display + positioning
This commit is contained in:
parent
ba8c660442
commit
b55e74a2c5
@ -17,8 +17,9 @@ const setupWrapper = () => {
|
|||||||
if (!$help) return;
|
if (!$help) return;
|
||||||
const $wrapper = html`<div
|
const $wrapper = html`<div
|
||||||
class="notion-enhancer--floating-buttons z-50
|
class="notion-enhancer--floating-buttons z-50
|
||||||
absolute right-0 bottom-[calc(26px+env(safe-area-inset-bottom))]
|
absolute bottom-[calc(26px+env(safe-area-inset-bottom))]
|
||||||
flex gap-[12px] !(&>.notion-help-button:static)"
|
flex gap-[12px] !(&>.notion-help-button:static)"
|
||||||
|
style="right:${$help.style.right}"
|
||||||
></div>`;
|
></div>`;
|
||||||
removeMutationListener(addToDom);
|
removeMutationListener(addToDom);
|
||||||
$help.replaceWith($wrapper);
|
$help.replaceWith($wrapper);
|
||||||
|
@ -25,9 +25,12 @@ export default async (api, db) => {
|
|||||||
<//>`,
|
<//>`,
|
||||||
onScroll = () => {
|
onScroll = () => {
|
||||||
if (!$scroller) return;
|
if (!$scroller) return;
|
||||||
const { scrollTop, scrollHeight, clientHeight } = $scroller,
|
const { scrollTop, scrollHeight, clientHeight } = $scroller;
|
||||||
scrollPercent = (scrollTop / (scrollHeight - clientHeight)) * 100,
|
let scrollDist = scrollTop;
|
||||||
scrollDist = scrollUnits === "Percent" ? scrollPercent : scrollTop;
|
if (scrollUnits === "Percent") {
|
||||||
|
scrollDist = (scrollTop / (scrollHeight - clientHeight)) * 100;
|
||||||
|
if (isNaN(scrollDist)) scrollDist = 0;
|
||||||
|
}
|
||||||
if (distanceUntilShown <= scrollDist) addFloatingButton($btn);
|
if (distanceUntilShown <= scrollDist) addFloatingButton($btn);
|
||||||
else removeFloatingButton($btn);
|
else removeFloatingButton($btn);
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user