Advanced · plugin: Draggable + Inertia
Drag, throw, snap
Grab a brick and throw it. InertiaPlugin glides it with real momentum and snaps it to the grid. The whole setup is the drag directive on each brick; the instances die with the component.
DraggableInertiaPluginsnap
G
S
A
P
drag the bricks, throw them, they snap to the grid
<!-- the whole drag setup is one attribute -->
<div class="arena">
<div class="brick" drag [snap]="96"></div>
</div>
<!-- inputs when you need them -->
<div drag="x" [inertia]="false"
[bounds]="'.arena'"
(dragEnd)="save()">
</div>How this works
- The
dragdirective isDraggable.create()with signal inputs: type, bounds (the parent by default), inertia, and a gridsnap. Instances are killed on destroy, so no stray pointer listeners after navigation. The raw API works too, straight from the callback. inertia: truehands the release velocity to InertiaPlugin, andsnaprounds the landing position to the grid. Momentum, friction, and settling are all GSAP.- Scatter is a
contextSafehandler tweening the samex/ytransforms Draggable uses, so dragging and tweening never fight over state.