Skip to content

Commit afc4e14

Browse files
committed
code update
1 parent f3e6ecd commit afc4e14

2 files changed

Lines changed: 9 additions & 36 deletions

File tree

src/index.css

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,9 @@ body[arco-theme='light'] {
2020
--color-scrollbar-track: #f0f0f0;
2121
}
2222

23-
.interactive-container {
23+
#root {
2424
overscroll-behavior: none;
25-
height: 100vh;
26-
width: 100vw;
27-
position: relative;
28-
contain: strict;
29-
padding: 0px;
30-
margin: 0px;
31-
box-sizing: border-box;
25+
contain: content;
3226
overflow: auto;
3327
}
3428

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import type { CSSProperties, HTMLAttributes, ReactNode } from "react";
1+
import type { HTMLAttributes, ReactNode } from "react";
22

33
type InteractiveContainerProps = {
44
children: ReactNode;
5-
className?: string;
6-
style?: CSSProperties;
75
} & HTMLAttributes<HTMLDivElement>;
86

97
const handleContainerWheel = (evt: Event) => {
@@ -16,19 +14,10 @@ const handleContainerWheel = (evt: Event) => {
1614
}
1715
};
1816

19-
const attachMainHandler = (target: Node) => {
17+
const attachMainHandler = (target: Node | null) => {
2018
const o = { capture: false, passive: false, once: false };
21-
target.removeEventListener("wheel", handleContainerWheel, o);
22-
target.addEventListener("wheel", handleContainerWheel, o);
23-
};
24-
25-
const weakSet = new WeakSet();
26-
27-
const setRef = (div: HTMLDivElement) => {
28-
if (!div) return;
29-
if (weakSet.has(div)) return;
30-
weakSet.add(div);
31-
attachMainHandler(div);
19+
target?.removeEventListener("wheel", handleContainerWheel, o);
20+
target?.addEventListener("wheel", handleContainerWheel, o);
3221
};
3322

3423
/**
@@ -41,17 +30,7 @@ const setRef = (div: HTMLDivElement) => {
4130
* - Outside Monaco, stop propagation so parent/page-level handlers do not
4231
* react to wheel gestures from this container.
4332
*/
44-
export default function InteractiveContainer({ children, className, style, ...props }: InteractiveContainerProps) {
45-
return (
46-
<div
47-
{...props}
48-
className={["interactive-container", className].filter(Boolean).join(" ")}
49-
style={{
50-
...style,
51-
}}
52-
ref={setRef}
53-
>
54-
{children}
55-
</div>
56-
);
33+
export default function InteractiveContainer({ children }: InteractiveContainerProps) {
34+
attachMainHandler(document.getElementById("root"));
35+
return <>{children}</>;
5736
}

0 commit comments

Comments
 (0)