-
Like: |
Beta Was this translation helpful? Give feedback.
Answered by
hunger
Mar 13, 2025
Replies: 2 comments 10 replies
-
Do you have the code for this example? That would make it clearer what you actually want to do. |
Beta Was this translation helpful? Give feedback.
3 replies
-
Would this get you started? import { Button, HorizontalBox, ScrollView, AboutSlint } from "std-widgets.slint";
export component Demo {
property <string> positional-color: "red";
height: 100px;
HorizontalBox {
ScrollView {
VerticalLayout {
red := Rectangle {
background: Colors.red;
height: 200px;
}
green := Rectangle {
background: Colors.green;
height: 200px;
}
blue := Rectangle {
background: Colors.blue;
height: 200px;
}
}
changed viewport-y => {
if self.viewport-y <= -400px {
root.positional-color = "blue";
} else if self.viewport-y <= -200px {
positional-color = "green";
} else {
positional-color = "red";
}
}
}
Text {
text: root.positional-color;
}
}
} |
Beta Was this translation helpful? Give feedback.
7 replies
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
With a bit of math :-)
You can get the
y
position ofred
,green
andblue
Rectangles and calculate the value when to show any of those from that (taking the viewport width and height into account).If you have a dynamic number of Elements in the layout you probably need something a bit more scalable. Maybe along these lines?