1
0
mirror of https://github.com/sendevia/website.git synced 2026-03-05 23:32:45 +08:00

feat: update scroll target selector from ID to class

This commit is contained in:
2025-12-05 23:48:12 +08:00
parent 53ce2591b2
commit 3c1b3b4aed
2 changed files with 6 additions and 6 deletions

View File

@@ -4,7 +4,7 @@ import { useGlobalScroll } from "../composables/useGlobalScroll";
const { isScrolled } = useGlobalScroll({ threshold: 500 });
function scrollToTop() {
const container = document.getElementById("contentFlow");
const container = document.querySelector(".content-flow");
(container as HTMLElement).scrollTo({ top: 0, behavior: "smooth" });
}
</script>

View File

@@ -5,7 +5,7 @@ let isInitialized = false;
let isScrolled = ref(false);
let precision = 1;
let scrollPosition = ref(0);
let targetElementSelector: string = "#layout-content-flow";
let targetScrollable: string = ".content-flow";
let threshold = 80;
const componentCallbacks = new Map<symbol, { threshold: number; callback: (isScrolled: boolean) => void }>();
@@ -17,7 +17,7 @@ function isScrollable(el: HTMLElement) {
}
function detectContainer() {
const el = document.querySelector(targetElementSelector);
const el = document.querySelector(targetScrollable);
if (el && el instanceof HTMLElement && isScrollable(el)) return el;
return window;
}
@@ -41,11 +41,11 @@ function handleGlobalScroll() {
}
}
function initGlobalScrollListener(initialThreshold: number, scrollContainer: string = "#layout-content-flow") {
function initGlobalScrollListener(initialThreshold: number = threshold, scrollContainer: string = targetScrollable) {
if (isInitialized) return;
threshold = initialThreshold;
targetElementSelector = scrollContainer;
targetScrollable = scrollContainer;
if (typeof window !== "undefined") {
const updateContainer = () => {
@@ -88,7 +88,7 @@ function initGlobalScrollListener(initialThreshold: number, scrollContainer: str
function calculatePercentage(precisionValue: number = precision): number {
try {
const el = document.querySelector(targetElementSelector);
const el = document.querySelector(targetScrollable);
const scrollContainer = el && el instanceof HTMLElement && isScrollable(el as HTMLElement) ? el : window;
const scrollTop =