Skip to content

Commit

Permalink
Support negative width and height
Browse files Browse the repository at this point in the history
In RFC the sizes can be negative when the origin is at the right/bottom side,
to address this, we use abc() to get the expected value.
  • Loading branch information
luin authored and jhchen committed Aug 1, 2023
1 parent ff7f282 commit e3f2e3f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions core/utils/scrollRectIntoView.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type Rect = {
export type Rect = {
top: number;
right: number;
bottom: number;
Expand All @@ -12,11 +12,11 @@ const getElementRect = (element: Element): Rect => {
const rect = element.getBoundingClientRect();
const scaleX =
('offsetWidth' in element &&
rect.width / (element as HTMLElement).offsetWidth) ||
Math.abs(rect.width) / (element as HTMLElement).offsetWidth) ||
1;
const scaleY =
('offsetHeight' in element &&
rect.height / (element as HTMLElement).offsetHeight) ||
Math.abs(rect.height) / (element as HTMLElement).offsetHeight) ||
1;
return {
top: rect.top,
Expand Down

0 comments on commit e3f2e3f

Please sign in to comment.