File tree Expand file tree Collapse file tree 3 files changed +11
-5
lines changed Expand file tree Collapse file tree 3 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -87,8 +87,8 @@ impl AnimationManager {
87
87
Some ( anim) => {
88
88
let time_since_toggle = ( input. time - anim. toggle_time ) as f32 ;
89
89
// On the frame we toggle we don't want to return the old value,
90
- // so we extrapolate forwards:
91
- let time_since_toggle = time_since_toggle + input. predicted_dt ;
90
+ // so we extrapolate forwards by half a frame :
91
+ let time_since_toggle = time_since_toggle + input. predicted_dt / 2.0 ;
92
92
let current_value = remap_clamp (
93
93
time_since_toggle,
94
94
0.0 ..=animation_time,
Original file line number Diff line number Diff line change @@ -545,9 +545,10 @@ impl Prepared {
545
545
546
546
if self . fade_in {
547
547
if let Some ( last_became_visible_at) = self . state . last_became_visible_at {
548
- let age = ctx. input ( |i| ( i. time - last_became_visible_at) as f32 + i. predicted_dt ) ;
548
+ let age =
549
+ ctx. input ( |i| ( i. time - last_became_visible_at) as f32 + i. predicted_dt / 2.0 ) ;
549
550
let opacity = crate :: remap_clamp ( age, 0.0 ..=ctx. style ( ) . animation_time , 0.0 ..=1.0 ) ;
550
- let opacity = emath:: easing:: cubic_out ( opacity) ; // slow fade-out = quick fade-in
551
+ let opacity = emath:: easing:: quadratic_out ( opacity) ; // slow fade-out = quick fade-in
551
552
ui. multiply_opacity ( opacity) ;
552
553
if opacity < 1.0 {
553
554
ctx. request_repaint ( ) ;
Original file line number Diff line number Diff line change @@ -146,7 +146,7 @@ impl ContextImpl {
146
146
147
147
fn request_repaint_after (
148
148
& mut self ,
149
- delay : Duration ,
149
+ mut delay : Duration ,
150
150
viewport_id : ViewportId ,
151
151
cause : RepaintCause ,
152
152
) {
@@ -163,6 +163,11 @@ impl ContextImpl {
163
163
// Hovering a tooltip is a good example of a case where we want to repaint after a delay.
164
164
}
165
165
166
+ if let Ok ( predicted_frame_time) = Duration :: try_from_secs_f32 ( viewport. input . predicted_dt ) {
167
+ // Make it less likely we over-shoot the target:
168
+ delay = delay. saturating_sub ( predicted_frame_time) ;
169
+ }
170
+
166
171
viewport. repaint . causes . push ( cause) ;
167
172
168
173
// We save some CPU time by only calling the callback if we need to.
You can’t perform that action at this time.
0 commit comments