All Projects → kirillmurashov → Vue Drag Resize

kirillmurashov / Vue Drag Resize

Licence: mit
Vue Component for resize and drag elements

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Vue Drag Resize

Vue Draggable Resizable Gorkys
Vue 用于可调整大小和可拖动元素的组件并支持冲突检测、元素吸附、元素对齐、辅助线
Stars: ✭ 521 (-48.26%)
Mutual labels:  resize, component, drag, draggable, resizable
React Rnd
🖱 A resizable and draggable component for React.
Stars: ✭ 2,560 (+154.22%)
Mutual labels:  resize, component, drag, draggable, resizable
Vue3 Draggable Resizable
[Vue3 组件] 用于拖拽调整位置和大小的的组件,同时支持冲突检测,元素吸附对齐,实时参考线。
Stars: ✭ 159 (-84.21%)
Mutual labels:  resize, component, drag, draggable, resizable
Svelte Grid
A responsive, draggable and resizable grid layout, for Svelte.
Stars: ✭ 473 (-53.03%)
Mutual labels:  drag, draggable, resizable
Vue Draggable Resizable
Vue2 Component for draggable and resizable elements.
Stars: ✭ 2,431 (+141.41%)
Mutual labels:  component, draggable, resizable
Formdraggerdemo
一个可在窗体内随意拖动窗体的方案
Stars: ✭ 24 (-97.62%)
Mutual labels:  component, drag, draggable
Angular2 Draggable
Angular directive (for version >= 2.x ) that makes the DOM element draggable and resizable
Stars: ✭ 270 (-73.19%)
Mutual labels:  draggable, resizable
Angular Resizable
A lightweight directive for creating resizable containers.
Stars: ✭ 317 (-68.52%)
Mutual labels:  resize, resizable
Ngx Sortablejs
Angular 2+ binding to SortableJS. Previously known as angular-sortablejs
Stars: ✭ 397 (-60.58%)
Mutual labels:  drag, draggable
vue-smart-widget
🗃️Smart widget is a flexible and extensible content container component for Vue2.x / Vue3.x in Next branch.
Stars: ✭ 110 (-89.08%)
Mutual labels:  draggable, resizable
Smooth Dnd
drag and drop library for javascript
Stars: ✭ 408 (-59.48%)
Mutual labels:  drag, draggable
Qt Nice Frameless Window
Qt Frameless Window for both Windows and OS X, support Aero Snap, drop shadow on Windows, and support Native Style such as round corner, drop shadow on OS X. Based on QMainWindow.
Stars: ✭ 430 (-57.3%)
Mutual labels:  draggable, resizable
jsPanel3
A jQuery Plugin to create highly configurable floating panels, modals, tooltips, hints/notifiers or contextmenus for use in a backend solution and other web applications.
Stars: ✭ 89 (-91.16%)
Mutual labels:  draggable, resizable
subjx
Drag/Resize/Rotate Javascript library
Stars: ✭ 155 (-84.61%)
Mutual labels:  resize, drag
Plain Draggable
The simple and high performance library to allow HTML/SVG element to be dragged.
Stars: ✭ 362 (-64.05%)
Mutual labels:  drag, draggable
TNImageView-Android
Android Library for making scale-able and rotatable image views or giving this power to your own image view. This repo has been depreciated.
Stars: ✭ 18 (-98.21%)
Mutual labels:  draggable, resizable
Moveable
Moveable! Draggable! Resizable! Scalable! Rotatable! Warpable! Pinchable! Groupable! Snappable!
Stars: ✭ 6,378 (+533.37%)
Mutual labels:  draggable, resizable
React Range
🎚️Range input with a slider. Accessible. Bring your own styles and markup.
Stars: ✭ 545 (-45.88%)
Mutual labels:  component, draggable
Scrollbooster
Enjoyable content drag-to-scroll library
Stars: ✭ 775 (-23.04%)
Mutual labels:  drag, draggable
vue-sortable-tree
vue tree draggable, drag item sort
Stars: ✭ 87 (-91.36%)
Mutual labels:  drag, draggable

logo

Vue-drag-resize

Latest Version on NPM Software License npm

Vue Component for draggable and resizable elements.

Table of Contents

Demo

Demo

Features

  • A lightweight, no-dependency
  • All props are reactive
  • Support touch events
  • Use draggable, resizable or both
  • Define sticks for resizing
  • Save aspect ratio for resizable components
  • Restrict size and movement to parent element
  • Restrict drag to vertical or horizontal axis

Install and basic usage

$ npm i -s vue-drag-resize

Register the component:

import Vue from 'vue'
import VueDragResize from 'vue-drag-resize'

Vue.component('vue-drag-resize', VueDragResize)

Use the component:

<template>
    <div id="app">
        <VueDragResize :isActive="true" :w="200" :h="200" v-on:resizing="resize" v-on:dragging="resize">
            <h3>Hello World!</h3>
            <p>{{ top }} х {{ left }} </p>
            <p>{{ width }} х {{ height }}</p>
        </VueDragResize>
    </div>
</template>

<script>
    import VueDragResize from 'vue-drag-resize';

    export default {
        name: 'app',

        components: {
            VueDragResize
        },

        data() {
            return {
                width: 0,
                height: 0,
                top: 0,
                left: 0
            }
        },

        methods: {
            resize(newRect) {
                this.width = newRect.width;
                this.height = newRect.height;
                this.top = newRect.top;
                this.left = newRect.left;
            }
        }
    }
</script>

Props

isActive

Type: Boolean
Required: false
Default: false

Determines whether the component should be active. 确定组件是否应处于活动状态。

<vue-drag-resize :isActive="true">

preventActiveBehavior

Type: Boolean
Required: false
Default: false

Disable behavior of the component by clicking on it and clicking outside the component's area (isActive: true / false). If the prop is enabled, the component is oriented only to the specified.

通过单击组件并单击组件区域外部来禁用组件的行为(isActive:true / false)。 如果启用了prop,则组件仅面向指定的。

<vue-drag-resize :preventActiveBehavior="true">

parentW

Type: Number
Required: false
Default: 0

Define the initial width of the parent element. If not specified it calculated automatically. With this parameter, you can set the bounding area for the component, and also it is used when resizing in real time. 定义父元素的初始宽度。 如果未指定,则自动计算。 使用此参数,您可以设置组件的边界区域,并在实时调整大小时使用它。

<vue-drag-resize :parentW="2000">

parentH

Type: Number
Required: false
Default: 0

Define the initial height of the parent element. If not specified it calculated automatically. With this parameter, you can set the bounding area for the component, and also it is used when resizing in real time. 定义父元素的初始高度。 如果未指定,则自动计算。 使用此参数,您可以设置组件的边界区域,并在实时调整大小时使用它。

<vue-drag-resize :parentH="2000">

parentScaleX

Type: Number
Required: false
Default: 1

Define the initial horizontal scale or the parent element. Same value in parent's transform: scale() css definition. The drag/resize and the sticks' sizes will computed with this value. 定义初始水平比例或父元素。父级的transform:scale()css定义中的值相同。 拖动/调整大小和杆的大小将使用该值计算。

<vue-drag-resize :parentScaleX="0.5">

parentScaleY

Type: Number
Required: false
Default: 1

Define the initial vertical scale or the parent element. Same value in parent's transform: scale() css definition. The drag/resize and the sticks' sizes will computed with this value. 定义初始垂直比例或父元素。父级的transform:scale()css定义中的值相同。

拖动/调整大小和杆的大小将使用该值计算。

<vue-drag-resize :parentScaleY="0.5">

isDraggable

Type: Boolean
Required: false
Default: true

Determines whether the component should draggable. 确定组件是否应可拖动。

<vue-drag-resize :isDraggable="false">

isResizable

Type: Boolean
Required: false
Default: true

Determines whether the component should resize. 确定组件是否应调整大小。

<vue-drag-resize :isResizable="false">

parentLimitation

Type: Boolean
Required: false
Default: false

Limits the scope of the component's change to its parent size. 将组件更改的范围限制为其父大小。

<vue-drag-resize :parentLimitation="true">

aspectRatio

Type: Boolean
Required: false
Default: false

Determines whether the component should retain its proportions. 确定组件是否应保持其比例。

<vue-drag-resize :aspectRatio="false">

w

Type: Number
Required: false
Default: 200

Define the initial width of the component. 定义组件的初始宽度。

<vue-drag-resize :w="200">

h

Type: Number
Required: false
Default: 200

Define the initial height of the component. 定义组件的初始高度。

<vue-drag-resize :h="200">

minw

Type: Number
Required: false
Default: 50

Define the minimal width of the component. 定义组件的初始宽度。

<vue-drag-resize :minw="50">

minh

Type: Number
Required: false
Default: 50

Define the minimal height of the component. 定义组件的最小高度。

<vue-drag-resize :minh="50">

x

Type: Number
Required: false
Default: 0

Define the initial x position of the component. 定义组件的初始X位置。

<vue-drag-resize :x="0">

y

Type: Number
Required: false
Default: 0

Define the initial y position of the component. 定义组件的初始Y位置。

<vue-drag-resize :y="0">

z

Type: Number|String
Required: false
Default: auto

Define the zIndex of the component. 定义组件的zindex(层级)。

<vue-drag-resize :z="999">

stickSize

Type: Number
Required: false
Default 8

Define the sticks' size.

<vue-drag-resize :stickSize="12">

sticks

Type: Array
Required: false
Default: ['tl', 'tm', 'tr', 'mr', 'br', 'bm', 'bl', 'ml']

Define the array of handles to restrict the element resizing: 定义句柄数组以限制元素大小调整:

  • tl - Top left
  • tm - Top middle
  • tr - Top right
  • mr - Middle right
  • br - Bottom right
  • bm - Bottom middle
  • bl - Bottom left
  • ml - Middle left
<vue-drag-resize :sticks="['tm','bm','ml','mr']">

axis

Type: String
Required: false
Default: both

Define the axis on which the element is draggable. Available values are x, y, both or none. 定义元素可拖动的轴。 可用值为xybothnone

<vue-drag-resize axis="x">

dragHandle

Type: String
Required: false

Defines the selector that should be used to drag the component. 定义应该用于拖动组件的选择器。

<vue-drag-resize dragHandle=".drag">

dragCancel

Type: String
Required: false

Defines a selector that should be used to prevent drag initialization. 定义应该用于防止拖动初始化的选择器。

<vue-drag-resize dragCancel=".drag">

contentClass

Type: String
Required: false

Defines a class that is applied on the div with the class vdr

<vue-drag-resize contentClass="box-shaddow">

Events

clicked

Required: false
Parameters: Original event handler

Called whenever the component gets clicked. 单击组件时调用。

<vue-drag-resize @clicked="onActivated">

activated

Required: false
Parameters: -

Called whenever the component gets clicked, in order to show handles. 单击组件时调用,以显示句柄。

<vue-drag-resize @activated="onActivated">

deactivated

Required: false
Parameters: -

Called whenever the user clicks anywhere outside the component, in order to deactivate it. 每当用户单击组件外部的任何位置时调用,以便将其停用。

<vue-drag-resize @deactivated="onDeactivated">

resizing

Required: false
Parameters: object

{
    left: Number, //the X position of the component
    top: Number, //the Y position of the component
    width: Number, //the width of the component
    height: Number //the height of the component
}

Called whenever the component gets resized. 每当组件调整大小时调用。

<vue-drag-resize @resizing="onResizing">

resizestop

Required: false
Parameters: object

{
    left: Number, //the X position of the component
    top: Number, //the Y position of the component
    width: Number, //the width of the component
    height: Number //the height of the component
}

Called whenever the component stops getting resized. 每当组件停止调整大小时调用。

<vue-drag-resize @resizestop="onResizstop">

dragging

Required: false
Parameters: object

{
    left: Number, //the X position of the component
    top: Number, //the Y position of the component
    width: Number, //the width of the component
    height: Number //the height of the component
}

Called whenever the component gets dragged. 每当拖动组件时调用。

<vue-drag-resize @dragging="onDragging">

dragstop

Required: false
Parameters: object

{
    left: Number, //the X position of the component
    top: Number, //the Y position of the component
    width: Number, //the width of the component
    height: Number //the height of the component
}

Called whenever the component stops getting dragged. 每当组件停止拖动时调用。

<vue-drag-resize @dragstop="onDragstop">

Contributing

Any contribution to the code or any part of the documentation and any idea and/or suggestion are very welcome.

# serve with hot reload at localhost:8081
npm run start

# distribution build
npm run build

License

MIT license

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].