refactor: simplify button positioning in RevealManager

Remove unused scroll container dependency and use relative rect
coordinates for button positioning.
This commit is contained in:
hypercross 2026-07-11 09:49:48 +08:00
parent e437d20d73
commit 6d0bd75cb6
1 changed files with 2 additions and 12 deletions

View File

@ -18,7 +18,6 @@ import {
import { Portal } from "solid-js/web";
import { useLocation } from "@solidjs/router";
import { useArticleDom } from "./Article";
import { useScrollContainer } from "../App";
import { journalStreamState } from "./stores/journalStream";
import { useJournalCompletions } from "./journal/completions";
import {
@ -76,7 +75,6 @@ function hide() {
export const RevealManager: Component = () => {
const contentDom = useArticleDom();
const scrollContainer = useScrollContainer();
const location = useLocation();
const comp = useJournalCompletions();
@ -181,16 +179,8 @@ export const RevealManager: Component = () => {
<button
class={`fixed z-50 inline-flex items-center justify-center w-5 h-5 rounded cursor-pointer ${btn().color}`}
style={{
top: `${
btn().rect.top +
(scrollContainer()?.scrollTop ?? window.scrollY) -
6
}px`,
left: `${
btn().rect.left +
(scrollContainer()?.scrollLeft ?? window.scrollX) -
20
}px`,
top: `${btn().rect.top - 6}px`,
left: `${btn().rect.left - 20}px`,
}}
title={btn().title}
innerHTML={btn().svg}