Type DrawerSwipe

type DrawerSwipe struct {
	// contains filtered or unexported fields
}

DrawerSwipe is caller-owned drag state for a drawer that is swiped toward its edge to dismiss. The caller supplies one axis of the pointer: increasing toward the closed edge (down for a bottom drawer, up for a top one, right for a right drawer, left for a left one). Move clamps the travel to the open extent; End decides whether the release dismisses or snaps to one of the caller's snap fractions.

Methods

Begin#

func (swipe *DrawerSwipe) Begin(pointer float32)

Begin starts a swipe at pointer.

Dragging#

func (swipe *DrawerSwipe) Dragging() bool

Dragging reports whether a swipe is in progress.

End#

func (swipe *DrawerSwipe) End(extent, velocity float32, snapPoints []float32) (offset float32, dismissed bool)

End finishes the swipe. velocity is the release speed toward closed, in pixels per second. It dismisses when the drawer travelled at least half its extent or was thrown faster than 600 px/s; otherwise it returns the nearest snap fraction (0 is the open edge) times extent. snapPoints are fractions in [0,1]; an empty slice snaps to the open or half-open position the drawer is already nearest.

Move#

func (swipe *DrawerSwipe) Move(pointer, extent float32) float32

Move advances the swipe and returns how far it has travelled toward closed, clamped to [0, extent].

Offset#

func (swipe *DrawerSwipe) Offset() float32

Offset is the current distance travelled toward closed.