Skip to main content

Reorder

Reorder is a component that allows you to use the Drag&Drop functionality to reorder the ReorderItem items in a group.

Basic usage

Attribute Disabled

The disabled attribute is used to disable the ability to reorder items within a Reorder. When this attribute is set, the user will not be able to drag items to change their order.

Handle for pulling

By adding an item to the handle slot of the ReorderItem item, you can define a specific area that will serve as a handle for dragging and rearranging items. This allows users to interact more intuitively when changing the order of items.

Attribute Reverse - Reverse order

The reverse attribute is used to change the direction of reordering items within a Reorder.

Drop Zones

DropZone is a component that represents a zone intended for rearranging content.

When to use

Use wje-reorder when you need a consistent WebJET-based implementation for this UI concern.

When not to use

Do not stretch the component beyond its responsibility; compose smaller primitives for edge cases.

Accessibility

Validate keyboard behavior, focus states, contrast, and meaningful labels for interactive elements.

Best Practices

  • Prefer component APIs over direct DOM manipulation.
  • Stick to design tokens and naming conventions.
  • Test components with realistic data before production rollout.

Attributes and Properties

dragEl

DescriptionStores a reference to the element currently being dragged.
Attributedrag-el
Typenull
Defaultnull

items

DescriptionControls item selection behavior for items.
Attributeitems
Typearray
Default[]

originalIndex

DescriptionStores the original index before reordering starts.
Attributeoriginal-index
Typenull
Defaultnull

isDragging

DescriptionControls whether is-dragging is enabled and affects component behavior.
Attributeis-dragging
Typeboolean
Defaultfalse

offsetX

DescriptionSets the numeric value used for offset-x.
Attributeoffset-x
Typenumber
Default0

offsetY

DescriptionSets the numeric value used for offset-y.
Attributeoffset-y
Typenumber
Default0

cloneEl

DescriptionStores a clone used as a drag preview while reordering.
Attributeclone-el
Typenull
Defaultnull

Events

NameDescription
wje-reorder:changeEvent fired when the reorder is changed.

Methods

attachEventListeners

DescriptionAttaches event listeners to the element.
Signature(element: any) => void

mouseDown

DescriptionHandles the mouse down event.
Signature(e: object) => void

touchStart

DescriptionHandles the touch start event.
Signature(e: any) => void

startDragging

DescriptionInitializes the dragging process for a reorderable item.
Signature(clientX: number, clientY: number, target: HTMLElement) => void

mouseMove

DescriptionHandles the mouse move event.
Signature(e: any) => void

touchMove

DescriptionHandles the touchmove event and updates the position of the dragged element.
Signature(e: TouchEvent) => void

moveElement

DescriptionUpdates the position of the dragged element and handles reordering logic based on the mouse position.
Signature(pageX: number, pageY: number) => void

mouseUp

DescriptionHandles the mouse up event.
Signature() => void

touchEnd

DescriptionHandles the touch end event.
Signature() => void

stopDragging

DescriptionStops dragging the element.
Signature() => void

dragStart

DescriptionPrevents the default behavior of the dragstart event.
Signature(e: DragEvent) => void

createClone

DescriptionCreates a clone of the element.
Signature() => void

isMovingDown

DescriptionChecks if the dragged element is moving down.
Signature(droppedElement: any) => boolean

dispatchChange

DescriptionDispatches a custom event to signal that a reordering operation has occurred.
Signature(from: number, to: number, order: Array<number>, orderElements: any) => void

CSS Shadow Parts

NameDescription
nativeThe native part of the reorder.

CSS Custom Properties

No CSS custom properties available for this component.

Slots

NameDescription
defaultThe default slot for the reorder.