Fix crash when scaling something with 0 width or height (#1078)

* resolve NaN value when trying to change scale value from zero to other numbers

* resolve NaN value when trying to change scale value from zero to other numbers

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
Sahra Zhou
2023-03-26 15:20:00 -07:00
committed by Keavon Chambers
parent d6ab417bcb
commit dbcb854cd2
2 changed files with 4 additions and 1 deletions

View File

@@ -48,6 +48,9 @@ pub fn apply_transform_operation(layer: &Layer, transform_op: TransformOp, value
// Find the delta transform
let mut delta = layer.transform.inverse() * transform;
if !delta.is_finite() {
return layer.transform.to_cols_array();
}
// Preserve aspect ratio
if matches!(transform_op, TransformOp::ScaleX | TransformOp::Width) && layer.preserve_aspect {