vue draggable resizable 實(shí)現(xiàn)可拖拽縮放的組件功能
雖然之前適配過(guò)舊版組件,但是因?yàn)?.0版本原作者對(duì)代碼進(jìn)行了重構(gòu),原來(lái)修改的代碼照搬是不可能的了。
所以也就一直沒有將 沖突檢測(cè) 以及 吸附對(duì)齊 功能適配到2.0版本,最近正好有時(shí)間就適配一下。
新增特征
- 沖突檢測(cè)
- 吸附對(duì)齊
- 默認(rèn)樣式優(yōu)化
功能預(yù)覽
項(xiàng)目地址
如果喜歡該項(xiàng)目,歡迎 Star
新增Props
isConflictCheck
Type: Boolean
Required: false
Default: false
定義組件是否開啟沖突檢測(cè)。
<vue-draggable-resizable :is-conflict-check="true">
snap
Type: Boolean
Required: false
Default: false
定義組件是否開啟元素對(duì)齊。
<vue-draggable-resizable :snap="true">
snapTolerance
Type: Number
Required: false
Default: 5
當(dāng)調(diào)用 snap 時(shí),定義組件與元素之間的對(duì)齊距離,以像素(px)為單位。
<vue-draggable-resizable :snap="true" :snap-tolerance="20">
其它屬性請(qǐng)參考 vue-draggable-resizable 官方文檔
安裝使用
$ npm install --save vue-draggable-resizable-gorkys
全局注冊(cè)組件
//main.js import Vue from 'vue' import vdr from 'vue-draggable-resizable-gorkys' // 導(dǎo)入默認(rèn)樣式 import 'vue-draggable-resizable-gorkys/dist/VueDraggableResizable.css' Vue.component('vdr', vdr)
局部注冊(cè)組件
<template> <div style="height: 500px; width: 500px; border: 1px solid red; position: relative;"> <vdr :w="100" :h="100" v-on:dragging="onDrag" v-on:resizing="onResize" :parent="true"> <p>Hello! I'm a flexible component. You can drag me around and you can resize me.<br> X: {{ x }} / Y: {{ y }} - Width: {{ width }} / Height: {{ height }}</p> </vdr> <vdr :w="200" :h="200" :parent="true" :debug="false" :min-width="200" :min-height="200" :isConflictCheck="true" :snap="true" :snapTolerance="20" > </vdr> </div> </template> <script> import vdr from 'vue-draggable-resizable-gorkys' import 'vue-draggable-resizable-gorkys/dist/VueDraggableResizable.css' export default { components: {vdr}, data: function () { return { width: 0, height: 0, x: 0, y: 0 } }, methods: { onResize: function (x, y, width, height) { this.x = x this.y = y this.width = width this.height = height }, onDrag: function (x, y) { this.x = x this.y = y } } } </script>
總結(jié)
以上所述是小編給大家介紹的vue draggable resizable 實(shí)現(xiàn)可拖拽縮放的組件功能 ,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
如果你覺得本文對(duì)你有幫助,歡迎轉(zhuǎn)載,煩請(qǐng)注明出處,謝謝!
相關(guān)文章
vue 點(diǎn)擊其他區(qū)域關(guān)閉自定義div操作
這篇文章主要介紹了vue 點(diǎn)擊其他區(qū)域關(guān)閉自定義div操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-07-07解決Vue項(xiàng)目Network:?unavailable的問題
項(xiàng)目只能通過(guò)Local訪問而不能通過(guò)Network訪問,本文主要介紹了解決Vue項(xiàng)目Network:?unavailable的問題,具有一定的參考價(jià)值,感興趣的可以了解一下2024-06-06vue中filters 傳入兩個(gè)參數(shù) / 使用兩個(gè)filters的實(shí)現(xiàn)方法
這篇文章主要介紹了vue中filters 傳入兩個(gè)參數(shù) / 使用兩個(gè)filters的實(shí)現(xiàn)方法,文中給大家提到了Vue 中的 filter 帶多參的使用方法,需要的朋友可以參考下2019-07-07Vue中實(shí)現(xiàn)回車鍵切換焦點(diǎn)的方法
這篇文章主要介紹了在Vue中實(shí)現(xiàn)回車鍵切換焦點(diǎn)的方法,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-02-02Vue ElementUI this.$confirm async await封
這篇文章主要介紹了Vue ElementUI this.$confirm async await封裝方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-09-09element日期選擇器el-date-picker樣式圖文詳解
最近寫的項(xiàng)目里面有一個(gè)功能是日期選擇功能,第一反應(yīng)是使用element里面的el-date-picker組件,下面這篇文章主要給大家介紹了關(guān)于element日期選擇器el-date-picker樣式的相關(guān)資料,需要的朋友可以參考下2022-09-09Vue 基礎(chǔ)語(yǔ)法之計(jì)算屬性(computed)、偵聽器(watch)、過(guò)濾器(filters)詳解
計(jì)算屬性就是 Vue 實(shí)例選項(xiàng)中的 computed,computed 的值是一個(gè)對(duì)象類型,對(duì)象中的屬性值為函數(shù),而且這個(gè)函數(shù)沒辦法接收參數(shù),這篇文章主要介紹了Vue 基礎(chǔ)語(yǔ)法之計(jì)算屬性(computed)、偵聽器(watch)、過(guò)濾器(filters)詳解,需要的朋友可以參考下2022-11-11