Skip to content

Commit 8615e3a

Browse files
committed
chore: ignore body rect
1 parent 5d63826 commit 8615e3a

File tree

3 files changed

+75
-0
lines changed

3 files changed

+75
-0
lines changed

docs/demos/body-overflow.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
title: Body Overflow
3+
nav:
4+
title: Demo
5+
path: /demo
6+
---
7+
8+
<code src="../examples/body-overflow.tsx"></code>

docs/examples/body-overflow.tsx

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/* eslint no-console:0 */
2+
import Trigger from 'rc-trigger';
3+
import React from 'react';
4+
import '../../assets/index.less';
5+
6+
export default () => {
7+
return (
8+
<React.StrictMode>
9+
<style
10+
dangerouslySetInnerHTML={{
11+
__html: `
12+
body {
13+
overflow-x: hidden;
14+
}
15+
`,
16+
}}
17+
/>
18+
19+
<Trigger
20+
arrow
21+
// forceRender
22+
action="click"
23+
popup={
24+
<div
25+
style={{
26+
background: 'yellow',
27+
border: '1px solid blue',
28+
width: 200,
29+
height: 60,
30+
opacity: 0.9,
31+
}}
32+
>
33+
Popup
34+
</div>
35+
}
36+
popupStyle={{ boxShadow: '0 0 5px red' }}
37+
popupAlign={{
38+
points: ['tc', 'bc'],
39+
overflow: {
40+
shiftX: 50,
41+
adjustY: true,
42+
},
43+
offset: [0, -10],
44+
htmlRegion: 'scroll',
45+
}}
46+
>
47+
<span
48+
style={{
49+
background: 'green',
50+
color: '#FFF',
51+
paddingBlock: 30,
52+
paddingInline: 70,
53+
opacity: 0.9,
54+
transform: 'scale(0.6)',
55+
display: 'inline-block',
56+
}}
57+
>
58+
Target
59+
</span>
60+
</Trigger>
61+
</React.StrictMode>
62+
);
63+
};

src/hooks/useAlign.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,10 @@ export default function useAlign(
191191
};
192192

193193
(scrollerList || []).forEach((ele) => {
194+
if (ele instanceof HTMLBodyElement) {
195+
return;
196+
}
197+
194198
const eleRect = ele.getBoundingClientRect();
195199
const {
196200
offsetHeight: eleOutHeight,

0 commit comments

Comments
 (0)