pub fn auto_hide(child: impl UiNode, enabled: impl IntoVar<bool>) -> impl UiNode
Expand description
P
Defines if the widget only renders if it’s bounds intersects with the viewport auto-hide rectangle.
The auto-hide rect is usually (1.vw(), 1.vh())
of extra space around the viewport, so only widgets that transform
themselves very far need to set this, disabling auto-hide for a widget does not disable it for descendants.
§Examples
The example demonstrates a container that is fixed in the scroll viewport, it sets the x
and y
properties
to always stay in frame. Because the container is layout out of view and just transformed back into view it
auto-hides while visible, the example uses auto_hide = false;
to fix the issue.
fn center_viewport(msg: impl UiNode) -> impl UiNode {
Container! {
layout::x = merge_var!(SCROLL.horizontal_offset(), SCROLL.zoom_scale(), |&h, &s| h.0.fct_l() - 1.vw() / s * h);
layout::y = merge_var!(SCROLL.vertical_offset(), SCROLL.zoom_scale(), |&v, &s| v.0.fct_l() - 1.vh() / s * v);
layout::scale = SCROLL.zoom_scale().map(|&fct| 1.fct() / fct);
layout::transform_origin = 0;
widget::auto_hide = false;
layout::max_size = (1.vw(), 1.vh());
child_align = Align::CENTER;
child = msg;
}
}