Skip to main content

drift

Function drift 

Source
pub fn drift(
    handle: &ScrollHandle,
    state: &DriftState,
    axes: Axes,
    beyond: Beyond,
) -> 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, Beyond::Nothing))

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.

beyond is what the pane’s edge gives onto, and decides whether a pointer carried past it still drives the pane — see Beyond and pane_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.