Skip to content

Commit

Permalink
fix: Allow more options for scrollLayerIntoView argument
Browse files Browse the repository at this point in the history
  • Loading branch information
surajshetty3416 committed Oct 29, 2024
1 parent ed91f1c commit 47013b9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions frontend/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,12 @@ const useStore = defineStore("store", {
videoBlock.attributes.src = videoSrc;
return videoBlock;
},
selectBlock(block: Block, e: MouseEvent | null, scrollLayerIntoView = true, scrollBlockIntoView = false) {
selectBlock(
block: Block,
e: MouseEvent | null,
scrollLayerIntoView: boolean | ScrollLogicalPosition = true,
scrollBlockIntoView = false,
) {
this.activeCanvas?.history?.pause();
if (this.settingPage) {
return;
Expand All @@ -220,10 +225,11 @@ const useStore = defineStore("store", {
}
if (scrollLayerIntoView) {
// TODO: move to layers?
const align = scrollLayerIntoView === true ? "center" : scrollLayerIntoView;
nextTick(() => {
document
.querySelector(`[data-block-layer-id="${block.blockId}"]`)
?.scrollIntoView({ behavior: "instant", block: "center", inline: "center" });
?.scrollIntoView({ behavior: "instant", block: align, inline: "center" });
});
}

Expand Down

0 comments on commit 47013b9

Please sign in to comment.