Merge pull request #1200 from NativeScript/cankov/background-native-image-recreated

Fix native image recreated on layout even if the view is not resized
This commit is contained in:
Panayot Cankov
2015-12-04 10:56:01 +02:00
5 changed files with 104 additions and 15 deletions

View File

@@ -893,14 +893,18 @@ export class View extends proxy.ProxyObject implements definition.View {
return { left: this._oldLeft, top: this._oldTop, right: this._oldRight, bottom: this._oldBottom }
}
_setCurrentLayoutBounds(left: number, top: number, right: number, bottom: number): boolean {
/**
* Returns two booleans - the first if "boundsChanged" the second is "sizeChanged".
*/
_setCurrentLayoutBounds(left: number, top: number, right: number, bottom: number): { boundsChanged: boolean, sizeChanged: boolean } {
this._isLayoutValid = true;
var changed: boolean = this._oldLeft !== left || this._oldTop !== top || this._oldRight !== right || this._oldBottom !== bottom;
var boundsChanged: boolean = this._oldLeft !== left || this._oldTop !== top || this._oldRight !== right || this._oldBottom !== bottom;
var sizeChanged: boolean = (this._oldRight - this._oldLeft !== right - left) || (this._oldBottom - this._oldTop !== bottom - top);
this._oldLeft = left;
this._oldTop = top;
this._oldRight = right;
this._oldBottom = bottom;
return changed;
return { boundsChanged, sizeChanged };
}
private _applyStyleFromScope() {

View File

@@ -138,13 +138,14 @@ export class View extends viewCommon.View {
}
public layout(left: number, top: number, right: number, bottom: number): void {
var changed: boolean = this._setCurrentLayoutBounds(left, top, right, bottom);
var { boundsChanged, sizeChanged } = this._setCurrentLayoutBounds(left, top, right, bottom);
this.layoutNativeView(left, top, right, bottom);
if (changed || (this._privateFlags & PFLAG_LAYOUT_REQUIRED) === PFLAG_LAYOUT_REQUIRED) {
if (boundsChanged || (this._privateFlags & PFLAG_LAYOUT_REQUIRED) === PFLAG_LAYOUT_REQUIRED) {
this.onLayout(left, top, right, bottom);
this._privateFlags &= ~PFLAG_LAYOUT_REQUIRED;
this._onBoundsChanged();
}
if (sizeChanged) {
this._onSizeChanged();
}
this._privateFlags &= ~PFLAG_FORCE_LAYOUT;
}
@@ -246,8 +247,8 @@ export class View extends viewCommon.View {
return false;
}
private _onBoundsChanged() {
this.style._boundsChanged();
private _onSizeChanged() {
this.style._sizeChanged();
}
public _updateNativeTransform() {