From 6ef8c427aad8a666535ee3871464853d01774781 Mon Sep 17 00:00:00 2001 From: tshirtman Date: Tue, 8 Apr 2014 16:12:11 +0200 Subject: [PATCH] fix carousel bug with load_next, make _start_animation interface more flexible --- kivy/uix/carousel.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/kivy/uix/carousel.py b/kivy/uix/carousel.py index 7e530ac74..60c37375c 100644 --- a/kivy/uix/carousel.py +++ b/kivy/uix/carousel.py @@ -282,8 +282,8 @@ class Carousel(StencilView): _offset = _direction[self.direction] if mode == 'prev': _offset = -_offset - self._offset = _offset - self._start_animation() + + self._start_animation(min_move=0, offset=_offset) def get_slide_container(self, slide): return slide.parent @@ -433,14 +433,15 @@ class Carousel(StencilView): index += 1 self.index = index - def _start_animation(self, *args): + def _start_animation(self, *args, **kwargs): # compute target offset for ease back, next or prev new_offset = 0 - direction = self.direction + direction = kwargs.get('direction', self.direction) is_horizontal = direction[0] in ['r', 'l'] extent = self.width if is_horizontal else self.height - min_move = self.min_move - _offset = self._offset + min_move = kwargs.get('min_move', self.min_move) + _offset = kwargs.get('offset', self._offset) + if _offset < min_move * -extent: new_offset = -extent elif _offset > min_move * extent: