Remove scrollView
This commit is contained in:
parent
46ddbcea14
commit
0a1c5494d6
|
|
@ -19,8 +19,8 @@ fn main() {
|
|||
|
||||
fn prepare(mut commands: Commands) {
|
||||
commands.spawn(Camera2dBundle::default());
|
||||
commands.spawn((
|
||||
NodeBundle {
|
||||
commands
|
||||
.spawn(NodeBundle {
|
||||
style: Style {
|
||||
width: Val::Percent(100.0),
|
||||
height: Val::Percent(100.0),
|
||||
|
|
@ -28,10 +28,23 @@ fn prepare(mut commands: Commands) {
|
|||
justify_content: JustifyContent::Center,
|
||||
..default()
|
||||
},
|
||||
background_color: BackgroundColor(Color::BLUE),
|
||||
..default()
|
||||
},
|
||||
ScrollView,
|
||||
));
|
||||
})
|
||||
.with_children(|p| {
|
||||
p.spawn((
|
||||
NodeBundle {
|
||||
style: Style {
|
||||
width: Val::Percent(80.0),
|
||||
height: Val::Percent(50.0),
|
||||
..default()
|
||||
},
|
||||
background_color: BackgroundColor(Color::YELLOW),
|
||||
..default()
|
||||
},
|
||||
ScrollViewport::default(),
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
fn add_content(mut commands: Commands, q: Query<Entity, Added<ScrollViewContent>>) {
|
||||
|
|
|
|||
35
src/lib.rs
35
src/lib.rs
|
|
@ -8,8 +8,7 @@ pub struct ScrollViewPlugin;
|
|||
|
||||
impl Plugin for ScrollViewPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.register_type::<ScrollView>()
|
||||
.register_type::<ScrollViewport>()
|
||||
app.register_type::<ScrollViewport>()
|
||||
.register_type::<ScrollViewContent>()
|
||||
.add_systems(
|
||||
Update,
|
||||
|
|
@ -18,9 +17,6 @@ impl Plugin for ScrollViewPlugin {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Component, Default, Debug, Reflect)]
|
||||
pub struct ScrollView;
|
||||
|
||||
#[derive(Component, Debug, Reflect)]
|
||||
pub struct ScrollViewport {
|
||||
pub scroll_speed: f32,
|
||||
|
|
@ -39,23 +35,17 @@ pub struct ScrollViewContent {
|
|||
pub pos_y: f32,
|
||||
}
|
||||
|
||||
pub fn create_scroll_view(mut commands: Commands, q: Query<Entity, Added<ScrollView>>) {
|
||||
for e in q.iter() {
|
||||
commands.entity(e).with_children(|p| {
|
||||
p.spawn((
|
||||
NodeBundle {
|
||||
style: Style {
|
||||
overflow: Overflow::clip(),
|
||||
max_height: Val::Percent(100.0),
|
||||
max_width: Val::Percent(100.0),
|
||||
align_items: AlignItems::Start,
|
||||
..default()
|
||||
},
|
||||
..Default::default()
|
||||
},
|
||||
ScrollViewport::default(),
|
||||
Interaction::None,
|
||||
))
|
||||
pub fn create_scroll_view(
|
||||
mut commands: Commands,
|
||||
mut q: Query<(Entity, &mut Style), Added<ScrollViewport>>,
|
||||
) {
|
||||
for (e, mut style) in q.iter_mut() {
|
||||
style.overflow = Overflow::clip();
|
||||
style.align_items = AlignItems::Start;
|
||||
|
||||
commands
|
||||
.entity(e)
|
||||
.insert(Interaction::None)
|
||||
.with_children(|v| {
|
||||
v.spawn((
|
||||
NodeBundle {
|
||||
|
|
@ -68,7 +58,6 @@ pub fn create_scroll_view(mut commands: Commands, q: Query<Entity, Added<ScrollV
|
|||
ScrollViewContent { pos_y: 0.0 },
|
||||
));
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue