Skip to content

Commit

Permalink
fix(image): image aspect dimensions for ImageSource.fromAsset(...) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
manoldonev committed Mar 19, 2018
1 parent c02bb28 commit 7506905
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 2 additions & 2 deletions tests/app/image-source/image-source-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ export function testFromAssetWithScalingAndAspectRatio(done) {
};

let img = imageSource.fromAsset(asset).then((source) => {
TKUnit.assertEqual(source.width, scaleWidth);
TKUnit.assertEqual(source.height, 5);
TKUnit.assertEqual(source.width, 18);
TKUnit.assertEqual(source.height, scaleHeight);
done();
}, (error) => {
done(error);
Expand Down
3 changes: 1 addition & 2 deletions tns-core-modules/image-asset/image-asset-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ export class ImageAsset extends observable.Observable implements definition.Ima
export function getAspectSafeDimensions(sourceWidth, sourceHeight, reqWidth, reqHeight) {
let widthCoef = sourceWidth / reqWidth;
let heightCoef = sourceHeight / reqHeight;

let aspectCoef = widthCoef > heightCoef ? widthCoef : heightCoef;
let aspectCoef = Math.min(widthCoef, heightCoef);

return {
width: Math.floor(sourceWidth / aspectCoef),
Expand Down

0 comments on commit 7506905

Please sign in to comment.