Skip to content
This repository was archived by the owner on Oct 19, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Tangram/Core/TangramView.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -811,15 +811,15 @@ - (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) ;
}
//吸底判断
else if(((TangramStickyLayout *)layout).stickyBottom == YES
&& 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
Expand All @@ -829,7 +829,7 @@ - (void)setContentOffset:(CGPoint)contentOffset
}
}
for (UIView<TangramLayoutProtocol> *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];
Expand Down
14 changes: 7 additions & 7 deletions Tangram/Factory/TangramDefaultItemModelFactory.m
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
}
Expand Down
60 changes: 60 additions & 0 deletions TangramDemo/TangramDemo/Resources/TangramMock.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down