From 9395104dfb9807166cd32bc03206cd1576ee1d3b Mon Sep 17 00:00:00 2001 From: Piotr Siuszko Date: Tue, 27 Feb 2024 10:02:49 +0100 Subject: [PATCH] Scroll speed --- .gitignore | 1 + src/lib.rs | 22 +++++++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index ea8c4bf..4fffb2f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /target +/Cargo.lock diff --git a/src/lib.rs b/src/lib.rs index edb42ed..b453242 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -21,8 +21,18 @@ impl Plugin for ScrollViewPlugin { #[derive(Component, Default, Debug, Reflect)] pub struct ScrollView; -#[derive(Component, Default, Debug, Reflect)] -pub struct ScrollViewport; +#[derive(Component, Debug, Reflect)] +pub struct ScrollViewport { + pub scroll_speed: f32, +} + +impl Default for ScrollViewport { + fn default() -> Self { + Self { + scroll_speed: 500.0, + } + } +} #[derive(Component, Debug, Reflect)] pub struct ScrollViewContent(pub Entity); @@ -38,7 +48,7 @@ pub fn create_scroll_view(mut commands: Commands, q: Query, - mut q: Query<(Entity, &mut Style, &Interaction), With>, + mut q: Query<(&mut Style, &Interaction, &ScrollViewport), With>, + time: Res