@@ -67,8 +67,13 @@ export const getNewStyle = (type, rect, deltaW, deltaH, ratio, minWidth, minHeig
67
67
height = heightAndDeltaH . height
68
68
deltaH = heightAndDeltaH . deltaH
69
69
if ( ratio ) {
70
- deltaW = deltaH * ratio
71
- width = height * ratio
70
+ if ( ratio > 1 ) {
71
+ height = width / ratio
72
+ deltaH = deltaW / ratio
73
+ } else {
74
+ width = height * ratio
75
+ deltaW = deltaH * ratio
76
+ }
72
77
}
73
78
centerX += deltaW / 2 * cos ( rotateAngle ) + deltaH / 2 * sin ( rotateAngle )
74
79
centerY += deltaW / 2 * sin ( rotateAngle ) - deltaH / 2 * cos ( rotateAngle )
@@ -82,8 +87,13 @@ export const getNewStyle = (type, rect, deltaW, deltaH, ratio, minWidth, minHeig
82
87
height = heightAndDeltaH . height
83
88
deltaH = heightAndDeltaH . deltaH
84
89
if ( ratio ) {
85
- deltaW = deltaH * ratio
86
- width = height * ratio
90
+ if ( ratio > 1 ) {
91
+ height = width / ratio
92
+ deltaH = deltaW / ratio
93
+ } else {
94
+ width = height * ratio
95
+ deltaW = deltaH * ratio
96
+ }
87
97
}
88
98
centerX += deltaW / 2 * cos ( rotateAngle ) - deltaH / 2 * sin ( rotateAngle )
89
99
centerY += deltaW / 2 * sin ( rotateAngle ) + deltaH / 2 * cos ( rotateAngle )
@@ -115,8 +125,13 @@ export const getNewStyle = (type, rect, deltaW, deltaH, ratio, minWidth, minHeig
115
125
height = heightAndDeltaH . height
116
126
deltaH = heightAndDeltaH . deltaH
117
127
if ( ratio ) {
118
- height = width / ratio
119
- deltaH = deltaW / ratio
128
+ if ( ratio > 1 ) {
129
+ height = width / ratio
130
+ deltaH = deltaW / ratio
131
+ } else {
132
+ width = height * ratio
133
+ deltaW = deltaH * ratio
134
+ }
120
135
}
121
136
centerX -= deltaW / 2 * cos ( rotateAngle ) + deltaH / 2 * sin ( rotateAngle )
122
137
centerY -= deltaW / 2 * sin ( rotateAngle ) - deltaH / 2 * cos ( rotateAngle )
@@ -150,8 +165,13 @@ export const getNewStyle = (type, rect, deltaW, deltaH, ratio, minWidth, minHeig
150
165
height = heightAndDeltaH . height
151
166
deltaH = heightAndDeltaH . deltaH
152
167
if ( ratio ) {
153
- width = height * ratio
154
- deltaW = deltaH * ratio
168
+ if ( ratio > 1 ) {
169
+ height = width / ratio
170
+ deltaH = deltaW / ratio
171
+ } else {
172
+ width = height * ratio
173
+ deltaW = deltaH * ratio
174
+ }
155
175
}
156
176
centerX -= deltaW / 2 * cos ( rotateAngle ) - deltaH / 2 * sin ( rotateAngle )
157
177
centerY -= deltaW / 2 * sin ( rotateAngle ) + deltaH / 2 * cos ( rotateAngle )
0 commit comments