Skip to content

Commit f71dc77

Browse files
committed
feat(locationStrategies): support page scale
1 parent 06c4c91 commit f71dc77

File tree

1 file changed

+11
-6
lines changed
  • packages/vuetify/src/util

1 file changed

+11
-6
lines changed

packages/vuetify/src/util/box.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,21 @@ export class Box {
44
width: number
55
height: number
66

7-
constructor ({ x, y, width, height }: {
7+
constructor (args: DOMRect | {
88
x: number
99
y: number
1010
width: number
1111
height: number
1212
}) {
13-
this.x = x
14-
this.y = y
15-
this.width = width
16-
this.height = height
13+
const pageScale = (window as any)?.pageScale ?? 1
14+
const factor = args instanceof DOMRect ? 1 + (1 - pageScale) / pageScale : 1
15+
16+
const { x, y, width, height } = args
17+
18+
this.x = x * factor
19+
this.y = y * factor
20+
this.width = width * factor
21+
this.height = height * factor
1722
}
1823

1924
get top () { return this.y }
@@ -44,7 +49,7 @@ export function getTargetBox (target: HTMLElement | [x: number, y: number]): Box
4449
height: 0,
4550
})
4651
} else {
47-
return target.getBoundingClientRect()
52+
return new Box(target.getBoundingClientRect())
4853
}
4954
}
5055

0 commit comments

Comments
 (0)