Previews and animations

Everything you see during a drag is drawn natively, at the screen’s frame rate, without calling Python.
The preview
Section titled “The preview”The preview is what follows the pointer. By default it is a copy of the item, lifted: a bit
bigger (lift=1.03) with a soft shadow. It keeps the place where you grabbed it, so it
doesn’t jump under the pointer.
pz.draggable(card, "c1", lift=1.06, shadow="#00000080", opacity=0.9)pz.draggable(card, "c1", lift=1.0, shadow=False) # flat, like a design toolpz.draggable(card, "c1", preview=ui.badge("1 file")) # anything elsepz.draggable(dot, "out", preview="wire") # a cable (node editors)pz.sortable(..., preview="none") # the items move, no previewThe source
Section titled “The source”The original item, while its preview moves:
source= |
Effect | Used for |
|---|---|---|
"ghost" |
Faded to source_opacity (0.35). |
Draggables, by default. |
"hide" |
Hidden: the item itself seems to move. | Sortables, by default; canvases. |
"keep" |
As it was. | Palettes, wires. |
In a sortable the other items close the slot of the dragged one, so source="ghost" shows its faded
copy at the landing place instead (the same as placeholder="ghost").
The placeholder
Section titled “The placeholder”Where the item will land: placeholder="shadow" (a tinted box), "ghost" (a translucent copy
at ghost_opacity) or "none". Sortables show a shadow by default and droppables nothing.
placeholder_style changes the look of the shadow:
pz.sortable(..., placeholder="shadow", placeholder_style={"background": "#98c37922", "border_color": "#98c379", "radius": 10})Highlights
Section titled “Highlights”Targets light up while a drag they take is over them (over_style) or anywhere
(active_style). See droppable.
Animations
Section titled “Animations”- Making room: in a sortable, the other items slide aside to open a gap, smoothly.
- Reordering: when the order of a sortable changes, from a drop or from your code
(sorting by name, a new item), the items glide to their new places in
animationmilliseconds (200;0turns it off). - Dropping: the preview flies to its landing place in
drop_animationmilliseconds (180), then the item appears there. - Cancelling: Esc, or a drop outside any target, flies the preview back home.