mirror of https://github.com/kivy/kivy.git
fix carousel bug with load_next, make _start_animation interface more flexible
This commit is contained in:
parent
284b402a95
commit
6ef8c427aa
kivy/uix
|
@ -282,8 +282,8 @@ class Carousel(StencilView):
|
||||||
_offset = _direction[self.direction]
|
_offset = _direction[self.direction]
|
||||||
if mode == 'prev':
|
if mode == 'prev':
|
||||||
_offset = -_offset
|
_offset = -_offset
|
||||||
self._offset = _offset
|
|
||||||
self._start_animation()
|
self._start_animation(min_move=0, offset=_offset)
|
||||||
|
|
||||||
def get_slide_container(self, slide):
|
def get_slide_container(self, slide):
|
||||||
return slide.parent
|
return slide.parent
|
||||||
|
@ -433,14 +433,15 @@ class Carousel(StencilView):
|
||||||
index += 1
|
index += 1
|
||||||
self.index = index
|
self.index = index
|
||||||
|
|
||||||
def _start_animation(self, *args):
|
def _start_animation(self, *args, **kwargs):
|
||||||
# compute target offset for ease back, next or prev
|
# compute target offset for ease back, next or prev
|
||||||
new_offset = 0
|
new_offset = 0
|
||||||
direction = self.direction
|
direction = kwargs.get('direction', self.direction)
|
||||||
is_horizontal = direction[0] in ['r', 'l']
|
is_horizontal = direction[0] in ['r', 'l']
|
||||||
extent = self.width if is_horizontal else self.height
|
extent = self.width if is_horizontal else self.height
|
||||||
min_move = self.min_move
|
min_move = kwargs.get('min_move', self.min_move)
|
||||||
_offset = self._offset
|
_offset = kwargs.get('offset', self._offset)
|
||||||
|
|
||||||
if _offset < min_move * -extent:
|
if _offset < min_move * -extent:
|
||||||
new_offset = -extent
|
new_offset = -extent
|
||||||
elif _offset > min_move * extent:
|
elif _offset > min_move * extent:
|
||||||
|
|
Loading…
Reference in New Issue