mirror of https://github.com/kivy/kivy.git
uix:carousel introduce `load_slide` method to animate to the provided
slide
This commit is contained in:
parent
dbc45322f1
commit
32a21e29b1
|
@ -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'
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
Loading…
Reference in New Issue