From 96ba3a83ea2b5b2481aa8fc60061d4f76dcdeec6 Mon Sep 17 00:00:00 2001 From: Sebastian Krzyszkowiak <dos@dosowisko.net> Date: Sun, 10 Sep 2023 12:41:43 +0200 Subject: [PATCH] py,st3m: ViewManager: Don't count the first think into transition time The first think after a transition starts tends to take a longer time as the view gets instantiated. Allow the transition to actually play by skipping the first time think gets called. --- python_payload/st3m/ui/view.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/python_payload/st3m/ui/view.py b/python_payload/st3m/ui/view.py index c69d257c58..db791cdc9b 100644 --- a/python_payload/st3m/ui/view.py +++ b/python_payload/st3m/ui/view.py @@ -190,6 +190,8 @@ class ViewManager(Responder): self._history: List[View] = [] self._input = InputController() + self._first_think = False + def think(self, ins: InputState, delta_ms: int) -> None: self._input.think(ins, delta_ms) @@ -201,7 +203,10 @@ class ViewManager(Responder): self.pop(ViewTransitionSwipeRight()) if self._transitioning: - self._transition += (delta_ms / 1000.0) * (1000 / self._time_ms) + if not self._first_think: + self._transition += (delta_ms / 1000.0) * (1000 / self._time_ms) + else: + self._first_think = False if self._transition >= 1.0: self._transition = 0 self._transitioning = False @@ -249,6 +254,7 @@ class ViewManager(Responder): self._transitioning = True self._transition = 0.0 self._direction = direction + self._first_think = True self._outgoing = self._incoming if self._outgoing is not None: -- GitLab