@@ -79,6 +79,13 @@ class Dragresize extends Component {
79
79
cy = y ;
80
80
// ay = e.pageY;
81
81
}
82
+
83
+ if ( isRatio ) {
84
+ const bxmm = this . limitScope ( { ax, ay, bx, cy } ) . bx ;
85
+ cy = ay + ( bxmm - ax ) * ratio ;
86
+ const cymm = this . limitScope ( { ax, ay, bx, cy } ) . cy ;
87
+ bx = ( cymm - ay ) / ratio + ax ;
88
+ }
82
89
break ;
83
90
case 'tl' :
84
91
diffX = m_x - x ;
@@ -96,6 +103,13 @@ class Dragresize extends Component {
96
103
ay = y + h ;
97
104
// cy = e.pageY;
98
105
}
106
+
107
+ if ( isRatio ) {
108
+ const axmm = this . limitScope ( { ax, ay, bx, cy } ) . ax ;
109
+ ay = cy - ( bx - axmm ) * ratio ;
110
+ const aymm = this . limitScope ( { ax, ay, bx, cy } ) . ay ;
111
+ ax = bx - ( cy - aymm ) / ratio ;
112
+ }
99
113
break ;
100
114
case 'tr' :
101
115
diffX = m_x - ( x + w ) ;
@@ -113,6 +127,13 @@ class Dragresize extends Component {
113
127
ay = y + h ;
114
128
// cy = e.pageY;
115
129
}
130
+
131
+ if ( isRatio ) {
132
+ const bxmm = this . limitScope ( { ax, ay, bx, cy } ) . bx ;
133
+ ay = cy - ( bxmm - ax ) * ratio ;
134
+ const aymm = this . limitScope ( { ax, ay, bx, cy } ) . ay ;
135
+ bx = ( cy - aymm ) / ratio + ax ;
136
+ }
116
137
break ;
117
138
case 'bl' :
118
139
diffX = m_x - x ;
@@ -130,6 +151,12 @@ class Dragresize extends Component {
130
151
cy = y ;
131
152
// ay = e.pageY;
132
153
}
154
+ if ( isRatio ) {
155
+ const axmm = this . limitScope ( { ax, ay, bx, cy } ) . ax ;
156
+ cy = ay + ( bx - axmm ) * ratio ;
157
+ const cymm = this . limitScope ( { ax, ay, bx, cy } ) . cy ;
158
+ ax = bx - ( cymm - ay ) / ratio ;
159
+ }
133
160
break ;
134
161
}
135
162
const attr = computeAttr ( this . limitScope ( { ax, ay, bx, cy } ) ) ;
@@ -262,11 +289,11 @@ Dragresize.propTypes = {
262
289
Dragresize . defaultProps = {
263
290
elmX : 10 ,
264
291
elmY : 10 ,
265
- elmW : 150 ,
266
- elmH : 100 ,
292
+ elmW : 100 ,
293
+ elmH : 150 ,
267
294
isDrag : true ,
268
295
isResize : true ,
269
- isRatio : false ,
296
+ isRatio : true ,
270
297
isChecked : true ,
271
298
dragScope : {
272
299
minLeft : 10 ,
@@ -277,7 +304,7 @@ Dragresize.defaultProps = {
277
304
sizeScope : {
278
305
minWidth : 30 ,
279
306
minHeight : 30 ,
280
- maxWidth : 200 ,
307
+ maxWidth : null ,
281
308
maxHeight : null ,
282
309
} ,
283
310
onMouseMove : null ,
0 commit comments