Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Basic Scrolling in Tab Menu #3

Closed
wants to merge 14 commits into from
Prev Previous commit
Next Next commit
mod: without slide-in
  • Loading branch information
bennjii committed Jun 2, 2023
commit c7d10642accf0b3eaaace21336b96c9b177646ae
15 changes: 8 additions & 7 deletions src/container/tabs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct ScrollState {
pub consumed: Vec2,
pub available: Vec2,
pub offset_delta: Vec2,

pub prev_frame_left: bool,
pub prev_frame_right: bool
}
Expand Down Expand Up @@ -137,20 +137,21 @@ impl Tabs {

ui.set_clip_rect(ui.available_rect_before_wrap()); // Don't cover the `rtl_ui` buttons.

println!("{} {}", scroll_state.offset.x, scroll_state.prev_frame_left);

let mut consume = ui.available_width();

if scroll_state.offset.x > 20.0 {
// if !scroll_state.prev_frame_left {
// scroll_state.offset_delta.x -= 20.0;
// }
if !scroll_state.prev_frame_left {
scroll_state.offset_delta.x += 20.0;
}

scroll_state.prev_frame_left = true;

consume -= 20.0;
}else if scroll_state.offset.x > 0.0 {
consume -= scroll_state.offset.x;
if scroll_state.prev_frame_left {
scroll_state.offset.x -= 20.0;
}
// consume -= scroll_state.offset.x;
}else {
scroll_state.prev_frame_left = false;
}
Expand Down