In my current project, I am utilizing Excalidraw to draw a layer of <div>
s on top of the <canvas>
. While everything is functioning well, I have encountered an issue with scrolling through the infinite canvas. When the mouse hovers over one of the <div>
s, scroll events do not pass through to the canvas below, resulting in a clunky user experience.
Is there a way to prevent these <div>
s from responding to scroll events? I have attempted using pointer-events: none
in CSS, which does work, but then the <div>
s become unresponsive to any interactions at all.
You can view an example in this CodeSandbox by following this link, and the relevant code snippet can be summarized as:
"use client";
import { useMemo } from "react";
import dynamic from "next/dynamic";
const Excalidraw = dynamic(
async () => {
const mod = await import("@excalidraw/excalidraw");
return mod.Excalidraw;
},
{ ssr: false },
)
export default function Home() {
const Excal = useMemo(() => <Excalidraw gridModeEnabled />, [])
return (
<main className="absolute w-screen h-screen">
<div
style={{
position: "fixed",
zIndex: 100,
top: "100px",
left: "100px",
backgroundColor: "yellow",
cursor: "pointer",
}}
>
<p>here</p>
</div>
{Excal}
</main>
)
}