Skip to content

GradientEditorBar

GradientEditorBar — примитив перетаскиваемой полосы, используемый внутри редакторов градиента.

Props

PropDefaultType
stops*
Текущие точки градиента.
GradientStop[]
activeStopIndex*
Индекс активной точки.
number
barBackground*
CSS-строка фона полосы.
string

Events

EventPayloadDescription
selectStopindex: numberГенерируется при выборе точки.
dragStopindex: number, position: numberГенерируется при перетаскивании точки.

Slots

SlotPropsDescription
defaultbar state + drag handlersПолный контракт рендеринга полосы градиента.

Пропы слота default

ts
{
  stops: GradientStop[]
  activeStopIndex: number
  barBackground: string
  barRef: (el: unknown) => void
  onStopPointerDown: (index: number, event: PointerEvent) => void
  onPointerMove: (event: PointerEvent) => void
  onPointerUp: () => void
  draggingIndex: number | null
}

Пример

vue
<GradientEditorBar
  :stops="stops"
  :active-stop-index="activeStopIndex"
  :bar-background="barBackground"
  @select-stop="selectStop"
  @drag-stop="dragStop"
  v-slot="ctx"
>
  <MyGradientBar v-bind="ctx" />
</GradientEditorBar>

Связанные API

Released under the MIT License.