Skip to content

Commit

Permalink
animation: correctly fixes Sequencial and Parallel animation when usi…
Browse files Browse the repository at this point in the history
…ng stop_property(). closes kivy#1255
  • Loading branch information
tito committed Aug 4, 2013
1 parent 0c53912 commit a3d445d
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions kivy/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,15 @@ def cancel_property(self, widget, prop):
if not props['properties']:
self.cancel(widget)

def have_properties_to_animate(self, widget):
'''Return True if a widget still have properties to animate.
.. versionadded:: 1.8.0
'''
props = self._widgets.get(widget.uid, None)
if props and props['properties']:
return True

#
# Private
#
Expand Down Expand Up @@ -353,6 +362,7 @@ def duration(self):

def start(self, widget):
self.stop(widget)
self._widgets[widget.uid] = True
self._register()
self.anim1.start(widget)

Expand All @@ -364,6 +374,13 @@ def stop(self, widget):
self.dispatch('on_complete', widget)
super(Sequence, self).cancel(widget)

def stop_property(self, widget, prop):
self.anim1.stop_property(widget, prop)
self.anim2.stop_property(widget, prop)
if (not self.anim1.have_properties_to_animate(widget) and
not self.anim2.have_properties_to_animate(widget)):
self.stop(widget)

def cancel(self, widget):
self.anim1.cancel(widget)
self.anim2.cancel(widget)
Expand Down Expand Up @@ -415,6 +432,13 @@ def stop(self, widget):
self.dispatch('on_complete', widget)
super(Parallel, self).cancel(widget)

def stop_property(self, widget, prop):
self.anim1.stop_property(widget, prop)
self.anim2.stop_property(widget, prop)
if (not self.anim1.have_properties_to_animate(widget) and
not self.anim2.have_properties_to_animate(widget)):
self.stop(widget)

def cancel(self, widget):
self.anim1.cancel(widget)
self.anim2.cancel(widget)
Expand Down

0 comments on commit a3d445d

Please sign in to comment.