Events
The FloatingToolbar emits events in response to dragging, programmatic moves, and resizing of the hosted Toolbar.
Drag Events
The FloatingToolbar exposes the following lowercase Vue events for drag and position changes:
dragstart—Fires before a pointer drag or keyboard Move mode begins. Callevent.preventDefault()to cancel it. The payload type isFloatingToolbarDragStartEvent.move—Fires when the position changes through pointer dragging, keyboard Move mode, orsetPosition. The payload type isFloatingToolbarMoveEvent.dragend—Fires when pointer dragging ends or keyboard Move mode exits, including cancellation withEscape. The payload type isFloatingToolbarDragEndEvent.
Each movement event includes the target FloatingToolbar handle, top and left coordinates, a drag flag, and the originating DOM event. The drag flag is true for pointer dragging and false for keyboard or programmatic movement. For setPosition calls, event is undefined.
Use Vue listeners to subscribe to these events:
<FloatingToolbar
:draggable="true"
@dragstart="handleDragstart"
@move="handleMove"
@dragend="handleDragend"
@resize="handleResize"
/>
For TypeScript callback props, FloatingToolbarProps uses the names onDragstart, onMove, onDragend, and onResize.
The following example logs drag start, drag end, and position changes.
Resize Event
The resize event is forwarded from the hosted Toolbar without changing its ToolbarResizeEvent payload. It fires when a window resize changes the Toolbar's dimensions and includes the hosted Toolbar's offsetWidth and offsetHeight.
Canceling a Drag Operation
Call event.preventDefault() in the dragstart handler to cancel the operation. Neither move nor dragend fires for that canceled interaction. You can use event.isDefaultPrevented() to check whether the operation was canceled.
The following example lets you lock the toolbar to prevent repositioning. Click Lock and try to drag the handle or enter keyboard Move mode. Click Unlock to enable movement again.