Repository: bevyengine/bevy
File: crates/bevy_ui/src/ui_node.rs (Rust)

Code before:
/// moving the window down causes the content to move up.
///
/// Updating the values of `ScrollPosition` will reposition the children of the node by the offset amount in logical pixels.
/// `ScrollPosition` may be updated by the layout system when a layout change makes a previously valid `ScrollPosition` invalid.
/// Changing this does nothing on a `Node` without setting at least one `OverflowAxis` to `OverflowAxis::Scroll`.
#[derive(Component, Debug, Clone, Default, Deref, DerefMut, Reflect)]
#[reflect(Component, Default, Clone)]
pub struct ScrollPosition(pub Vec2);

impl ScrollPosition {
    pub const DEFAULT: Self = Self(Vec2::ZERO);
}

impl From<Vec2> for ScrollPosition {
    fn from(value: Vec2) -> Self {
        Self(value)
    }
}

/// Determines which axes of a node are *sticky* during scrolling.
///
/// A **sticky** node maintains its position along the specified axes
/// instead of moving with its scrolled parent content when [`ScrollPosition`] is applied.
#[derive(Component, Debug, Clone, Default, Deref, DerefMut, Reflect)]
#[reflect(Component, Default, Clone)]
pub struct ScrollSticky(pub BVec2);

impl From<BVec2> for ScrollSticky {
    fn from(value: BVec2) -> Self {
        Self(value)
    }
}

/// The base component for UI entities. It describes UI layout and style properties.
///
/// When defining new types of UI entities, require [`Node`] to make them behave like UI nodes.
///
/// Nodes can be laid out using either Flexbox or CSS Grid Layout.
///
/// See below for general learning resources and for documentation on the individual style properties.
///
/// ### Flexbox
///
/// - [MDN: Basic Concepts of Flexbox](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Basic_Concepts_of_Flexbox)
/// - [A Complete Guide To Flexbox](https://css-tricks.com/snippets/css/a-guide-to-flexbox/) by CSS Tricks. This is detailed guide with illustrations and comprehensive written explanation of the different Flexbox properties and how they work.
/// - [Flexbox Froggy](https://flexboxfroggy.com/). An interactive tutorial/game that teaches the essential parts of Flexbox in a fun engaging way.
///
/// ### CSS Grid
///
/// - [MDN: Basic Concepts of Grid Layout](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout/Basic_Concepts_of_Grid_Layout)
/// - [A Complete Guide To CSS Grid](https://css-tricks.com/snippets/css/complete-guide-grid/) by CSS Tricks. This is detailed guide with illustrations and comprehensive written explanation of the different CSS Grid properties and how they work.

Review comment (bug):
I think the name `ScrollSticky` carries the wrong implications. It should be called `IgnoreScroll` or something. And the description is misleading too, the node isn't sticky, it's fixed in place.

Code after:
/// moving the window down causes the content to move up.
///
/// Updating the values of `ScrollPosition` will reposition the children of the node by the offset amount in logical pixels.
/// `ScrollPosition` may be updated by the layout system when a layout change makes a previously valid `ScrollPosition` invalid.
/// Changing this does nothing on a `Node` without setting at least one `OverflowAxis` to `OverflowAxis::Scroll`.
#[derive(Component, Debug, Clone, Default, Deref, DerefMut, Reflect)]
#[reflect(Component, Default, Clone)]
pub struct ScrollPosition(pub Vec2);

impl ScrollPosition {
    pub const DEFAULT: Self = Self(Vec2::ZERO);
}

impl From<Vec2> for ScrollPosition {
    fn from(value: Vec2) -> Self {
        Self(value)
    }
}

/// Controls whether a UI element ignores its parent's [`ScrollPosition`] along specific axes.
///
/// When an axis is set to `true`, the node will not have the parent’s scroll position applied
/// on that axis. This can be used to keep an element visually fixed along one or both axes
/// even when its parent UI element is scrolled.
#[derive(Component, Debug, Clone, Default, Deref, DerefMut, Reflect)]
#[reflect(Component, Default, Clone)]
pub struct IgnoreScroll(pub BVec2);

impl From<BVec2> for IgnoreScroll {
    fn from(value: BVec2) -> Self {
        Self(value)
    }
}

/// The base component for UI entities. It describes UI layout and style properties.
///
/// When defining new types of UI entities, require [`Node`] to make them behave like UI nodes.
///
/// Nodes can be laid out using either Flexbox or CSS Grid Layout.
///
/// See below for general learning resources and for documentation on the individual style properties.
///
/// ### Flexbox
///
/// - [MDN: Basic Concepts of Flexbox](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Basic_Concepts_of_Flexbox)
/// - [A Complete Guide To Flexbox](https://css-tricks.com/snippets/css/a-guide-to-flexbox/) by CSS Tricks. This is detailed guide with illustrations and comprehensive written explanation of the different Flexbox properties and how they work.
/// - [Flexbox Froggy](https://flexboxfroggy.com/). An interactive tutorial/game that teaches the essential parts of Flexbox in a fun engaging way.
///
/// ### CSS Grid
///
/// - [MDN: Basic Concepts of Grid Layout](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout/Basic_Concepts_of_Grid_Layout)