@@ -94,8 +94,11 @@ impl UseFloatingOptions {
9494 self . while_elements_mounted ( auto_update_rc. into ( ) )
9595 }
9696
97- /// Set `while_elements_mounted` option to [`auto_update`] with [`AutoUpdateOptions::default`].
98- pub fn while_elements_mounted_auto_update_enabled ( self , enabled : MaybeSignal < bool > ) -> Self {
97+ /// Set `while_elements_mounted` option to [`auto_update`] with [`AutoUpdateOptions::default`] when `enabled` is `true`.
98+ pub fn while_elements_mounted_auto_update_with_enabled (
99+ self ,
100+ enabled : MaybeSignal < bool > ,
101+ ) -> Self {
99102 let auto_update_rc: Rc < WhileElementsMountedFn > = Rc :: new ( |reference, floating, update| {
100103 auto_update ( reference, floating, update, AutoUpdateOptions :: default ( ) )
101104 } ) ;
@@ -107,6 +110,41 @@ impl UseFloatingOptions {
107110 }
108111 } ) )
109112 }
113+
114+ /// Set `while_elements_mounted` option to [`auto_update`] with `options`.
115+ pub fn while_elements_mounted_auto_update_with_options (
116+ self ,
117+ options : MaybeSignal < AutoUpdateOptions > ,
118+ ) -> Self {
119+ let auto_update_rc = move |options : AutoUpdateOptions | -> Rc < WhileElementsMountedFn > {
120+ Rc :: new ( move |reference, floating, update| {
121+ auto_update ( reference, floating, update, options. clone ( ) )
122+ } )
123+ } ;
124+
125+ self . while_elements_mounted ( MaybeProp :: derive ( move || Some ( auto_update_rc ( options ( ) ) ) ) )
126+ }
127+
128+ /// Set `while_elements_mounted` option to [`auto_update`] with `options` when `enabled` is `true`.
129+ pub fn while_elements_mounted_auto_update_with_enabled_and_options (
130+ self ,
131+ enabled : MaybeSignal < bool > ,
132+ options : MaybeSignal < AutoUpdateOptions > ,
133+ ) -> Self {
134+ let auto_update_rc = move |options : AutoUpdateOptions | -> Rc < WhileElementsMountedFn > {
135+ Rc :: new ( move |reference, floating, update| {
136+ auto_update ( reference, floating, update, options. clone ( ) )
137+ } )
138+ } ;
139+
140+ self . while_elements_mounted ( MaybeProp :: derive ( move || {
141+ if enabled ( ) {
142+ Some ( auto_update_rc ( options ( ) ) )
143+ } else {
144+ None
145+ }
146+ } ) )
147+ }
110148}
111149
112150/// CSS styles to apply to the floating element to position it.
@@ -119,6 +157,31 @@ pub struct FloatingStyles {
119157 pub will_change : Option < String > ,
120158}
121159
160+ impl FloatingStyles {
161+ pub fn style_position ( & self ) -> String {
162+ match self . position {
163+ Strategy :: Absolute => "absolute" . into ( ) ,
164+ Strategy :: Fixed => "fixed" . into ( ) ,
165+ }
166+ }
167+
168+ pub fn style_top ( & self ) -> String {
169+ self . top . clone ( )
170+ }
171+
172+ pub fn style_left ( & self ) -> String {
173+ self . left . clone ( )
174+ }
175+
176+ pub fn style_transform ( & self ) -> Option < String > {
177+ self . transform . clone ( )
178+ }
179+
180+ pub fn style_will_change ( & self ) -> Option < String > {
181+ self . will_change . clone ( )
182+ }
183+ }
184+
122185impl From < FloatingStyles > for String {
123186 fn from ( value : FloatingStyles ) -> Self {
124187 format ! (
0 commit comments