scrollbar: Implement minimum thumb size (#25288)
This PR addresses 3 issues with the common scrollbar component used in the Terminal, Outline Panel, etc. 1. Extremely small or invisible scrollbar for long content. 2. Flickering issue when the thumb is already at the bottom-most position, and the user tries to overscroll. 3. Scrollbar appearing even when there is no excessive content to scroll. Before: <img width="300" alt="image" src="https://github.com/user-attachments/assets/8a124a72-3b56-4bef-858a-a4942c871829" /> After: <img width="300" alt="Screenshot 2025-02-21 at 3 26 32 AM" src="https://github.com/user-attachments/assets/2a8a5796-b332-4c06-84b2-226d2de6e300" /> Release Notes: - Fixed extremely small scrollbar thumb for long content in Terminal, Outline Panel, and more. --------- Co-authored-by: Danilo <danilo@zed.dev> Co-authored-by: Richard Feldman <oss@rtfeldman.com>
This commit is contained in:
parent
5e1dd91ee5
commit
d45aaa1745
2 changed files with 181 additions and 169 deletions
|
@ -69,9 +69,10 @@ impl ScrollableHandle for TerminalScrollHandle {
|
|||
let offset_delta = (point.y.0 / state.line_height.0).round() as i32;
|
||||
|
||||
let max_offset = state.total_lines - state.viewport_lines;
|
||||
let display_offset = ((max_offset as i32 + offset_delta) as usize).min(max_offset);
|
||||
let display_offset = (max_offset as i32 + offset_delta).clamp(0, max_offset as i32);
|
||||
|
||||
self.future_display_offset.set(Some(display_offset));
|
||||
self.future_display_offset
|
||||
.set(Some(display_offset as usize));
|
||||
}
|
||||
|
||||
fn viewport(&self) -> Bounds<Pixels> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue