uix:carousel introduce `load_slide` method to animate to the provided

slide
This commit is contained in:
qua-non 2013-10-03 21:51:49 +05:30
parent dbc45322f1
commit 32a21e29b1
2 changed files with 18 additions and 0 deletions

View File

@ -17,6 +17,10 @@ Builder.load_string('''
Button
Button
Button
text: 'load(page 3)'
on_release:
carousel = root.parent.parent
carousel.load_slide(carousel.slides[2])
Button
Button
text: 'prev'

View File

@ -234,6 +234,20 @@ class Carousel(StencilView):
self._position_visible_slides, -1)
super(Carousel, self).__init__(**kwargs)
def load_slide(self, slide):
'''Animate to the slide that is passed as the argument.
.. versionchanged:: 1.8.0
'''
slides = self.slides
start, stop = slides.index(self.current_slide), slides.index(slide)
if stop > start:
self.index = stop - 1
self.load_next()
else:
self.index = stop + 1
self.load_previous()
def load_previous(self):
'''Animate to the previous slide.