diff --git a/Tangram/Core/TangramView.m b/Tangram/Core/TangramView.m index 1b0a740..6b9a778 100644 --- a/Tangram/Core/TangramView.m +++ b/Tangram/Core/TangramView.m @@ -793,13 +793,13 @@ - (void)setContentOffset:(CGPoint)contentOffset } if ([layout.position isEqualToString:@"top-fixed"] || (([layout.position isEqualToString:@"fixed"]) && (((TangramFixLayout *)layout).alignType == TopLeft || ((TangramFixLayout *)layout).alignType == TopRight))) { - layout.frame = CGRectMake(layout.frame.origin.x,self.contentOffset.y + ((TangramFixLayout *)layout).originPoint.y, layout.frame.size.width, layout.frame.size.height); + layout.frame = CGRectMake(layout.frame.origin.x, contentOffset.y + ((TangramFixLayout *)layout).originPoint.y, layout.frame.size.width, layout.frame.size.height); if (topOffset < layout.vv_height + ((TangramFixLayout *)layout).originPoint.y) { topOffset = layout.vv_height + ((TangramFixLayout *)layout).originPoint.y; } } else { - layout.frame = CGRectMake(layout.frame.origin.x,self.vv_height- layout.vv_height + self.contentOffset.y - ((TangramFixLayout *)layout).offsetY, layout.frame.size.width, layout.frame.size.height); + layout.frame = CGRectMake(layout.frame.origin.x,self.vv_height- layout.vv_height + contentOffset.y - ((TangramFixLayout *)layout).offsetY, layout.frame.size.width, layout.frame.size.height); bottomOffset -= (layout.vv_height + ((TangramFixLayout *)layout).offsetY); if (bottomOffset > (self.vv_height - layout.vv_height - ((TangramFixLayout *)layout).offsetY)) { bottomOffset = (self.vv_height - layout.vv_height - ((TangramFixLayout *)layout).offsetY); @@ -811,7 +811,7 @@ - (void)setContentOffset:(CGPoint)contentOffset if (((TangramStickyLayout *)layout).stickyBottom == NO && self.contentOffset.y >= ((TangramStickyLayout *)layout).originalY - topOffset - ((TangramStickyLayout *)layout).extraOffset) { ((TangramStickyLayout *)layout).enterFloatStatus = YES; - layout.frame = CGRectMake(layout.frame.origin.x,self.contentOffset.y + topOffset + layout.marginTop + ((TangramStickyLayout *)layout).extraOffset , layout.frame.size.width, layout.frame.size.height); + layout.frame = CGRectMake(layout.frame.origin.x, contentOffset.y + topOffset + layout.marginTop + ((TangramStickyLayout *)layout).extraOffset , layout.frame.size.width, layout.frame.size.height); topOffset += (layout.vv_height + layout.marginTop + layout.marginBottom + ((TangramStickyLayout *)layout).extraOffset) ; } //吸底判断 @@ -819,7 +819,7 @@ - (void)setContentOffset:(CGPoint)contentOffset && self.contentOffset.y + self.vv_height >= ((TangramStickyLayout *)layout).originalY + layout.vv_height) { ((TangramStickyLayout *)layout).enterFloatStatus = YES; - layout.frame = CGRectMake(layout.frame.origin.x,self.contentOffset.y + self.vv_height - layout.vv_height - layout.marginBottom, layout.frame.size.width, layout.frame.size.height); + layout.frame = CGRectMake(layout.frame.origin.x, contentOffset.y + self.vv_height - layout.vv_height - layout.marginBottom, layout.frame.size.width, layout.frame.size.height); bottomOffset -= (layout.vv_height + layout.marginTop + layout.marginBottom); } else @@ -829,7 +829,7 @@ - (void)setContentOffset:(CGPoint)contentOffset } } for (UIView *layout in self.dragableLayoutArray) { - layout.frame = CGRectMake(layout.frame.origin.x, ((TangramDragableLayout *)layout).originPoint.y + self.contentOffset.y , layout.frame.size.width, layout.frame.size.height); + layout.frame = CGRectMake(layout.frame.origin.x, ((TangramDragableLayout *)layout).originPoint.y + contentOffset.y , layout.frame.size.width, layout.frame.size.height); } [super setContentOffset:contentOffset]; diff --git a/Tangram/Factory/TangramDefaultItemModelFactory.m b/Tangram/Factory/TangramDefaultItemModelFactory.m index 7bfed9b..cc75ff7 100644 --- a/Tangram/Factory/TangramDefaultItemModelFactory.m +++ b/Tangram/Factory/TangramDefaultItemModelFactory.m @@ -83,17 +83,17 @@ + (TangramDefaultItemModel *)praseDictToItemModel:(TangramDefaultItemModel *)ite } } if ([styleDict tm_safeObjectForKey:@"width"] != nil) { - if([[styleDict tm_stringForKey:@"width"]containsString:@"rp"]){ + NSString *widthStr = [styleDict tm_stringForKey:@"width"]; + if([widthStr containsString:@"rp"]){ itemModel.heightFromStyle = [TangramDefaultDataSourceHelper floatValueByRPObject:[styleDict tm_safeObjectForKey:@"width"]]; - } - else{ + } else if ([widthStr isEqualToString:@"-1"]) { + //width 配-1 意味着屏幕宽度 + itemModel.widthFromStyle = [UIScreen mainScreen].bounds.size.width; + } else { itemModel.widthFromStyle = [styleDict tm_floatForKey:@"width"]; } } - else if ([[styleDict tm_stringForKey:@"width"] isEqualToString:@"-1"]) { - //width 配-1 意味着屏幕宽度 - itemModel.widthFromStyle = [UIScreen mainScreen].bounds.size.width; - } + if ([styleDict tm_floatForKey:@"aspectRatio"] > 0.f) { itemModel.modelAspectRatio = [styleDict tm_floatForKey:@"aspectRatio"]; } diff --git a/TangramDemo/TangramDemo/Resources/TangramMock.json b/TangramDemo/TangramDemo/Resources/TangramMock.json index c26be9c..33c2265 100644 --- a/TangramDemo/TangramDemo/Resources/TangramMock.json +++ b/TangramDemo/TangramDemo/Resources/TangramMock.json @@ -36,6 +36,66 @@ } ] }, + { + "type": "container-float", + "id": "float-RYYYYYYYYYY", + "style":{ + "bgColor": "#CC5500", + "align": "bottom_left", + "x": 20, + "y": 20 + }, + "items": [ + { + "type": "text", + "text": "float-layout", + "style":{ + "width": 40, + "height": 40, + } + } + ] + }, + { + "type": "container-sticky", + "id": "sticky-RYYYYYYYYYY", + "style":{ + "bgColor": "#CC5500", + "align": "top_left", + "x": 0, + "y": 80 + }, + "items": [ + { + "type": "text", + "text": "sticky-layout", + "style":{ + "width": 100, + "height": 20, + } + } + ] + }, + { + "type": "container-fix", + "id": "fix-RYYYYYYYYYY", + "style":{ + "bgColor": "#4dCC0000", + "align": "top_left", + "x": 0, + "y": 100 + }, + "items": [ + { + "type": "text", + "text": "fix layout", + "style":{ + "width": "-1", + "height": 20, + } + } + ] + }, { "type": "container-oneColumn", "id": "first-line-1",