mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-31 00:22:30 +00:00
Extract 11 composables and 5 layout components from App.vue, reducing it from 1921 to 327 lines. Unify dialog overlay style across DialogContent and DialogScrollContent for consistent backdrop appearance.
27 lines
840 B
TypeScript
27 lines
840 B
TypeScript
import { ref, type Ref } from "vue";
|
|
|
|
export function useTabScroll(tabsContainerRef: Ref<HTMLElement | null>) {
|
|
const canScrollLeft = ref(false);
|
|
const canScrollRight = ref(false);
|
|
|
|
function updateScrollButtons() {
|
|
const el = tabsContainerRef.value;
|
|
if (!el) {
|
|
canScrollLeft.value = false;
|
|
canScrollRight.value = false;
|
|
return;
|
|
}
|
|
canScrollLeft.value = el.scrollLeft > 0;
|
|
canScrollRight.value = el.scrollLeft < el.scrollWidth - el.clientWidth - 1;
|
|
}
|
|
|
|
function scrollTabs(direction: "left" | "right") {
|
|
const el = tabsContainerRef.value;
|
|
if (!el) return;
|
|
const scrollAmount = el.clientWidth * 0.8;
|
|
el.scrollBy({ left: direction === "left" ? -scrollAmount : scrollAmount, behavior: "smooth" });
|
|
}
|
|
|
|
return { canScrollLeft, canScrollRight, updateScrollButtons, scrollTabs };
|
|
}
|