Skip to content

Commit 1eab36b

Browse files
committed
Fix UserProfileSlidingPane background color fade
1 parent 75f9c92 commit 1eab36b

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/profile/user_profile.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -305,17 +305,15 @@ script_mod! {
305305
from: {all: Forward {duration: 0.5}}
306306
ease: Ease.ExpDecay {d1: 0.80, d2: 0.97}
307307
apply: {
308-
slide: 0.0,
309-
bg_view: { draw_bg: { color: (COLOR_TRANSPARENT) } }
308+
slide: 0.0
310309
}
311310
}
312311
hide: AnimatorState{
313312
redraw: true,
314313
from: {all: Forward {duration: 0.5}}
315314
ease: Ease.ExpDecay {d1: 0.80, d2: 0.97}
316315
apply: {
317-
slide: 1.0,
318-
bg_view: { draw_bg: { color: #000000BB } }
316+
slide: 1.0
319317
}
320318
}
321319
}
@@ -390,7 +388,7 @@ pub struct UserProfileSlidingPane {
390388
#[source] source: ScriptObjectRef,
391389
#[deref] view: View,
392390
#[apply_default] animator: Animator,
393-
#[live] slide: f64,
391+
#[live] slide: f32,
394392

395393
#[rust] info: Option<UserProfilePaneInfo>,
396394
#[rust] is_animating_out: bool,
@@ -555,11 +553,15 @@ impl Widget for UserProfileSlidingPane {
555553
script_apply_eval!(cx, main_content, {
556554
margin.right: #(right_margin)
557555
});
558-
// let bg_alpha = (1.0 - self.slide) * 0.733; // 0.733 ≈ 0xBB/0xFF
559-
// let mut bg_view = self.view(cx, ids!(bg_view));
560-
// script_apply_eval!(cx, bg_view, {
561-
// draw_bg +: { color: vec4(0.0, 0.0, 0.0, #(bg_alpha)) }
562-
// });
556+
// Also derive the bg_view overlay alpha from `slide`.
557+
// The animator can only interpolate struct fields, not child view properties,
558+
// so we compute the bg color here from the smoothly-animated `slide` value.
559+
let bg_alpha = (1.0 - self.slide) * 0.733; // 0.733 ≈ 0xBB/0xFF
560+
let bg_color = vec4(0.0, 0.0, 0.0, bg_alpha);
561+
let mut bg_view = self.view(cx, ids!(bg_view));
562+
script_apply_eval!(cx, bg_view, {
563+
draw_bg +: { color: #(bg_color) }
564+
});
563565

564566
// Set the user name, using the user ID as a fallback.
565567
self.label(cx, ids!(user_name)).set_text(cx, info.displayable_name());

0 commit comments

Comments
 (0)