New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

vue3-draggable-resizable

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue3-draggable-resizable

[Vue3 Component] Draggable and resizable component for vue3

  • 1.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.9K
increased by12%
Maintainers
1
Weekly downloads
 
Created
Source

Vue3DraggableResizable

npm version Software License npm vue version

[ Vue3 Component ] Draggable and resizable component for vue3

点击查看中文文档

Features

  • Draggable and resizable
  • Define handles for resizing
  • Restrict movement and size in parent node
  • Customize various class names
  • Provide your own markup for handles

Usage

$ npm install vue3-draggable-resizable

Register the Vue3DraggableResizable

// >main.js
import { createApp } from 'vue'
import App from './App.vue'
import Vue3DraggableResizable from 'vue3-draggable-resizable'
//default styles
import 'vue3-draggable-resizable/dist/Vue3DraggableResizable.css'

// You will have a global component named "Vue3DraggableResizable"
createApp(App)
  .use(Vue3DraggableResizable)
  .mount('#app')

You can also use it separately within the component

// >component.js
import { defineComponent } from 'vue'
import Vue3DraggableResizable from 'vue3-draggable-resizable'
//default styles
import 'vue3-draggable-resizable/dist/Vue3DraggableResizable.css'

export default defineComponent({
  components: { Vue3DraggableResizable }
  // ...other
})

Here is a complete example of using "vue-template"

<template>
  <div id="app">
    <div class="parent">
      <Vue3DraggableResizable
        :initW="110"
        :initH="120"
        v-model:x="x"
        v-model:y="y"
        v-model:w="w"
        v-model:h="h"
        v-model:active="active"
        :draggable="true"
        :resizable="true"
        @activated="print('activated')"
        @deactivated="print('deactivated')"
        @drag-start="print('drag-start')"
        @resize-start="print('resize-start')"
        @dragging="print('dragging')"
        @resizing="print('resizing')"
        @drag-end="print('drag-end')"
        @resize-end="print('resize-end')"
      >
        This is a test example
      </Vue3DraggableResizable>
    </div>
  </div>
</template>

<script>
import { defineComponent } from 'vue'
import Vue3DraggableResizable from 'vue3-draggable-resizable'
//default styles
import 'vue3-draggable-resizable/dist/Vue3DraggableResizable.css'
export default defineComponent({
  components: { Vue3DraggableResizable },
  data() {
    return {
      x: 100,
      y: 100,
      h: 100,
      w: 100,
      active: false
    }
  },
  methods: {
    print(val) {
      console.log(val)
    }
  }
})
</script>
<style>
.parent {
  width: 200px;
  height: 200px;
  position: absolute;
  top: 100px;
  left: 100px;
  border: 1px solid #000;
  user-select: none;
}
</style>

Props

initW

type: Number
default: null

Set initial width(px)

<Vue3DraggableResizable :initW="100" />
initH

type: Number
default: null

Set initial height(px)

<Vue3DraggableResizable :initH="100" />
w

type: Number
default: 0

Current width(px) of the container.
You can use "v-model:w" to keeps it up-to-date

<Vue3DraggableResizable v-model:w="100" />
h

type: Number
default: 0

Current height(px) of the container.
You can use "v-model:h" to keeps it up-to-date

<Vue3DraggableResizable v-model:h="100" />
x

type: Number
default: 0

Current left(px) of the container.
You can use "v-model:x" to keeps it up-to-date

<Vue3DraggableResizable v-model:x="100" />
y

type: Number
default: 0

The current top(px) of the container.
You can use "v-model:y" to keeps it up-to-date

<Vue3DraggableResizable v-model:y="100" />
minW

type: Number
default: 20

Minimum width(px)

<Vue3DraggableResizable :minW="100" />
minH

type: Number
default: 20

Minimum height(px)

<Vue3DraggableResizable :minH="100" />
active

type: Boolean
default: false

Indicates whether the component is selected.
You can use "v-model:active" to keeps it up-to-date

<Vue3DraggableResizable v-model:active="100" />
draggable

type: Boolean
default: true

Defines the component can be draggable or not

<Vue3DraggableResizable :draggable="true" />
resizable

type: Boolean
default: true

Defines the component can be resizable or not

<Vue3DraggableResizable :draggable="true" />
disabledX

type: Boolean
default: false

Defines the component can be moved on x-axis or not

<Vue3DraggableResizable :disabledX="true" />
disabledY

type: Boolean
default: false

Defines the component can be moved on y-axis or not

<Vue3DraggableResizable :disabledY="true" />
disabledW

type: Boolean
default: false

Defines the component`s width can be modify or not

<Vue3DraggableResizable :disabledW="true" />
disabledH

type: Boolean
default: false

Defines the component`s height can be modify or not

<Vue3DraggableResizable :disabledH="true" />
parent

type: Boolean
default: false

Restrict movement and size within its parent node

<Vue3DraggableResizable :parent="true" />
handles

type: Array
default: ['tl', 'tm', 'tr', 'ml', 'mr', 'bl', 'bm', 'br']

Define the array of handles to restrict the element resizing

  • tl : Top left
  • tm : Top middle
  • tr : Top right
  • mr : Middle right
  • ml : Middle left
  • bl : Bottom left
  • bm : Bottom middle
  • br : Bottom right
<Vue3DraggableResizable :handles="['tl','tr','bl','br']" />
classNameDraggable

type: String
default: draggable

Used to set the custom class of a draggable-resizable component when draggable is enable.

<Vue3DraggableResizable classNameDraggable="draggable" />
classNameResizable

type: String
default: resizable

Used to set the custom class of a draggable-resizable component when resizable is enable.

<Vue3DraggableResizable classNameResizable="resizable" />
classNameDragging

type: String
default: dragging

Used to set the custom class of a draggable-resizable component when is dragging.

<Vue3DraggableResizable classNameDragging="dragging" />
classNameResizing

type: String
default: resizing

Used to set the custom class of a draggable-resizable component when is resizing.

<Vue3DraggableResizable classNameResizing="resizing" />
classNameActive

type: String
default: active

Used to set the custom class of a draggable-resizable component when is active.

<Vue3DraggableResizable classNameActive="active" />
classNameHandle

type: String
default: handle

Used to set the custom common class of each handle element.

<Vue3DraggableResizable classNameHandle="my-handle" />

following handle nodes will be rendered

...
<div class="vdr-handle vdr-handle-tl my-handle my-handle-tl"></div>
<div class="vdr-handle vdr-handle-tm my-handle my-handle-tm"></div>
<div class="vdr-handle vdr-handle-tr my-handle my-handle-tr"></div>
<div class="vdr-handle vdr-handle-ml my-handle my-handle-mr"></div>
...

Events

activated

payload: -

<Vue3DraggableResizable @activated="activatedHandle" />
deactivated

payload: -

<Vue3DraggableResizable @deactivated="deactivatedHandle" />
drag-start

payload: { x: number, y: number }

<Vue3DraggableResizable @drag-start="dragStartHandle" />
dragging

payload: { x: number, y: number }

<Vue3DraggableResizable @dragging="dragStartHandle" />
drag-end

payload: { x: number, y: number }

<Vue3DraggableResizable @drag-end="dragEndHandle" />
resize-start

payload: { x: number, y: number, w: number, h: number }

<Vue3DraggableResizable @resize-start="resizeStartHandle" />
resizing

payload: { x: number, y: number, w: number, h: number }v

<Vue3DraggableResizable @resizing="resizingHandle" />
resize-end

payload: { x: number, y: number, w: number, h: number }

<Vue3DraggableResizable @resize-end="resizeEndHandle" />

Keywords

FAQs

Package last updated on 12 Nov 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc