File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -393,14 +393,24 @@ impl Scroll {
393393 }
394394
395395 pub fn build ( & self , ui : & mut Ui , build : impl FnOnce ( & mut Ui ) ) {
396+ // ┌► ┌─────┐ ◄┐
397+ // │ │~~~~~│ │ visible_h
398+ // │ │~~~ │ │
399+ // full │ ├─────┤ ◄┘
400+ // │ │~~~ │
401+ // │ │~~~~~│
402+ // └► └─────┘
403+
396404 self :: layer ( ) . scissor_rect ( self . rect ) . build ( ui, |ui| {
397405 let last = self :: translate ( ) . y ( -self . scroll ) . build ( ui, build) ;
398- let last_y = last. y - self . rect . size . height ;
399406
400- let percentage = self . scroll / last_y;
407+ let visible_h = self . rect . size . height ;
408+ let full_h = last. y ;
409+
410+ let mult = visible_h / full_h;
411+ let h = visible_h * mult;
401412
402413 let w = 10.0 ;
403- let h = self . rect . height ( ) / ( last_y / self . rect . height ( ) ) ;
404414
405415 self :: quad ( )
406416 . y ( 0.0 )
@@ -410,7 +420,7 @@ impl Scroll {
410420 . border_radius ( [ 5.0 ; 4 ] )
411421 . build ( ui) ;
412422 self :: quad ( )
413- . y ( percentage * ( self . rect . size . height - h ) )
423+ . y ( self . scroll * mult )
414424 . x ( self . rect . size . width - w)
415425 . size ( w, h)
416426 . color ( [ 74 , 68 , 88 ] )
You can’t perform that action at this time.
0 commit comments