overlay.registerOnCanOpen

API reference for the overlay.registerOnCanOpen method.

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.

import { overlay } from "@canva/preview/design";
overlay.registerOnCanOpen({
target: "image_selection",
onCanOpen: (event) => {
console.log(event.canOpen);
},
});
tsx
#optionsobject
Required

The options for registering the callback.

#options.targetstring
Required

The target to check if an overlay can be opened for. The only supported option is "image_selection".

#options.onCanOpenfunction
Required

The callback that runs when an overlay for the specified target can or can't be opened.

#options.onCanOpen(event)object
Required

Information about the event.

#options.onCanOpen(event.canOpen)boolean
Required

If true, an overlay can be opened for the specified target.

#options.onCanOpen(event.open)function
Required

Opens an overlay for the specified target.

void