Skip to content

Commit 6fd205e

Browse files
Added a RelativeTo sample
1 parent b29f360 commit 6fd205e

File tree

4 files changed

+98
-0
lines changed

4 files changed

+98
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ These samples are supplied directly from the feature teams of Fuse and we welcom
4242
<tr>
4343
<td><a href="Samples/Animation/CyclePhase">Cycle Phase</a></td>
4444
<td><a href="Samples/Animation/TimelineWrap">Timeline Wrap</a></td>
45+
<td><a href="Samples/RelativeTo">RelativeTo</a></td>
4546
</tr>
4647
</table>
4748

Samples/RelativeTo/MainView.ux

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<App Theme="Basic">
2+
<DockPanel>
3+
<TopFrameBackground Dock="Top" />
4+
<Panel>
5+
<Rectangle ux:Name="newLayoutMaster" Width="50" Height="50" Color="#8889" Alignment="TopLeft" Margin="20,50"/>
6+
<StackPanel Alignment="Top">
7+
<TextInput PlaceholderText="Click me to show the keyboard" Alignment="Center">
8+
<WhileKeyboardVisible>
9+
<Move Target="rect3" RelativeTo="Keyboard" Y="-1" Duration="0.5" />
10+
</WhileKeyboardVisible>
11+
</TextInput>
12+
<Button Text="Click me" Alignment="Center">
13+
<WhilePressed>
14+
<Move Target="rect1" RelativeTo="Size" Y="-1" Duration="0.5" />
15+
<Move Target="rect2" RelativeTo="ParentSize" Y="-1" Duration="0.5" />
16+
<Move Target="rect5" RelativeTo="Size" RelativeNode="relativeNode" Y="-1" Duration="0.5" />
17+
</WhilePressed>
18+
</Button>
19+
<Switch>
20+
<WhileTrue>
21+
<Change rect4.LayoutMaster="newLayoutMaster" />
22+
</WhileTrue>
23+
</Switch>
24+
</StackPanel>
25+
<Rectangle ux:Name="relativeNode" Height="400" Width="50" Color="#bbf" Alignment="BottomRight">
26+
<VerticalText Alignment="Center" Width="200">relativeNode</VerticalText>
27+
</Rectangle>
28+
29+
<Text ux:Class="VerticalText" TransformOrigin="Center" Alignment="Bottom" TextColor="#000">
30+
<Rotation Degrees="-90" />
31+
</Text>
32+
33+
<Grid ColumnCount="5" Rows="3*,1*" Color="#ddd" Width="80%" Height="100%" Alignment="BottomLeft">
34+
<VerticalText Width="200">RelativeTo="Size"</VerticalText>
35+
<VerticalText Width="200">RelativeTo="ParentSize"</VerticalText>
36+
<VerticalText Width="200">RelativeTo="Keyboard"</VerticalText>
37+
<VerticalText Width="200">RelativeTo="PositionChange"</VerticalText>
38+
<VerticalText Width="200">RelativeNode="relativeNode"</VerticalText>
39+
40+
41+
42+
<Rectangle ux:Name="rect1" Width="50" Height="50" Color="#f00" Alignment="Bottom"/>
43+
<Rectangle ux:Name="rect2" Width="50" Height="50" Color="#0f0" Alignment="Bottom"/>
44+
<Rectangle ux:Name="rect3" Width="50" Height="50" Color="#00f" Alignment="Bottom"/>
45+
<Panel Alignment="Bottom" Width="50" Height="50">
46+
<Rectangle ux:Name="rect4" Width="50" Height="50" Color="#0ff" LayoutMaster="layoutMaster">
47+
<LayoutAnimation>
48+
<Move RelativeTo="PositionChange" X="1" Y="1" Duration="0.5" />
49+
</LayoutAnimation>
50+
</Rectangle>
51+
<Rectangle ux:Name="layoutMaster" Width="50" Height="50"/>
52+
</Panel>
53+
<Rectangle ux:Name="rect5" Width="50" Height="50" Color="#f0f" Alignment="Bottom"/>
54+
</Grid>
55+
</Panel>
56+
</DockPanel>
57+
</App>

Samples/RelativeTo/README.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Using the RelativeTo and RelativeNode properties
2+
3+
This sample shows the use of the `RelativeTo` property using the following values:
4+
5+
- Size: Moves the set amount times the size of the element. So Y="-1" moves the element by its entire height in the negative Y direction.
6+
- ParentSize: Same as Size but uses the elements parents size instead.
7+
- PositionChange: Used in response to a LayoutAnimation to move the element by the amount of change in position within it's parent.
8+
- Keyboard: Moves the element relative to the size of the eyboard.
9+
10+
- Also the use of the `RelativeNode`

Samples/RelativeTo/RelativeTo.unoproj

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"RootNamespace":"",
3+
"Packages": [
4+
"Fuse.Animations",
5+
"Fuse.BasicTheme",
6+
"Fuse.Themes",
7+
"Fuse.Controls",
8+
"Fuse.Designer",
9+
"Fuse.Drawing",
10+
"Fuse.Drawing.Primitives",
11+
"Fuse.Effects",
12+
"Fuse.Elements",
13+
"Fuse.Entities",
14+
"Fuse.Gestures",
15+
"Fuse.Navigation",
16+
"Fuse.Shapes",
17+
"Fuse.Triggers",
18+
"Fuse.Reactive",
19+
"Fuse.Android",
20+
"Fuse.Desktop",
21+
"Fuse.iOS",
22+
"Fuse.UserEvents",
23+
"FuseCore",
24+
"Uno.Collections",
25+
"Uno.Geometry"
26+
],
27+
"Includes": [
28+
"*"
29+
]
30+
}

0 commit comments

Comments
 (0)