@@ -14,17 +14,17 @@ export function checkCropperSizeRestriction(cropperPosition: CropperPosition, cr
14
14
const centerY = cropperPosition . y1 + cropperHeight / 2 ;
15
15
16
16
if ( cropperState . options . cropperStaticHeight && cropperState . options . cropperStaticWidth ) {
17
- cropperWidth = cropperState . maxSize ! . width > cropperState . options . cropperStaticWidth
17
+ cropperWidth = cropperState . maxSize ( ) . width > cropperState . options . cropperStaticWidth
18
18
? cropperState . options . cropperStaticWidth
19
- : cropperState . maxSize ! . width ;
20
- cropperHeight = cropperState . maxSize ! . height > cropperState . options . cropperStaticHeight
19
+ : cropperState . maxSize ( ) . width ;
20
+ cropperHeight = cropperState . maxSize ( ) . height > cropperState . options . cropperStaticHeight
21
21
? cropperState . options . cropperStaticHeight
22
- : cropperState . maxSize ! . height ;
22
+ : cropperState . maxSize ( ) . height ;
23
23
} else {
24
- cropperWidth = Math . max ( cropperState . cropperScaledMinWidth , Math . min ( cropperWidth , cropperState . cropperScaledMaxWidth , cropperState . maxSize ! . width ) ) ;
25
- cropperHeight = Math . max ( cropperState . cropperScaledMinHeight , Math . min ( cropperHeight , cropperState . cropperScaledMaxHeight , cropperState . maxSize ! . height ) ) ;
24
+ cropperWidth = Math . max ( cropperState . cropperScaledMinWidth , Math . min ( cropperWidth , cropperState . cropperScaledMaxWidth , cropperState . maxSize ( ) . width ) ) ;
25
+ cropperHeight = Math . max ( cropperState . cropperScaledMinHeight , Math . min ( cropperHeight , cropperState . cropperScaledMaxHeight , cropperState . maxSize ( ) . height ) ) ;
26
26
if ( cropperState . options . maintainAspectRatio ) {
27
- if ( cropperState . maxSize ! . width / cropperState . options . aspectRatio < cropperState . maxSize ! . height ) {
27
+ if ( cropperState . maxSize ( ) . width / cropperState . options . aspectRatio < cropperState . maxSize ( ) . height ) {
28
28
cropperHeight = cropperWidth / cropperState . options . aspectRatio ;
29
29
} else {
30
30
cropperWidth = cropperHeight * cropperState . options . aspectRatio ;
@@ -54,18 +54,18 @@ export function checkCropperWithinMaxSizeBounds(position: CropperPosition, cropp
54
54
y1 : 0
55
55
} ;
56
56
}
57
- if ( position . x2 > cropperState . maxSize ! . width ) {
57
+ if ( position . x2 > cropperState . maxSize ( ) . width ) {
58
58
position = {
59
59
...position ,
60
- x1 : position . x1 - ( maintainSize ? ( position . x2 - cropperState . maxSize ! . width ) : 0 ) ,
61
- x2 : cropperState . maxSize ! . width
60
+ x1 : position . x1 - ( maintainSize ? ( position . x2 - cropperState . maxSize ( ) . width ) : 0 ) ,
61
+ x2 : cropperState . maxSize ( ) . width
62
62
} ;
63
63
}
64
- if ( position . y2 > cropperState . maxSize ! . height ) {
64
+ if ( position . y2 > cropperState . maxSize ( ) . height ) {
65
65
position = {
66
66
...position ,
67
- y1 : position . y1 - ( maintainSize ? ( position . y2 - cropperState . maxSize ! . height ) : 0 ) ,
68
- y2 : cropperState . maxSize ! . height
67
+ y1 : position . y1 - ( maintainSize ? ( position . y2 - cropperState . maxSize ( ) . height ) : 0 ) ,
68
+ y2 : cropperState . maxSize ( ) . height
69
69
} ;
70
70
}
71
71
return position ;
@@ -143,16 +143,16 @@ export function resizeCropper(event: Event | BasicEvent, moveStart: MoveStart, c
143
143
if ( cropperPosition . x1 < 0 ) {
144
144
cropperPosition . x2 -= cropperPosition . x1 ;
145
145
cropperPosition . x1 = 0 ;
146
- } else if ( cropperPosition . x2 > cropperState . maxSize ! . width ) {
147
- cropperPosition . x1 -= ( cropperPosition . x2 - cropperState . maxSize ! . width ) ;
148
- cropperPosition . x2 = cropperState . maxSize ! . width ;
146
+ } else if ( cropperPosition . x2 > cropperState . maxSize ( ) . width ) {
147
+ cropperPosition . x1 -= ( cropperPosition . x2 - cropperState . maxSize ( ) . width ) ;
148
+ cropperPosition . x2 = cropperState . maxSize ( ) . width ;
149
149
}
150
150
if ( cropperPosition . y1 < 0 ) {
151
151
cropperPosition . y2 -= cropperPosition . y1 ;
152
152
cropperPosition . y1 = 0 ;
153
- } else if ( cropperPosition . y2 > cropperState . maxSize ! . height ) {
154
- cropperPosition . y1 -= ( cropperPosition . y2 - cropperState . maxSize ! . height ) ;
155
- cropperPosition . y2 = cropperState . maxSize ! . height ;
153
+ } else if ( cropperPosition . y2 > cropperState . maxSize ( ) . height ) {
154
+ cropperPosition . y1 -= ( cropperPosition . y2 - cropperState . maxSize ( ) . height ) ;
155
+ cropperPosition . y2 = cropperState . maxSize ( ) . height ;
156
156
}
157
157
break ;
158
158
}
@@ -171,7 +171,7 @@ export function checkAspectRatio(position: string, cropperPosition: CropperPosit
171
171
switch ( position ) {
172
172
case 'top' :
173
173
cropperPosition . x2 = cropperPosition . x1 + ( cropperPosition . y2 - cropperPosition . y1 ) * cropperState . options . aspectRatio ;
174
- overflowX = Math . max ( cropperPosition . x2 - cropperState . maxSize ! . width , 0 ) ;
174
+ overflowX = Math . max ( cropperPosition . x2 - cropperState . maxSize ( ) . width , 0 ) ;
175
175
overflowY = Math . max ( 0 - cropperPosition . y1 , 0 ) ;
176
176
if ( overflowX > 0 || overflowY > 0 ) {
177
177
cropperPosition . x2 -= ( overflowY * cropperState . options . aspectRatio ) > overflowX ? ( overflowY * cropperState . options . aspectRatio ) : overflowX ;
@@ -180,8 +180,8 @@ export function checkAspectRatio(position: string, cropperPosition: CropperPosit
180
180
break ;
181
181
case 'bottom' :
182
182
cropperPosition . x2 = cropperPosition . x1 + ( cropperPosition . y2 - cropperPosition . y1 ) * cropperState . options . aspectRatio ;
183
- overflowX = Math . max ( cropperPosition . x2 - cropperState . maxSize ! . width , 0 ) ;
184
- overflowY = Math . max ( cropperPosition . y2 - cropperState . maxSize ! . height , 0 ) ;
183
+ overflowX = Math . max ( cropperPosition . x2 - cropperState . maxSize ( ) . width , 0 ) ;
184
+ overflowY = Math . max ( cropperPosition . y2 - cropperState . maxSize ( ) . height , 0 ) ;
185
185
if ( overflowX > 0 || overflowY > 0 ) {
186
186
cropperPosition . x2 -= ( overflowY * cropperState . options . aspectRatio ) > overflowX ? ( overflowY * cropperState . options . aspectRatio ) : overflowX ;
187
187
cropperPosition . y2 -= ( overflowY * cropperState . options . aspectRatio ) > overflowX ? overflowY : ( overflowX / cropperState . options . aspectRatio ) ;
@@ -198,7 +198,7 @@ export function checkAspectRatio(position: string, cropperPosition: CropperPosit
198
198
break ;
199
199
case 'topright' :
200
200
cropperPosition . y1 = cropperPosition . y2 - ( cropperPosition . x2 - cropperPosition . x1 ) / cropperState . options . aspectRatio ;
201
- overflowX = Math . max ( cropperPosition . x2 - cropperState . maxSize ! . width , 0 ) ;
201
+ overflowX = Math . max ( cropperPosition . x2 - cropperState . maxSize ( ) . width , 0 ) ;
202
202
overflowY = Math . max ( 0 - cropperPosition . y1 , 0 ) ;
203
203
if ( overflowX > 0 || overflowY > 0 ) {
204
204
cropperPosition . x2 -= ( overflowY * cropperState . options . aspectRatio ) > overflowX ? ( overflowY * cropperState . options . aspectRatio ) : overflowX ;
@@ -208,8 +208,8 @@ export function checkAspectRatio(position: string, cropperPosition: CropperPosit
208
208
case 'right' :
209
209
case 'bottomright' :
210
210
cropperPosition . y2 = cropperPosition . y1 + ( cropperPosition . x2 - cropperPosition . x1 ) / cropperState . options . aspectRatio ;
211
- overflowX = Math . max ( cropperPosition . x2 - cropperState . maxSize ! . width , 0 ) ;
212
- overflowY = Math . max ( cropperPosition . y2 - cropperState . maxSize ! . height , 0 ) ;
211
+ overflowX = Math . max ( cropperPosition . x2 - cropperState . maxSize ( ) . width , 0 ) ;
212
+ overflowY = Math . max ( cropperPosition . y2 - cropperState . maxSize ( ) . height , 0 ) ;
213
213
if ( overflowX > 0 || overflowY > 0 ) {
214
214
cropperPosition . x2 -= ( overflowY * cropperState . options . aspectRatio ) > overflowX ? ( overflowY * cropperState . options . aspectRatio ) : overflowX ;
215
215
cropperPosition . y2 -= ( overflowY * cropperState . options . aspectRatio ) > overflowX ? overflowY : overflowX / cropperState . options . aspectRatio ;
@@ -219,7 +219,7 @@ export function checkAspectRatio(position: string, cropperPosition: CropperPosit
219
219
case 'bottomleft' :
220
220
cropperPosition . y2 = cropperPosition . y1 + ( cropperPosition . x2 - cropperPosition . x1 ) / cropperState . options . aspectRatio ;
221
221
overflowX = Math . max ( 0 - cropperPosition . x1 , 0 ) ;
222
- overflowY = Math . max ( cropperPosition . y2 - cropperState . maxSize ! . height , 0 ) ;
222
+ overflowY = Math . max ( cropperPosition . y2 - cropperState . maxSize ( ) . height , 0 ) ;
223
223
if ( overflowX > 0 || overflowY > 0 ) {
224
224
cropperPosition . x1 += ( overflowY * cropperState . options . aspectRatio ) > overflowX ? ( overflowY * cropperState . options . aspectRatio ) : overflowX ;
225
225
cropperPosition . y2 -= ( overflowY * cropperState . options . aspectRatio ) > overflowX ? overflowY : overflowX / cropperState . options . aspectRatio ;
@@ -229,8 +229,8 @@ export function checkAspectRatio(position: string, cropperPosition: CropperPosit
229
229
cropperPosition . x2 = cropperPosition . x1 + ( cropperPosition . y2 - cropperPosition . y1 ) * cropperState . options . aspectRatio ;
230
230
cropperPosition . y2 = cropperPosition . y1 + ( cropperPosition . x2 - cropperPosition . x1 ) / cropperState . options . aspectRatio ;
231
231
const overflowX1 = Math . max ( 0 - cropperPosition . x1 , 0 ) ;
232
- const overflowX2 = Math . max ( cropperPosition . x2 - cropperState . maxSize ! . width , 0 ) ;
233
- const overflowY1 = Math . max ( cropperPosition . y2 - cropperState . maxSize ! . height , 0 ) ;
232
+ const overflowX2 = Math . max ( cropperPosition . x2 - cropperState . maxSize ( ) . width , 0 ) ;
233
+ const overflowY1 = Math . max ( cropperPosition . y2 - cropperState . maxSize ( ) . height , 0 ) ;
234
234
const overflowY2 = Math . max ( 0 - cropperPosition . y1 , 0 ) ;
235
235
if ( overflowX1 > 0 || overflowX2 > 0 || overflowY1 > 0 || overflowY2 > 0 ) {
236
236
cropperPosition . x1 += ( overflowY1 * cropperState . options . aspectRatio ) > overflowX1 ? ( overflowY1 * cropperState . options . aspectRatio ) : overflowX1 ;
0 commit comments