Skip to main content

drift

Function drift 

Source
pub fn drift(
    handle: &ScrollHandle,
    state: &DriftState,
    axes: Axes,
) -> AnyElement
Expand description

Move handle while a drag is held near its edge, for as long as it is held there.

Drop it in beside scrollbar, over the same container, and feed it from the drag-move listener — see DriftState::aim:

div().relative()
    .child(scroll::pane("board", Axes::Horizontal).size_full().track_scroll(&self.scroll).child(lanes))
    .child(scroll::drift(&self.scroll, &self.drift, Axes::Horizontal))

Without it a board is only as wide as the window: a card cannot be carried to a lane that is off screen, because reaching for one means letting go.

The gesture ending is not an event this subscribes to. gpui hands a drop to whatever was under the pointer, and a release over nothing is not delivered at all, so either would leave a pane drifting on a gesture that is over. The drag going away is the signal instead, and it arrives however the drag ended.

Across the axis the pointer must be within the pane, or every lane on a board would drift together on one that is only near one of them. Along it, past the edge still counts — see drift_velocity.

Not motion in the motion sense and not reduced with it: nothing here animates a property, the pane is being scrolled by a gesture the same way a wheel scrolls it, and a reader who cannot reach the far lane has no gesture left to make.