Skip to content

Commit dee27b9

Browse files
authored
fix: Support RTL in WorkspaceSvg.scrollIntoBounds (#8936)
* feat: add support for RTL to scrollBoundsIntoView * Add additional comment
1 parent c644fe3 commit dee27b9

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

core/workspace_svg.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2603,15 +2603,28 @@ export class WorkspaceSvg
26032603
let deltaY = 0;
26042604

26052605
if (bounds.left < viewport.left) {
2606-
deltaX = viewport.left - bounds.left;
2606+
deltaX = this.RTL
2607+
? Math.min(
2608+
viewport.left - bounds.left,
2609+
viewport.right - bounds.right, // Don't move the right side out of view
2610+
)
2611+
: viewport.left - bounds.left;
26072612
} else if (bounds.right > viewport.right) {
2608-
deltaX = viewport.right - bounds.right;
2613+
deltaX = this.RTL
2614+
? viewport.right - bounds.right
2615+
: Math.max(
2616+
viewport.right - bounds.right,
2617+
viewport.left - bounds.left, // Don't move the left side out of view
2618+
);
26092619
}
26102620

26112621
if (bounds.top < viewport.top) {
26122622
deltaY = viewport.top - bounds.top;
26132623
} else if (bounds.bottom > viewport.bottom) {
2614-
deltaY = viewport.bottom - bounds.bottom;
2624+
deltaY = Math.max(
2625+
viewport.bottom - bounds.bottom,
2626+
viewport.top - bounds.top, // Don't move the top out of view
2627+
);
26152628
}
26162629

26172630
deltaX *= scale;

0 commit comments

Comments
 (0)