On September 25th, 2024, we released v2 of the Apps SDK. To learn what’s new and how to upgrade, see Migration FAQ and Migration guide.

ui.startDrag

API reference for the ui.startDrag method.
This version of the API is in beta. Beta APIs are unstable and may change without warning. You can't release public apps using this API until it's stable.

This API is deprecated, and is no longer recommended for use, and should be removed from your app.

The method has been superseded by startDragToPoint.

Adds the specified element or content to a design at the end of a drag event.

Parameters

eventDragStartEvent<E>
REQUIRED

A drag start event.

Properties of event
currentTargetE
REQUIRED
dragDataobject
REQUIRED

Element or content to be added to the design at the end of the drag event.

Audio track to be added to the design at the end of a drag event.

typestring
REQUIRED

The type of element.

This must be "audio".

resolveAudioReffunction
REQUIRED

A function that returns a reference (ref) to an audio asset in Canva's backend.

Returns

A Promise that resolves with the following object:

refAudioRef

A unique identifier that references an audio asset in Canva's backend.

durationMsnumber
REQUIRED

The duration of the audio track, in milliseconds.

titlestring
REQUIRED

A human readable title for the audio track.

Embed element to be added to the design at the end of a drag event.

typestring
REQUIRED

The type of element.

This must be "embed".

previewSizeDimensions
REQUIRED

The dimensions of the preview image.

Properties of previewSize
widthnumber
REQUIRED

A width, in pixels.

heightnumber
REQUIRED

A height, in pixels.

previewUrlstring
REQUIRED

The URL of an image to display under the user's cursor during the drag and drop event.

embedUrlstring
REQUIRED

The URL of media that can be embedded, such as the URL of a YouTube video.

This URL must be supported by the Iframely API.

Text element or content to be added to the design at the end of a drag event.

typestring
REQUIRED

The type of element.

This must be "text".

childrenstring[]
OPTIONAL

The text content to drag.

textAlignstring
OPTIONAL

The alignment of the text.

Default Value: "start"

The available options include:

  • "start"
  • "center"
  • "end"
  • "justify"
fontWeightFontWeight
OPTIONAL

The weight (thickness) of the font.

Default Value: "normal"

The available options include:

  • "normal"
  • "thin"
  • "extralight"
  • "light"
  • "medium"
  • "semibold"
  • "bold"
  • "ultrabold"
  • "heavy"
fontStylestring
OPTIONAL

The style of the font.

Default Value: "normal"

The available options include:

  • "normal"
  • "italic"
decorationstring
OPTIONAL

The decoration of the font.

Default Value: "none"

The available options include:

  • "none"
  • "underline"
fontRefFontRef
OPTIONAL

A unique identifier that points to a font asset in Canva's backend.

Video element or content to be added to the design at the end of a drag event.

typestring
REQUIRED

The type of element.

This must be "video".

resolveVideoReffunction
REQUIRED

A function that returns a reference (ref) to a video asset in Canva's backend.

Returns

A Promise that resolves with the following object:

refVideoRef

A unique identifier that references a video asset in Canva's backend.

previewSizeDimensions
REQUIRED

The dimensions of the preview image.

Properties of previewSize
widthnumber
REQUIRED

A width, in pixels.

heightnumber
REQUIRED

A height, in pixels.

previewUrlstring
REQUIRED

The URL of an image to display under the user's cursor during the drag and drop event.

fullSizeDimensions
OPTIONAL

The dimensions of the full-size video.

  • These dimensions are used when adding the video to the design
  • If omitted, the previewSize dimensions are used as a fallback.
Properties of fullSize
widthnumber
REQUIRED

A width, in pixels.

heightnumber
REQUIRED

A height, in pixels.

Image element or content to be added to the design at the end of a drag event.

typestring
REQUIRED

The type of element.

This must be "image".

previewSizeDimensions
REQUIRED

The dimensions of the preview image.

Properties of previewSize
widthnumber
REQUIRED

A width, in pixels.

heightnumber
REQUIRED

A height, in pixels.

resolveImageReffunction
REQUIRED

A function that returns a reference (ref) to an audio asset in Canva's backend.

Returns

A Promise that resolves with the following object:

refImageRef

A unique identifier that references an image asset in Canva's backend.

previewUrlstring
REQUIRED

The URL of an image to display under the user's cursor during the drag and drop event.

fullSizeDimensions
OPTIONAL

The dimensions of the full-size image.

Properties of fullSize
widthnumber
REQUIRED

A width, in pixels.

heightnumber
REQUIRED

A height, in pixels.

Returns

Promise<void>