Skip to content

Commit

Permalink
fix scrolling
Browse files Browse the repository at this point in the history
  • Loading branch information
madeindjs committed Jan 23, 2025
1 parent 52cf981 commit 2071863
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ const {
const { getComponentInfoFromDrag, removeInsertionCandidacy, isParentSuitable } =
useDragDropComponent(wf);
const { isComponentVisible } = useEvaluator(wf);
const rootEl = ref<HTMLElement>(null);
const emit = defineEmits(["expandBranch"]);
const matched = computed(() => {
Expand Down Expand Up @@ -147,16 +146,17 @@ async function select(ev: MouseEvent | KeyboardEvent) {
}
function expand() {
if (!treeBranch.value) return;
treeBranch.value.expand();
collapsed.value = false;
emit("expandBranch");
}
function scrollToShow() {
if (!rootEl.value) return;
const treeEl = rootEl.value.closest(".BuilderSidebarComponentTree");
if (!treeBranch.value) return;
const treeEl = treeBranch.value.$el.closest(".BuilderSidebarComponentTree");
const treeBCR = treeEl.getBoundingClientRect();
const scrollTop = rootEl.value.offsetTop - treeBCR.height / 2;
const scrollTop = treeBranch.value.$el.offsetTop - treeBCR.height / 2;
treeEl.scrollTo({ top: scrollTop, left: 0, behavior: "smooth" });
}
Expand Down

0 comments on commit 2071863

Please sign in to comment.