draggable-panel

Vue draggable panel
3,320 25
Install
npm install draggable-panel
Latest Version:1.0.10
Vue:3
License:MIT
Last Updated:Nov 7, 2022
Links: GitHub  ·  npm
Maintainer: cainier

Vue Draggable Panel

Vue3 based drag panel component


Demo

https://cainier.github.io/draggable-panel

image

Example

https://github.com/Cainier/draggable-panel/blob/main/src/App.vue

Features

  1. Canvas scale
  2. Canvas move
  3. Chart item scale
  4. Chart item resize

Hotkey

Ctrl can be replaced by Command

  • Move: Space + Drag
  • Scale: Ctrl + Mousewheel
  • Scale +: Ctrl + =
  • Scale -: Ctrl + -
  • Reset: Ctrl + 0
  • Real Size: Ctrl + Enter

Installation

npm i draggable-panel

yarn add draggable-panel

Document

Props

  • width: Number
    • Description: Panel width (px)
    • Required
    • Example: 1920
  • height: Number
    • Description: Panel height (px)
    • Required
    • Example: 1080
  • data: Objects in Array
    • Description: Chart data array
    • Required
    • Example:
      [
        ...
        {
          id    : 1,    // ID (Number / String)
          width : 300,  // Default width (Number)
          height: 200,  // Default height (Number)
          x     : 20,   // Default Y (Number)
          y     : 20    // Default X (Number)
        },
        ...
      ]
      
  • chartMinWidth: Number
    • Description: Minimum chart width (px)
    • Default: 100
  • chartMinHeight: Number
    • Description: Minimum chart height (px)
    • Default: 100
  • padding: Number
    • Description: The default spacing between the canvas and the container (px)
    • Example: 32
  • scaleMin: Number
    • Description: Canvas minimum scale ratio
    • Example: 0.5
  • scaleMax: Number
    • Description: Canvas maximum scale ratio
    • Example: 10
  • lock: Boolean
    • Description: Lock scale / move / resize
    • Example: false
  • canvasStyle: Object
    • Description: Canvas custom style
    • Example:
      {
        "background": "#FFFFFF"
      }
      
  • chartStyle: Object
    • Description: Chart custom style
    • Example:
      {
        "background": "#1976D255"
      }
      

Events

  • @canvas-scale -> function(scale)

    • Description: Emitted when canvas scale
    • Parameters:
      • scale: Number
        • Description: Scale ratio
  • @canvas-drop -> function(event, position)

    • Description: Drag and drop element from outside the draggable-panel to the canvas
    • Parameters:
      • event: DragEvent
        • Description: DragEvent
      • position: Object
        • x: number
          • Description: Canvas position X
        • y: number
          • Description: Canvas position Y
  • @chart-move -> function(chartItem)

    • Description: Emitted when canvas chart move
    • Parameters:
      • chartItem: Object
        • Description: Chart object in chart array
  • @chart-scale -> function(chartItem)

    • Description: Emitted when canvas chart scale
    • Parameters:
      • chartItem: Object
        • Description: Chart object in chart array

Slots

  • chart

    • Description: Chart default item
    • Required
    • Example:
      <template #chart="{ chart, index }">
          <div>{{ chart }}</div>
      </template>
      
  • chart-[id]

    • Description: Chart for specified ID
    • Example:
      <template #chart-1="{ chart, index }">
          <div>{{ chart }}</div>
      </template>
      
      <template #chart-2="{ chart, index }">
          <div>{{ chart }}</div>
      </template>
      

Thanks For

Related Packages

v3-drag-zoom

一个轻量、高效的缩放拖拽逐渐,帮助开发人员快速实现类似地图缩放拖拽等功能

4,424
@minogin/vue-drag-resize-rotate

Vue component which acts as a draggable, resizable and rotateable container for...

7,341 78
vue-grid-layout

A draggable and resizable grid layout, as a Vue component.

2,102,559 7,398
vue3-grid-layout-next

A draggable and resizable grid layout, as a Vue component.

773,720 129
vue-grid-layout-v3

A draggable and resizable grid layout, as a Vue component.

429,159 113

Version History

Version Released Vue License
1.0.10 ^3.2.25 MIT
1.0.9 ^3.2.25 MIT
1.0.8 ^3.2.25 MIT
1.0.7 ^3.2.25 MIT
1.0.6 ^3.2.25 MIT