Skip to main content
Version: 2.x (next)

View State Types

Types for view state, render content props, and style props.

DraxViewState​

Current drag/receive state of a view, provided to renderContent.

interface DraxViewState {
dragStatus: DraxViewDragStatus;
receiveStatus: DraxViewReceiveStatus;
dragAbsolutePosition?: Position;
dragTranslation?: Position;
dragTranslationRatio?: Position;
dragOffset?: Position;
grabOffset?: Position;
grabOffsetRatio?: Position;
draggingOverReceiver?: DraxEventViewData;
receiveOffset?: Position;
receiveOffsetRatio?: Position;
receivingDrag?: DraxEventViewData;
}

DraxViewDragStatus (enum)​

enum DraxViewDragStatus {
Inactive, // Not being dragged
Dragging, // Currently being dragged
Released, // Released, snap in progress
}

DraxViewReceiveStatus (enum)​

enum DraxViewReceiveStatus {
Inactive, // Nothing hovering
Receiving, // Something is hovering over this view
}

DraxTrackingStatus​

interface DraxTrackingStatus {
dragging: boolean;
receiving: boolean;
}

DraxRenderContentProps​

Props passed to renderContent and renderHoverContent.

interface DraxRenderContentProps {
viewState?: DraxViewState;
trackingStatus?: DraxTrackingStatus;
hover: boolean; // true in hover layer copy
children: ReactNode;
dimensions?: ViewDimensions;
payload?: unknown; // dragPayload ?? payload, same as dragged.payload in events
}

DraxList / SortableItem rows merge item, index and originalIndex into the payload, so a row's renderHoverContent can read props.payload.item.

  • The hover's payload is a snapshot taken at drag start. The hover doesn't re-render when the payload changes during the drag.
  • A row that sets its own dragPayload gets that value as payload, without item, index and originalIndex (dragPayload wins over the merged payload). The list then can't reorder that row. Put extra fields in payload instead, which is merged.

DraxStyleProp​

type DraxStyleProp = StyleProp<ViewStyle>;

AnimatedViewStylePropWithoutLayout​

Used for hover styles — supports animated values but no layout props.

type AnimatedViewStylePropWithoutLayout =
| StyleProp<ViewStyle>
| StyleProp<AnimatedStyle<StyleProp<ViewStyle>>>;