API reference
Design
Platform
overlay.registerOnCanOpen
API reference for the overlay.registerOnCanOpen method.
This version of the API is deprecated. This version will soon be unsupported. You should use a stable version of the API in your app.
Registers a callback that runs when an overlay for the specified target can or can't be opened.
To learn more, see Creating image overlays.
Usage
import { overlay } from "@canva/design";overlay.registerOnCanOpen({target: "image_selection",onCanOpen: (event) => {console.log(event.canOpen);},});
TSX
Parameters
options
object
RequiredThe options for registering the callback.
options.target
string
RequiredThe target to check if an overlay can be opened for. The only supported option is "image_selection"
.
options.onCanOpen
function
RequiredThe callback that runs when an overlay for the specified target can or can't be opened.
options.onCanOpen(event)
object
RequiredInformation about the event.
options.onCanOpen(event.canOpen)
boolean
RequiredIf true
, an overlay can be opened for the specified target.
options.onCanOpen(event.open)
function
RequiredOpens an overlay for the specified target.
Returns
A disposer function that cleans up the registered callback.