diff --git a/dotlottie-rs/src/dotlottie_player.rs b/dotlottie-rs/src/dotlottie_player.rs index 6b359eba..bf240086 100644 --- a/dotlottie-rs/src/dotlottie_player.rs +++ b/dotlottie-rs/src/dotlottie_player.rs @@ -109,7 +109,7 @@ impl DotLottieRuntime { if self.is_loaded { self.playback_state = PlaybackState::Stopped; let start_frame = 0_f32; - let end_frame = self.total_frames() - 1.0; + let end_frame = self.total_frames(); match self.config.mode { Mode::Forward | Mode::Bounce => { @@ -139,7 +139,7 @@ impl DotLottieRuntime { } as f32; let duration = (self.duration() * 1000.0) / self.config.speed as f32; - let total_frames = self.total_frames() - 1.0; + let total_frames = self.total_frames(); let raw_next_frame = elapsed_time / duration * total_frames; @@ -166,7 +166,7 @@ impl DotLottieRuntime { } fn handle_forward_mode(&mut self, next_frame: f32) -> f32 { - let total_frames = self.total_frames() - 1.0; + let total_frames = self.total_frames(); if next_frame >= total_frames { if self.config.loop_animation { @@ -183,7 +183,7 @@ impl DotLottieRuntime { } fn handle_reverse_mode(&mut self, next_frame: f32) -> f32 { - let total_frames = self.total_frames() - 1.0; + let total_frames = self.total_frames(); if next_frame <= 0.0 { if self.config.loop_animation { self.loop_count += 1; @@ -198,7 +198,7 @@ impl DotLottieRuntime { } fn handle_bounce_mode(&mut self, next_frame: f32) -> f32 { - let total_frames = self.total_frames() - 1.0; + let total_frames = self.total_frames(); match self.direction { Direction::Forward => { @@ -227,7 +227,7 @@ impl DotLottieRuntime { } fn handle_reverse_bounce_mode(&mut self, next_frame: f32) -> f32 { - let total_frames = self.total_frames() - 1.0; + let total_frames = self.total_frames(); match self.direction { Direction::Reverse => { @@ -264,7 +264,7 @@ impl DotLottieRuntime { } pub fn total_frames(&self) -> f32 { - self.renderer.total_frames().unwrap_or(0.0) + self.renderer.total_frames().unwrap_or(0.0) - 1.0 } pub fn duration(&self) -> f32 { @@ -307,7 +307,7 @@ impl DotLottieRuntime { self.is_loaded = loaded; let first_frame = 0_f32; - let end_frame = self.total_frames() - 1.0; + let end_frame = self.total_frames(); match self.config.mode { Mode::Forward | Mode::Bounce => {