File tree 1 file changed +10
-5
lines changed
1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -19,25 +19,30 @@ export function getDocumentRect() {
19
19
const body = document . body ;
20
20
const html = document . documentElement ;
21
21
22
+ const clientWidth = html . clientWidth ;
23
+ const clientHeight = html . clientHeight ;
24
+
22
25
const height = Math . max (
23
26
body . scrollHeight ,
24
27
body . offsetHeight ,
25
- html . clientHeight ,
28
+ clientHeight ,
26
29
html . scrollHeight ,
27
30
html . offsetHeight
28
31
) ;
29
32
30
33
const width = Math . max (
31
34
body . scrollWidth ,
32
35
body . offsetWidth ,
33
- html . clientWidth ,
36
+ clientWidth ,
34
37
html . scrollWidth ,
35
38
html . offsetWidth
36
39
) ;
37
40
38
41
return {
39
42
height,
40
43
width,
44
+ clientWidth,
45
+ clientHeight,
41
46
} ;
42
47
}
43
48
@@ -50,12 +55,12 @@ export function getRelativePosition(
50
55
element : HTMLElement ,
51
56
relativePos : IPosition
52
57
) {
53
- const page = getDocumentRect ( ) ;
58
+ const { clientWidth , clientHeight } = getDocumentRect ( ) ;
54
59
const anchorX = relativePos . x ;
55
60
const anchorY = relativePos . y ;
56
61
57
- const marginRight = page . width - anchorX ;
58
- const marginBottom = page . height - anchorY ;
62
+ const marginRight = clientWidth - anchorX ;
63
+ const marginBottom = clientHeight - anchorY ;
59
64
60
65
const viewHeight = element . offsetHeight ;
61
66
const viewWidth = element . offsetWidth ;
You can’t perform that action at this time.
0 commit comments