Skip to content

Commit

Permalink
fix animated images
Browse files Browse the repository at this point in the history
  • Loading branch information
Kl4rry committed May 23, 2024
1 parent 938c573 commit 5f55acf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,7 @@ impl App {
}

pub fn update(&mut self, _wgpu: &WgpuState) -> (bool, Duration) {
self.delay = Duration::MAX;
if let Some(ref mut image) = self.image_view {
self.delay = self.delay.min(image.animate());
}
Expand Down
10 changes: 2 additions & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use std::{
path::PathBuf,
sync::{Arc, Mutex},
thread,
time::Duration,
};

use cgmath::Vector2;
Expand Down Expand Up @@ -227,6 +226,7 @@ impl WindowHandler<'_> {

let _ = event_loop.run(move |event, event_loop| match event {
Event::Resumed => wgpu.window.set_visible(true),
Event::NewEvents(..) => wgpu.window.request_redraw(),
Event::WindowEvent { event, .. } => match event {
WindowEvent::CloseRequested => {
let _ = proxy.send_event(UserEvent::Exit);
Expand Down Expand Up @@ -275,13 +275,7 @@ impl WindowHandler<'_> {
event_loop.exit();
}

let control_flow = if repaint_after.is_zero() {
wgpu.window.request_redraw();
app.delay = Duration::MAX;
ControlFlow::Wait
} else {
ControlFlow::wait_duration(repaint_after)
};
let control_flow = ControlFlow::wait_duration(repaint_after);
event_loop.set_control_flow(control_flow);

let output = wgpu.surface.get_current_texture().unwrap();
Expand Down

0 comments on commit 5f55acf

Please sign in to comment.