indexInterfaces
Interface: CanvasHtmlLayersInterface
Defined in: src/canvas/interfaces/CanvasHtmlLayersInterface.ts:1
Methods
add()
> add(id, element, style?): HTMLDivElement
Defined in: src/canvas/interfaces/CanvasHtmlLayersInterface.ts:23
Add a HTML layer to the canvas.
Parameters
id
string
The id of the layer.
element
HTMLElement
The html element to be added.
style?
Partial<Pick<CSSStyleDeclaration, "position" | "pointerEvents" | "userSelect">>
The style of the layer.
Returns
HTMLDivElement
Default
{ position: "absolute", pointerEvents: "none", userSelect: "none" }.Example
const root = document.getElementById('root')
if (!root) {
throw new Error('root element not found')
}
const htmlLayer = canvas.htmlLayers.add("ui", root, {
position: "absolute",
pointerEvents: "none"
})
const reactRoot = createRoot(htmlLayer)
reactRoot.render(
<App />
)get()
> get(id): HTMLElement | undefined
Defined in: src/canvas/interfaces/CanvasHtmlLayersInterface.ts:32
Get a HTML layer from the canvas.
Parameters
id
string
The id of the layer.
Returns
HTMLElement | undefined
remove()
> remove(id): void
Defined in: src/canvas/interfaces/CanvasHtmlLayersInterface.ts:37
Remove a HTML layer from the canvas.
Parameters
id
string
The id of the layer to be removed.
Returns
void