fixup! fix(core/ui): respect animation_disabled() on T3T1

pull/3762/head
Martin Milata 1 month ago
parent bf00054675
commit 81620ec249

@ -48,7 +48,7 @@ impl<T: Component + Paginate + Clone> SwipePage<T> {
fn handle_transition(ctx: &mut EventCtx, event: Event, transition: &mut Transition<T>) -> bool {
let mut finished = false;
if let Event::Timer(EventCtx::ANIM_FRAME_TIMER) = event {
if transition.animation.finished(Instant::now()) || util::animation_disabled() {
if transition.animation.finished(Instant::now()) {
finished = true;
} else {
ctx.request_anim_frame();
@ -125,6 +125,15 @@ impl<T: Component + Paginate + Clone> Swipable for SwipePage<T> {
}
_ => {}
};
self.current = match direction {
SwipeDirection::Left | SwipeDirection::Up => (self.current + 1).min(self.pages - 1),
SwipeDirection::Right | SwipeDirection::Down => self.current.saturating_sub(1),
};
if util::animation_disabled() {
self.inner.change_page(self.current);
ctx.request_paint();
return true;
}
self.transition = Some(Transition {
cloned: unwrap!(Gc::new(self.inner.clone())),
animation: Animation::new(
@ -135,10 +144,6 @@ impl<T: Component + Paginate + Clone> Swipable for SwipePage<T> {
),
direction,
});
self.current = match direction {
SwipeDirection::Left | SwipeDirection::Up => (self.current + 1).min(self.pages - 1),
SwipeDirection::Right | SwipeDirection::Down => self.current.saturating_sub(1),
};
self.inner.change_page(self.current);
ctx.request_anim_frame();
ctx.request_paint();

@ -64,6 +64,12 @@ impl<Q: FlowState, S: FlowStore> SwipeFlow<Q, S> {
self.transition = Transition::Internal;
return;
}
if util::animation_disabled() {
self.state = state;
self.store.event(state.index(), ctx, Event::Attach);
ctx.request_paint();
return;
}
self.transition = Transition::External {
prev_state: self.state,
animation: Animation::new(
@ -106,7 +112,7 @@ impl<Q: FlowState, S: FlowStore> SwipeFlow<Q, S> {
Transition::External { animation, .. }
if matches!(event, Event::Timer(EventCtx::ANIM_FRAME_TIMER)) =>
{
if animation.finished(Instant::now()) || util::animation_disabled() {
if animation.finished(Instant::now()) {
finished = true;
ctx.request_paint();
self.store.event(i, ctx, Event::Attach)

Loading…
Cancel
Save