Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

iced_web: Scrollable not limited by max_width #6

Open
Kaiden42 opened this issue Nov 30, 2020 · 0 comments
Open

iced_web: Scrollable not limited by max_width #6

Kaiden42 opened this issue Nov 30, 2020 · 0 comments

Comments

@Kaiden42
Copy link

Hello,

I've noticed that the Scrollable widget on iced_web applies max_with to it's content, but not on itself. Which results in having the width of the scrollable DIV to not being limited by the maximum width.

This is a different behavior than iced_native.

Code to reproduce:

use iced::{
    scrollable, Container, Element, Length, Sandbox, Scrollable,
    Settings, Text
};

fn main() -> iced::Result {
    ScrollTest::run(Settings::default())
}

struct ScrollTest {
    state: scrollable::State,
}

#[derive(Clone, Debug)]
enum Message {}

impl Sandbox for ScrollTest {
    
    type Message = Message;

    fn new() -> Self {
        ScrollTest {
            state: scrollable::State::new(),
        }
    }
    
    fn title(&self) -> String {
        String::from("Scrollable Test")
    }
    
    fn update(&mut self, _: Self::Message) { }
    
    fn view(&mut self) -> Element<'_, Self::Message> {
        Container::new(
            Scrollable::new(&mut self.state)
                .max_width(600)
                .push(Text::new("This is a line").width(Length::Fill))
                .push(Text::new("This is a line").width(Length::Fill))
                .push(Text::new("This is a line").width(Length::Fill))
                .push(Text::new("This is a line").width(Length::Fill))
                .push(Text::new("This is a line").width(Length::Fill))
                .push(Text::new("This is a line").width(Length::Fill))
                .push(Text::new("This is a line").width(Length::Fill))
        )
        .center_x()
        .center_y()
        .width(Length::Fill)
        .height(Length::Fill)
        .into()
    }
}

iced_native on Linux:
iced_native

iced_web without maximum width:
web_without_max

iced_web with maximum width:
web_with_max

@hecrj hecrj transferred this issue from iced-rs/iced Jan 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant