mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 11:01:21 +08:00
chore: set keepAspectRatio to true as default in image-asset (#5613)
* chore: set keepAspectRatio to true as default in image-asset * fix: remove empty lines
This commit is contained in:
@ -15,7 +15,7 @@ export function testFromResource() {
|
||||
// >> imagesource-resname
|
||||
const img = imageSource.fromResource("icon");
|
||||
// << imagesource-resname
|
||||
|
||||
|
||||
TKUnit.assert(img.height > 0, "image.fromResource failed");
|
||||
}
|
||||
|
||||
@ -149,6 +149,22 @@ export function testFromAssetWithScalingAndAspectRatio(done) {
|
||||
});
|
||||
}
|
||||
|
||||
export function testFromAssetWithScalingAndDefaultAspectRatio(done) {
|
||||
let asset = new imageAssetModule.ImageAsset(splashscreenPath);
|
||||
let scaleWidth = 10;
|
||||
let scaleHeight = 11;
|
||||
asset.options.width = scaleWidth;
|
||||
asset.options.height = scaleHeight;
|
||||
|
||||
let img = imageSource.fromAsset(asset).then((source) => {
|
||||
TKUnit.assertEqual(source.width, 18);
|
||||
TKUnit.assertEqual(source.height, scaleHeight);
|
||||
done();
|
||||
}, (error) => {
|
||||
done(error);
|
||||
});
|
||||
}
|
||||
|
||||
export function testFromAssetWithBiggerScaling(done) {
|
||||
let asset = new imageAssetModule.ImageAsset(splashscreenPath);
|
||||
let scaleWidth = 600;
|
||||
|
@ -9,6 +9,11 @@ export class ImageAsset extends observable.Observable implements definition.Ima
|
||||
ios: PHAsset;
|
||||
android: string;
|
||||
|
||||
constructor () {
|
||||
super();
|
||||
this._options = { keepAspectRatio: true };
|
||||
}
|
||||
|
||||
get options(): definition.ImageAssetOptions {
|
||||
return this._options;
|
||||
}
|
||||
|
Reference in New Issue
Block a user