Merge pull request #635 from NativeScript/nnikolov/NavigationWithoutHistory

Fixed issue #360.
This commit is contained in:
Nedyalko Nikolov
2015-08-28 15:53:21 +03:00

View File

@@ -7,7 +7,7 @@ global.moduleMerge(common, exports);
export class WrapLayout extends common.WrapLayout { export class WrapLayout extends common.WrapLayout {
private _lenghts: Array<number>; private _lengths: Array<number>;
private static getChildMeasureSpec(parentMode: number, parentLength: number, itemLength): number { private static getChildMeasureSpec(parentMode: number, parentLength: number, itemLength): number {
if (itemLength > 0) { if (itemLength > 0) {
@@ -42,9 +42,9 @@ export class WrapLayout extends common.WrapLayout {
var remainingWidth = widthMode === utils.layout.UNSPECIFIED ? Number.MAX_VALUE : width - ((this.paddingLeft + this.paddingRight) * density); var remainingWidth = widthMode === utils.layout.UNSPECIFIED ? Number.MAX_VALUE : width - ((this.paddingLeft + this.paddingRight) * density);
var remainingHeight = heightMode === utils.layout.UNSPECIFIED ? Number.MAX_VALUE : height - ((this.paddingTop + this.paddingBottom) * density); var remainingHeight = heightMode === utils.layout.UNSPECIFIED ? Number.MAX_VALUE : height - ((this.paddingTop + this.paddingBottom) * density);
this._lenghts = [0]; this._lengths = [0];
var rowOrColumn = 0; var rowOrColumn = 0;
var maxLenght = 0; var maxLength = 0;
var i: number = 0; var i: number = 0;
var isVertical = this.orientation === enums.Orientation.vertical; var isVertical = this.orientation === enums.Orientation.vertical;
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
@@ -57,43 +57,43 @@ export class WrapLayout extends common.WrapLayout {
if (isVertical) { if (isVertical) {
if (childSize.measuredHeight > remainingHeight) { if (childSize.measuredHeight > remainingHeight) {
rowOrColumn++; rowOrColumn++;
maxLenght = Math.max(maxLenght, measureHeight); maxLength = Math.max(maxLength, measureHeight);
measureHeight = childSize.measuredHeight; measureHeight = childSize.measuredHeight;
remainingWidth = height - childSize.measuredHeight; remainingWidth = height - childSize.measuredHeight;
this._lenghts[rowOrColumn] = childSize.measuredWidth; this._lengths[rowOrColumn] = childSize.measuredWidth;
} }
else { else {
remainingHeight -= childSize.measuredHeight; remainingHeight -= childSize.measuredHeight;
this._lenghts[rowOrColumn] = Math.max(this._lenghts[rowOrColumn], childSize.measuredWidth); this._lengths[rowOrColumn] = Math.max(this._lengths[rowOrColumn], childSize.measuredWidth);
measureHeight += childSize.measuredHeight; measureHeight += childSize.measuredHeight;
} }
} }
else { else {
if (childSize.measuredWidth > remainingWidth) { if (childSize.measuredWidth > remainingWidth) {
rowOrColumn++; rowOrColumn++;
maxLenght = Math.max(maxLenght, measureWidth); maxLength = Math.max(maxLength, measureWidth);
measureWidth = childSize.measuredWidth; measureWidth = childSize.measuredWidth;
remainingWidth = width - childSize.measuredWidth; remainingWidth = width - childSize.measuredWidth;
this._lenghts[rowOrColumn] = childSize.measuredHeight; this._lengths[rowOrColumn] = childSize.measuredHeight;
} }
else { else {
remainingWidth -= childSize.measuredWidth; remainingWidth -= childSize.measuredWidth;
this._lenghts[rowOrColumn] = Math.max(this._lenghts[rowOrColumn], childSize.measuredHeight); this._lengths[rowOrColumn] = Math.max(this._lengths[rowOrColumn], childSize.measuredHeight);
measureWidth += childSize.measuredWidth; measureWidth += childSize.measuredWidth;
} }
} }
} }
if (isVertical) { if (isVertical) {
measureHeight = Math.max(maxLenght, measureHeight); measureHeight = Math.max(maxLength, measureHeight);
for (i = 0; i < this._lenghts.length; i++) { for (i = 0; i < this._lengths.length; i++) {
measureWidth += this._lenghts[i]; measureWidth += this._lengths[i];
} }
} }
else { else {
measureWidth = Math.max(maxLenght, measureWidth); measureWidth = Math.max(maxLength, measureWidth);
for (i = 0; i < this._lenghts.length; i++) { for (i = 0; i < this._lengths.length; i++) {
measureHeight += this._lenghts[i]; measureHeight += this._lengths[i];
} }
} }
@@ -121,10 +121,10 @@ export class WrapLayout extends common.WrapLayout {
var childTop = this.paddingTop * density; var childTop = this.paddingTop * density;
var childrenLength: number; var childrenLength: number;
if (isVertical) { if (isVertical) {
childrenLength = bottom - top - (this.paddingTop + this.paddingBottom) * density; childrenLength = bottom - top - (this.paddingBottom * density);
} }
else { else {
childrenLength = right - left - (this.paddingLeft + this.paddingRight) * density; childrenLength = right - left - (this.paddingRight * density);
} }
var rowOrColumn = 0; var rowOrColumn = 0;
@@ -139,7 +139,7 @@ export class WrapLayout extends common.WrapLayout {
var childWidth = child.getMeasuredWidth() + (child.marginLeft + child.marginRight) * density; var childWidth = child.getMeasuredWidth() + (child.marginLeft + child.marginRight) * density;
var childHeight = child.getMeasuredHeight() + (child.marginTop + child.marginBottom) * density; var childHeight = child.getMeasuredHeight() + (child.marginTop + child.marginBottom) * density;
var length = this._lenghts[rowOrColumn]; var length = this._lengths[rowOrColumn];
if (isVertical) { if (isVertical) {
@@ -156,7 +156,7 @@ export class WrapLayout extends common.WrapLayout {
rowOrColumn++; rowOrColumn++;
// Take current column width. // Take current column width.
childWidth = length = this._lenghts[rowOrColumn]; childWidth = length = this._lengths[rowOrColumn];
} }
} }
else { else {
@@ -173,7 +173,7 @@ export class WrapLayout extends common.WrapLayout {
rowOrColumn++; rowOrColumn++;
// Take current row height. // Take current row height.
childHeight = length = this._lenghts[rowOrColumn]; childHeight = length = this._lengths[rowOrColumn];
} }
} }