@@ -10,6 +10,8 @@ use thaw_utils::{class_list, mount_style, OptionalProp};
10
10
pub fn Scrollbar (
11
11
#[ prop( optional, into) ] class : OptionalProp < MaybeSignal < String > > ,
12
12
#[ prop( optional, into) ] style : Option < MaybeSignal < String > > ,
13
+ #[ prop( optional, into) ] content_class : OptionalProp < MaybeSignal < String > > ,
14
+ #[ prop( optional, into) ] content_style : OptionalProp < MaybeSignal < String > > ,
13
15
#[ prop( default = 8 ) ] size : u8 ,
14
16
children : Children ,
15
17
) -> impl IntoView {
@@ -54,6 +56,9 @@ pub fn Scrollbar(
54
56
if content_width <= 0.0 {
55
57
return 0.0 ;
56
58
}
59
+ if content_width <= container_width {
60
+ return 0.0 ;
61
+ }
57
62
x_track_width * container_width / content_width
58
63
} ) ;
59
64
let x_thumb_left = Memo :: new ( move |_| {
@@ -83,6 +88,10 @@ pub fn Scrollbar(
83
88
if content_height <= 0.0 {
84
89
return 0.0 ;
85
90
}
91
+ if content_height <= container_height {
92
+ return 0.0 ;
93
+ }
94
+
86
95
y_track_height * container_height / content_height
87
96
} ) ;
88
97
let y_thumb_top = Memo :: new ( move |_| {
@@ -271,7 +280,13 @@ pub fn Scrollbar(
271
280
>
272
281
273
282
<div class="thaw-scrollbar__container" ref=container_ref on: scroll=on_scroll>
274
- <div class="thaw-scrollbar__content" style="width: fit-content;" ref=content_ref>{ children( ) } </div>
283
+ <div
284
+ class=class_list![ "thaw-scrollbar__content" , content_class. map( |c| move || c. get( ) ) ]
285
+ style=move || format!( "width: fit-content; {}" , content_style. as_ref( ) . map_or( String :: new( ) , |s| s. get( ) ) )
286
+ ref=content_ref
287
+ >
288
+ { children( ) }
289
+ </div>
275
290
</div>
276
291
<div class="thaw-scrollbar__track--vertical" ref=y_track_ref>
277
292
<div
0 commit comments