Skip to content

Commit 3d85356

Browse files
authored
fix: prevent NaN crop when previousCropSize.x/y is zero (#636)
1 parent b7ddaae commit 3d85356

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Cropper.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ class Cropper extends React.Component<CropperProps, State> {
734734
let adjustedCrop = this.props.crop
735735

736736
// Only scale if we're initialized and this is a legitimate resize
737-
if (this.isInitialized && this.previousCropSize) {
737+
if (this.isInitialized && this.previousCropSize?.width && this.previousCropSize?.height) {
738738
const sizeChanged =
739739
Math.abs(this.previousCropSize.width - this.state.cropSize.width) > 1e-6 ||
740740
Math.abs(this.previousCropSize.height - this.state.cropSize.height) > 1e-6

0 commit comments

Comments
 (0)