1.2.0 • Published 11 months ago

@neosjs/vue-dragresizable v1.2.0

Weekly downloads
-
License
MIT
Repository
-
Last release
11 months ago

@neosjs/vue-dragresizable

NPM Version NPM Downloads NPM Downloads NPM License Vue Dragresizable

Vue组件用于可拖动和可调整大小的元素。

注意:带 beta 的版本为支持 Vue2 的版本

安装

pnpm add @neosjs/vue-dragresizable
# or
npm install @neosjs/vue-dragresizable

使用方法

<script lang="ts" setup>
import VueDragresizable from '@neosjs/vue-dragresizable'

const handles = ref(['tl', 'tm', 'tr', 'mr', 'br', 'bm', 'bl', 'ml'])
const fitParent = ref(false)
const width = ref(338)
const height = ref(250)
const maxW = ref('100%')
const maxH = ref('100%')
const minW = ref(338)
const minH = ref(250)
const dragSelector = ref('.drag-header')
const left = ref(`calc( 50% - ${width.value / 2}px)`)
const top = ref(`calc(50% - ${height.value / 2}px)`)
const maximize = ref(false)
const checkEmpty = (value) => {
  return typeof value !== 'number' ? 0 : value
}
</script>

<template>
  <div>
    <VueDragresizable
      :drag-selector="dragSelector"
      :maximize="maximize"
      :handles="handles"
      :fit-parent="fitParent"
      :width="width"
      :height="height"
      :max-width="checkEmpty(maxW)"
      :max-height="checkEmpty(maxH)"
      :min-width="checkEmpty(minW)"
      :min-height="checkEmpty(minH)"
      :x="left"
      :y="top"
      class="resizable"
    >
      <div class="resizable-content">
        <p class="drag-header">
          <span>标题</span>
        </p>
        <p>这里是内容哦</p>
        <p>这里是内容哦</p>
      </div>
    </VueDragresizable>
  </div>
</template>

Props

参数说明类型默认值
width初始宽度String、Number-
height初始高度String、Number-
max-width最大宽度Number-
max-height最大高度Number-
min-width最小宽度Number0
min-height最小高度Number0
x(left)初始 x 坐标String、Number0
y(top)初始 y 坐标String、Number0
zIndexz-index 层级String、Numberauto
lockRatio是否锁定比例Booleanfalse
hideHandles是否隐藏 handlesBooleanfalse
handles调整大小的点位(可拖拽放大的点位)String 'tl', 'tm', 'tr', 'mr', 'br', 'bm', 'bl', 'ml'-
roundHandle是否圆角 handlesBooleanfalse
fitParent在父级容器里调整大小Booleanfalse
maximize是否允许最大化Booleanfalse
active是否激活Booleantrue
dragSelector拖拽选择器String-
dragCancel拖拽取消选择器String-
classNameResizable自定义 Resizable 类名String-
classNameResizing自定义 Resizing 类名String-
classNameDraggable自定义 Draggable 类名String-
classNameDragging自定义 Dragging 类名String-
classNameActive自定义 Active 类名String-
classNameHandle自定义 Handle 类名String-
grid元素所在的网格Number, Number1, 1
axis可拖动元素的轴String 'x', 'y', 'both'both
scale缩放比例Number、Array1
onDragStart拖拽开始回调Function-
onDrag拖拽时的回调Function-
onResizeStart调整大小开始回调Function-
onResize调整大小时的回调Function-

Events

事件名说明回调参数
mounted组件挂载完成时触发eventName、left、top、width、height
destroyed组件销毁时触发eventName、left、top、width、height
deactivated组件失活时触发eventName、left、top、width、height
resizeMove、resizeing调整大小时触发eventName、left、top、width、height
resizeEnd、resizeStop调整大小结束时触发eventName、left、top、width、height
dragMove、dragging拖拽时触发eventName、left、top、width、height
dragEnd、dragStop拖拽结束时触发eventName、left、top、width、height
maximize最大化时触发eventName、left、top、width、height、state

handles

  • tl - Top left
  • tm - Top middle
  • tr - Top right
  • mr - Middle right
  • br - Bottom right
  • bm - Bottom middle
  • bl - Bottom left
  • ml - Middle left

License

MIT License © 2021-PRESENT NeosJS

1.2.0

11 months ago

1.1.1

12 months ago

1.0.2

12 months ago

1.1.0

12 months ago

1.0.2-beta.1

12 months ago

1.1.3

12 months ago

1.1.2

12 months ago

1.1.0-beta.1

12 months ago

1.1.1-beta.1

12 months ago

1.0.1

1 year ago

1.0.0

1 year ago