Skip to content

Commit 51d5310

Browse files
author
kirillmurashov
committed
Added: initial "auto" for width and height props
1 parent e2537c2 commit 51d5310

File tree

4 files changed

+79
-41
lines changed

4 files changed

+79
-41
lines changed

README.md

Lines changed: 51 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
<p align="center">
55

6-
[![Latest Version on NPM](https://img.shields.io/npm/v/vue-drag-resize.svg?style=flat-square)](https://npmjs.com/package/vue-drag-resize)
7-
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)
8-
[![npm](https://img.shields.io/npm/dt/vue-drag-resize.svg?style=flat-square)](https://www.npmjs.com/package/vue-drag-resize)
6+
[![Latest Version on NPM](https://img.shields.io/npm/v/vue-drag-resize.svg?style=flat-square)](https://npmjs.com/package/vue-drag-resize)
7+
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)
8+
[![npm](https://img.shields.io/npm/dt/vue-drag-resize.svg?style=flat-square)](https://www.npmjs.com/package/vue-drag-resize)
99
</p>
1010

1111
<p align="center">
@@ -31,7 +31,7 @@
3131

3232
### Features
3333

34-
* A lightweight, no-dependency
34+
* A lightweight, no-dependency
3535
* All props are reactive
3636
* Support touch events
3737
* Snap element to custom grid
@@ -43,14 +43,10 @@
4343

4444
## Install and basic usage
4545

46-
For Vue2:
4746
```bash
4847
$ npm i -s vue-drag-resize
4948
```
50-
For Vue3:
51-
```bash
52-
$ npm i -s vue-drag-resize@next
53-
```
49+
5450

5551
Register the component:
5652

@@ -112,7 +108,8 @@ Type: `Boolean`<br>
112108
Required: `false`<br>
113109
Default: `false`
114110

115-
Determines whether the component should be active.
111+
Determines whether the component should be active.
112+
116113
确定组件是否应处于活动状态。
117114

118115
```html
@@ -124,10 +121,10 @@ Type: `Boolean`<br>
124121
Required: `false`<br>
125122
Default: `false`
126123

127-
Disable behavior of the component by clicking on it and clicking outside the component's area (isActive: true / false).
124+
Disable behavior of the component by clicking on it and clicking outside the component's area (isActive: true / false).<br>
128125
If the prop is enabled, the component is oriented only to the specified.
129126

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

133130
```html
@@ -139,9 +136,10 @@ Type: `Number`<br>
139136
Required: `false`<br>
140137
Default: `0`
141138

142-
Define the initial width of the parent element. If not specified it calculated automatically.
139+
Define the initial width of the parent element. If not specified it calculated automatically.<br>
143140
With this parameter, you can set the bounding area for the component, and also it is used when resizing in real time.
144-
定义父元素的初始宽度。 如果未指定,则自动计算。
141+
142+
定义父元素的初始宽度。 如果未指定,则自动计算。<br>
145143
使用此参数,您可以设置组件的边界区域,并在实时调整大小时使用它。
146144
```html
147145
<vue-drag-resize :parentW="2000">
@@ -152,8 +150,9 @@ Type: `Number`<br>
152150
Required: `false`<br>
153151
Default: `0`
154152

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

@@ -166,9 +165,10 @@ Type: `Number`<br>
166165
Required: `false`<br>
167166
Default: `1`
168167

169-
Define the initial horizontal scale or the parent element. Same value in parent's transform: scale() css definition.
168+
Define the initial horizontal scale or the parent element. Same value in parent's transform: scale() css definition.<br>
170169
The drag/resize and the sticks' sizes will computed with this value.
171-
定义初始水平比例或父元素。父级的transform:scale()css定义中的值相同。
170+
171+
定义初始水平比例或父元素。父级的transform:scale()css定义中的值相同。<br>
172172
拖动/调整大小和杆的大小将使用该值计算。
173173
```html
174174
<vue-drag-resize :parentScaleX="0.5">
@@ -179,10 +179,10 @@ Type: `Number`<br>
179179
Required: `false`<br>
180180
Default: `1`
181181

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

185+
定义初始垂直比例或父元素。父级的transform:scale()css定义中的值相同。<br>
186186
拖动/调整大小和杆的大小将使用该值计算。
187187

188188
```html
@@ -195,6 +195,7 @@ Required: `false`<br>
195195
Default: `true`
196196

197197
Determines whether the component should draggable.
198+
198199
确定组件是否应可拖动。
199200

200201

@@ -208,6 +209,7 @@ Required: `false`<br>
208209
Default: `true`
209210

210211
Determines whether the component should resize.
212+
211213
确定组件是否应调整大小。
212214

213215

@@ -220,6 +222,7 @@ Required: `false`<br>
220222
Default: `false`
221223

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

225228

@@ -259,13 +262,14 @@ Define the grid step size for the vertical axis. Both sides of the component (to
259262
```html
260263
<vue-drag-resize :snapToGrid="true" :gridY="20">
261264
```
262-
265+
263266
#### aspectRatio
264267
Type: `Boolean`<br>
265268
Required: `false`<br>
266269
Default: `false`
267270

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

271275

@@ -274,11 +278,14 @@ Determines whether the component should retain its proportions.
274278
```
275279

276280
#### w
277-
Type: `Number`<br>
281+
Type: `Number|String`<br>
278282
Required: `false`<br>
279283
Default: `200`
280284

281-
Define the initial width of the component.
285+
Define the initial width of the component.<br>
286+
The value can either be a number >= 0 or the string 'auto'. <br>
287+
If set to 'auto', the initial width value will be equal to the width of the content within the component.
288+
282289
定义组件的初始宽度。
283290

284291

@@ -287,11 +294,14 @@ Define the initial width of the component.
287294
```
288295

289296
#### h
290-
Type: `Number`<br>
297+
Type: `Number|String`<br>
291298
Required: `false`<br>
292299
Default: `200`
293300

294-
Define the initial height of the component.
301+
Define the initial height of the component.<br>
302+
The value can either be a number >= 0 or the string 'auto'. <br>
303+
If set to 'auto', the initial height value will be equal to the height of the content within the component.
304+
295305
定义组件的初始高度。
296306

297307

@@ -306,6 +316,7 @@ Required: `false`<br>
306316
Default: `50`
307317

308318
Define the minimal width of the component.
319+
309320
定义组件的初始宽度。
310321

311322

@@ -320,6 +331,7 @@ Required: `false`<br>
320331
Default: `50`
321332

322333
Define the minimal height of the component.
334+
323335
定义组件的最小高度。
324336

325337

@@ -333,6 +345,7 @@ Required: `false`<br>
333345
Default: `0`
334346

335347
Define the initial x position of the component.
348+
336349
定义组件的初始X位置。
337350

338351

@@ -346,6 +359,7 @@ Required: `false`<br>
346359
Default: `0`
347360

348361
Define the initial y position of the component.
362+
349363
定义组件的初始Y位置。
350364

351365

@@ -359,6 +373,7 @@ Required: `false`<br>
359373
Default: `auto`
360374

361375
Define the zIndex of the component.
376+
362377
定义组件的zindex(层级)。
363378

364379
```html
@@ -382,6 +397,7 @@ Required: `false`<br>
382397
Default: `['tl', 'tm', 'tr', 'mr', 'br', 'bm', 'bl', 'ml']`
383398

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

387403
* `tl` - Top left
@@ -403,6 +419,7 @@ Required: `false`<br>
403419
Default: `both`
404420

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

408425
```html
@@ -414,6 +431,7 @@ Type: `String`<br>
414431
Required: `false`
415432

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

419437
```html
@@ -425,6 +443,7 @@ Type: `String`<br>
425443
Required: `false`
426444

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

430449
```html
@@ -454,6 +473,7 @@ Required: `false`<br>
454473
Parameters: `Original event handler`
455474

456475
Called whenever the component gets clicked.
476+
457477
单击组件时调用。
458478

459479
```html
@@ -466,6 +486,7 @@ Required: `false`<br>
466486
Parameters: `-`
467487

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

471492
```html
@@ -478,6 +499,7 @@ Required: `false`<br>
478499
Parameters: `-`
479500

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

483505

@@ -500,6 +522,7 @@ Parameters: `object`
500522
```
501523

502524
Called whenever the component gets resized.
525+
503526
每当组件调整大小时调用。
504527

505528

@@ -521,6 +544,7 @@ Parameters: `object`
521544
```
522545

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

526550

@@ -542,6 +566,7 @@ Parameters: `object`
542566
```
543567

544568
Called whenever the component gets dragged.
569+
545570
每当拖动组件时调用。
546571

547572

@@ -564,6 +589,7 @@ Parameters: `object`
564589

565590

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

569595

@@ -586,4 +612,4 @@ npm run build
586612

587613
## License
588614

589-
[MIT license](LICENSE)
615+
[MIT license](LICENSE)

src/components/vue-drag-resize.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,8 @@
3939
}
4040
.vdr-stick.not-resizable{
4141
display: none;
42+
}
43+
.content-container{
44+
display: block;
45+
position: relative;
4246
}

src/components/vue-drag-resize.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
<div class="vdr" :style="style"
1+
<div class="vdr" :style="positionStyle"
22
:class="`${(active || isActive) ? 'active' : 'inactive'} ${contentClass ? contentClass: ''}`"
33
@mousedown="bodyDown($event)"
44
@touchstart="bodyDown($event)"
55
@touchend="up($event)">
6-
<slot></slot>
6+
<div :style="sizeStyle" class="content-container" ref="container2">
7+
<slot></slot>
8+
</div>
79
<div
810
v-for="stick in sticks"
911
class="vdr-stick"

0 commit comments

Comments
 (0)