uix:Carousel add `load_next` and `load_prev` methods for animating to

next
slide and previous slides closes #896
This commit is contained in:
qua-non 2013-05-08 00:42:41 +05:30
parent f6ba55b1a8
commit 3d284099a5
2 changed files with 30 additions and 0 deletions

View File

@ -19,8 +19,14 @@ Builder.load_string('''
Button
Button
Button
text: 'prev'
on_release:
root.parent.parent.load_previous()
Button
Button
text: 'next'
on_release:
root.parent.parent.load_next()
''')
class Page(GridLayout):

View File

@ -235,6 +235,30 @@ class Carousel(StencilView):
self._position_visible_slides, -1)
super(Carousel, self).__init__(**kwargs)
def load_previous(self):
'''Animate previous slide in.
.. versionadded:: 1.7.0
'''
self.load_next(mode='prev')
def load_next(self, mode='next'):
'''Animate previous slide in.
.. versionadded:: 1.7.0
'''
h, w = self.size
_direction = {
'top': -h / 2,
'bottom': h / 2,
'left': w / 2,
'right': -w / 2}
_offset = _direction[self.direction]
if mode == 'prev':
_offset = -_offset
self._offset = _offset
self._start_animation()
def get_slide_container(self, slide):
return slide.parent