mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Merge pull request #2198 from NativeScript/cankov/image-exactly
Image should not requestLayout when measured with 'exactly' spec
This commit is contained in:
@@ -133,3 +133,5 @@ export var device: definition.Device = new Device();
|
||||
export module screen {
|
||||
export var mainScreen = new MainScreen();
|
||||
}
|
||||
|
||||
export var isAndroid = true;
|
||||
10
tns-core-modules/platform/platform.d.ts
vendored
10
tns-core-modules/platform/platform.d.ts
vendored
@@ -3,6 +3,16 @@
|
||||
* Contains all kinds of information about the device, its operating system and software.
|
||||
*/
|
||||
declare module "platform" {
|
||||
|
||||
/**
|
||||
* Gets a value indicating if the app is running on the Android platform.
|
||||
*/
|
||||
export var isAndroid: boolean;
|
||||
|
||||
/**
|
||||
* Gets a value indicating if the app is running on the iOS platform.
|
||||
*/
|
||||
export var isIOS: boolean;
|
||||
|
||||
/*
|
||||
* Enum holding platform names.
|
||||
|
||||
@@ -126,3 +126,5 @@ export var device: definition.Device = new Device();
|
||||
export module screen {
|
||||
export var mainScreen = new MainScreen();
|
||||
}
|
||||
|
||||
export var isIOS = true;
|
||||
@@ -36,6 +36,7 @@ function onImageSourcePropertyChanged(data: dependencyObservable.PropertyChangeD
|
||||
|
||||
export class Image extends imageCommon.Image {
|
||||
private _ios: UIImageView;
|
||||
private _imageSourceAffectsLayout: boolean = true;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
@@ -54,7 +55,7 @@ export class Image extends imageCommon.Image {
|
||||
public _setNativeImage(nativeImage: any) {
|
||||
this.ios.image = nativeImage;
|
||||
|
||||
if (isNaN(this.width) || isNaN(this.height)) {
|
||||
if (this._imageSourceAffectsLayout) {
|
||||
this.requestLayout();
|
||||
}
|
||||
}
|
||||
@@ -77,7 +78,9 @@ export class Image extends imageCommon.Image {
|
||||
|
||||
var finiteWidth: boolean = widthMode !== utils.layout.UNSPECIFIED;
|
||||
var finiteHeight: boolean = heightMode !== utils.layout.UNSPECIFIED;
|
||||
|
||||
|
||||
this._imageSourceAffectsLayout = widthMode !== utils.layout.EXACTLY || heightMode !== utils.layout.EXACTLY;
|
||||
|
||||
if (nativeWidth !== 0 && nativeHeight !== 0 && (finiteWidth || finiteHeight)) {
|
||||
var scale = Image.computeScaleFactor(width, height, finiteWidth, finiteHeight, nativeWidth, nativeHeight, this.stretch);
|
||||
var resultW = Math.floor(nativeWidth * scale.width);
|
||||
|
||||
Reference in New Issue
Block a user