Skip to content

Commit

Permalink
chore: 🤖 apply suggested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
theashraf committed Jan 16, 2024
1 parent 95033bf commit af1de12
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions dotlottie-rs/src/dotlottie_player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down Expand Up @@ -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;

Expand All @@ -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 {
Expand All @@ -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;
Expand All @@ -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 => {
Expand Down Expand Up @@ -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 => {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 => {
Expand Down

0 comments on commit af1de12

Please sign in to comment.