vueどのようにドラッグしてコンポーネントのサイズを変更しますか?Vueコンポーネントは、ドラッグやサイズ調整が可能な要素です。
10111 ワード
vueはどのようにドラッグしてコンポーネントのサイズを変えますか?
Vueドラッグでサイズ調整(Vue-drag-resize)
Vue Component for resize and drag elemens.
Vueコンポーネントは、サイズを調整したり、ドラッグしたりします。
View demoデモンストレーションDownload Sourceダウンロード元
特徴(Feature) A lightweight、no-dependencyは軽くて、 に依存しません。 Use draggable、resizable or bothはドラッグ可能で、サイズを調整したり、 を同時に使用したりすることができます。 Define sticks for resizing定義棒はサイズを調整します。 Save aspect ratio for resizable componentsは、サイズ調整可能なコンポーネントのためのアスペクト比 を保存します。 Restict size and movement to parent element制限サイズと親要素 に移動 Restict drag to vertical or horizontal axis制限を垂直または水平軸 にドラッグします。
インストールと基本的な使い方(Install and baic usage)
登録コンポーネント:
コンポーネントを使う:
アクティブ(isActive)
Type:
コンポーネントがアクティブな状態にあるべきかどうかを判定します。
Type:
コンポーネントがドラッグすべきかどうかを決定します。
Type:
コンポーネントがサイズを調整すべきかどうかを決定します。
Type:
コンポーネント変更の範囲を親サイズに制限します。
Type:
コンポーネントがその比率を保持すべきかどうかを決定します。
Type:
コンポーネントの初期幅を指定します。
Type:
コンポーネントの初期高さを指定します。
Type:
コンポーネントの最小幅を指定します。
Type:
コンポーネントの最小高さを指定します。
Type:
コンポーネントの初期x位置を指定します。
Type:
コンポーネントの初期y位置を指定します。
Type:
コンポーネントのzIndexを定義します。
Type:
ハンドル配列を定義して要素のサイズ調整を制限します。
Type:
ドラッグ可能な要素の軸を指定します。利用可能な値は
アクティブ(activated)
Required:
コンポーネントが表示されるたびに、このコンポーネントをクリックしてハンドルを呼び出します。
Required:
ユーザーがコンポーネントの外部のどの位置をクリックして、それを停止するたびに呼び出します。
Required:
調整コンポーネントが大きいたびに呼び出します。
Required:
コンポーネントが停止するたびに、大きい時間で呼び出します。
Required:
コンポーネントをドラッグするたびに呼び出します。
Required:
コンポーネントがドラッグを停止するたびに呼び出します。
Any contribution to the code or any parth of the documentation and any idea/or suggaestion are very welcome.
コードまたはドキュメントの任意の部分に貢献することを歓迎し、任意のアイデアと/または提案を提出します。
vueはどのようにドラッグしてコンポーネントのサイズを変えますか?
Vueドラッグでサイズ調整(Vue-drag-resize)
Vue Component for resize and drag elemens.
Vueコンポーネントは、サイズを調整したり、ドラッグしたりします。
View demoデモンストレーションDownload Sourceダウンロード元
特徴(Feature)
インストールと基本的な使い方(Install and baic 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:コンポーネントを使う:
Hello World!
{{ top }} х {{ left }}
{{ width }} х {{ height }}
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;
}
}
}
アイテム(Props)アクティブ(isActive)
Type:
Boolean
Required:false
Default:false
タイプ:Boolean
必須:false
デフォルト値:false
Determines whether the component shuld be active.コンポーネントがアクティブな状態にあるべきかどうかを判定します。
isDraggable(isDraggable)Type:
Boolean
Required:false
Default:true
タイプ:Boolean
必須:false
デフォルト値:true
Determines whether the component shuld draggable.コンポーネントがドラッグすべきかどうかを決定します。
ISResizableType:
Boolean
Required:false
Default:true
タイプ:Boolean
必須:false
デフォルト値:true
Determines whether the component shuld resize.コンポーネントがサイズを調整すべきかどうかを決定します。
親制限(parent Limitation)Type:
Boolean
Required:false
Default:false
タイプ:Boolean
必須:false
デフォルト値:false
Limits the scope of the component's change to its parent size.コンポーネント変更の範囲を親サイズに制限します。
AsppectRatio(aspectRatio)Type:
Boolean
Required:false
Default:false
タイプ:Boolean
必須:false
デフォルト値:false
Determines whether the component shound retain its propotions.コンポーネントがその比率を保持すべきかどうかを決定します。
w(w)Type:
Number
Required:false
Default:200
タイプ:Number
必須:false
デフォルト値:200
Define the initial width of the component.コンポーネントの初期幅を指定します。
H(h)Type:
Number
Required:false
Default:200
タイプ:Number
必須:false
デフォルト値:200
Define the initial height of the component.コンポーネントの初期高さを指定します。
w(minw)Type:
Number
Required:false
Default:50
タイプ:Number
必須:false
デフォルト値:50
Define the minimal width of the component.コンポーネントの最小幅を指定します。
h(minh)Type:
Number
Required:false
Default:50
タイプ:Number
必須:false
デフォルト値:50
Define the minimal height of the component.コンポーネントの最小高さを指定します。
X(x)Type:
Number
Required:false
Default:0
タイプ:Number
必須:false
デフォルト値:0
Define the initial x position of the component.コンポーネントの初期x位置を指定します。
湖南省にある地名Type:
Number
Required:false
Default:0
タイプ:Number
必須:false
デフォルト値:0
Define the initial y position of the component.コンポーネントの初期y位置を指定します。
ž (z)Type:
Number|String
Required:false
Default:auto
タイプ:Number|String
必須:false
デフォルト値:auto
Define the zIndex of the component.コンポーネントのzIndexを定義します。
棍棒(sticks)Type:
Array
Required:false
Default:['tl', 'tm', 'tr', 'mr', 'br', 'bm', 'bl', 'ml']
タイプ:Array
必須:false
デフォルト値:['tl', 'tm', 'tr', 'mr', 'br', 'bm', 'bl', 'ml']
Define the array of handles to restict the element resizing:ハンドル配列を定義して要素のサイズ調整を制限します。
tl
-Top left tl
左上tm
-Top middle tm
中高層tr
-Top right tr
右上mr
-Middle right mr
-右中br
-Bottom right br
-右下bm
-Bottom middle bm
底部中間bl
-Bottom left bl
左下ml
-Middle left ml
左中
軸(axis)Type:
String
Required:false
Default:both
タイプ:String
必須:false
デフォルト値:both
Define the axis on which the element is draggable.Available values are x
、y
、both
or none
.ドラッグ可能な要素の軸を指定します。利用可能な値は
x
、y
、both
none
です。
大事記(Events)アクティブ(activated)
Required:
false
Parameters:-
必要:false
パラメータ:-
Called whenever the component gets clicked,in order to show handles.コンポーネントが表示されるたびに、このコンポーネントをクリックしてハンドルを呼び出します。
無効(deactivated)Required:
false
Parameters:-
必要:false
パラメータ:-
Called whenever the user clicks anywhere out side the component,in order to deactivate it.ユーザーがコンポーネントの外部のどの位置をクリックして、それを停止するたびに呼び出します。
サイズを調整します。Required:
false
Parameters:object
必要:false
パラメータ: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.調整コンポーネントが大きいたびに呼び出します。
サイズを調整します。Required:
false
Parameters:object
必要:false
パラメータ: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.コンポーネントが停止するたびに、大きい時間で呼び出します。
ドラッグ(dragging)Required:
false
Parameters:object
必要:false
パラメータ: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.コンポーネントをドラッグするたびに呼び出します。
ドラッグ停止(dragstop)Required:
false
Parameters:object
必要:false
パラメータ: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.コンポーネントがドラッグを停止するたびに呼び出します。
貢献(Conttributing)Any contribution to the code or any parth of the documentation and any idea/or suggaestion are very welcome.
コードまたはドキュメントの任意の部分に貢献することを歓迎し、任意のアイデアと/または提案を提出します。
# serve with hot reload at localhost:8081
npm run start
# distribution build
npm run build
翻訳元:https://vuejsexamples.com/vue-component-for-draggable-and-resizable-elements/ vueはどのようにドラッグしてコンポーネントのサイズを変えますか?