1.0.2 • Published 8 months ago

@lg-charts/drag-provider v1.0.2

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
8 months ago

DragProvider

Provides drag and drop functionality for chart components.

DragProvider creates a draggable context around charts components. Any child Chart or ChartCard with a dragId prop, will automatically become draggable and droppable within that context.

DragProvider contexts are also nestable, providing better control of where a child component can be dropped.

npm (scoped)

Installation

PNPM

pnpm add @lg-charts/drag-provider

NPM

npm install @lg-charts/drag-provider

Yarn

yarn add @lg-charts/drag-provider

Basic Chart Example

function ChartPage() {
  // Chart state and dragEnd handlers configured here

  return (
    <DragProvider onDragEnd={handleChartCardDrag}>
      {/** Controls drag events for cards */}
      <ChartCard dragId="chart-card-1">
        <DragProvider onDragEnd={handleChartDrag}>
          {/** Controls drag events for charts inside chart-card-1 */}
          <Chart dragId="chart-1" />
          <Chart dragId="chart-2" />
        </DragProvider>
      </ChartCard>
      <ChartCard dragId="chart-card-2">
        <DragProvider onDragEnd={handleChartDrag}>
          {/** Controls drag events for charts inside chart-card-2 */}
          <Chart dragId="chart-3" />
          <Chart dragId="chart-4" />
        </DragProvider>
      </ChartCard>
    </DragProvider>
  }
}

Props

NameDescriptionTypeDefault
onDragStart (optional)Callback that will fire on the dragstart event({ active: string }) => voidundefined
onDragEnd (optional)Callback that will fire on the dragend event({ active: string; over: string }) => voidundefined

Callback Arguments

  • active - dragId of the drag component being dragged.
  • over - dragId of the drag component the active component is over on dragend.
1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago

0.2.8

9 months ago

0.2.7

9 months ago

0.2.6

9 months ago

0.2.5

9 months ago

0.2.4

10 months ago

0.2.3

10 months ago

0.2.2

10 months ago

0.2.1

10 months ago

0.2.0

11 months ago

0.1.3

11 months ago

0.1.1

11 months ago

0.1.0

11 months ago