Skip to content

Commit db7dff2

Browse files
Fix subpixel animations
1 parent c7ca56b commit db7dff2

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/pixel_shift.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::{
55
use crate::TIMEOUT_MS;
66

77
const INTERVAL_MS: i32 = TIMEOUT_MS * 1; // should be a multiple of TIMEOUT_MS
8-
const PROLONGED_INTERVAL_MS: i32 = TIMEOUT_MS * 1; // should be a multiple of TIMEOUT_MS and more than INTERVAL_MS
8+
const PROLONGED_INTERVAL_MS: i32 = TIMEOUT_MS * 5; // should be a multiple of TIMEOUT_MS and more than INTERVAL_MS
99
const ANIMATION_INTERVAL_MS: i32 = 200; // should be less than TIMEOUT_MS
1010
const ANIMATION_DURATION_MS: i32 = 4000; // should be a multiple of ANIMATION_INTERVAL_MS
1111

@@ -73,7 +73,7 @@ impl PixelShiftManager {
7373
match self.state {
7474
ShiftState::Normal => {
7575
self.state = ShiftState::ShiftingSubpixel;
76-
self.subpixel_progress = self.direction as f64;
76+
self.subpixel_progress = if self.direction == 1 { 0.0 } else { 1.0 };
7777
},
7878
ShiftState::ShiftingSubpixel => {
7979
let shift_by = ANIMATION_INTERVAL_MS as f64 / ANIMATION_DURATION_MS as f64;

0 commit comments

Comments
 (0)