diff options
author | Dan Williams <dcbw@redhat.com> | 2007-03-12 01:39:00 (GMT) |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2007-03-12 01:39:00 (GMT) |
commit | a1411040f15a12a08b48dd8ef5ac44cd534459ba (patch) | |
tree | c021a9f86e9042515a5b95d96b384f7a03c85568 /shell | |
parent | b5ced20ca4264c64aa25789b78d753303a68d8a9 (diff) |
Make frame animation faster and smoother
Diffstat (limited to 'shell')
-rw-r--r-- | shell/view/frame/frame.py | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/shell/view/frame/frame.py b/shell/view/frame/frame.py index 0d2231e..6586cd3 100644 --- a/shell/view/frame/frame.py +++ b/shell/view/frame/frame.py @@ -232,7 +232,15 @@ class Frame: def do_slide_in(self, current=0, n_frames=0): if _ANIMATION: - self._move(float(current + 1) / float(n_frames)) + if current + 1 == n_frames: + # hardcode last frame to avoid precision errors in division + self._move(1) + else: + # each frame, move half the remaining distance + pos = 0.0 + for i in range(0, current + 1): + pos += float((1.0 - float(pos)) / 2.0) + self._move(pos) elif current == 0: self._move(1) if self._event_frame.is_visible(): @@ -240,7 +248,15 @@ class Frame: def do_slide_out(self, current=0, n_frames=0): if _ANIMATION: - self._move(1 - (float(current + 1) / float(n_frames))) + if current + 1 == n_frames: + # hardcode last frame to avoid precision errors in division + self._move(0) + else: + # each frame, move half the remaining distance + pos = 0.0 + for i in range(0, current + 1): + pos += float((1.0 - float(pos)) / 2.0) + self._move(1.0 - float(pos)) elif current == 0: self._move(0) if not self._event_frame.is_visible(): |