-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BasicCarousel not Responsive and How to change animate like slide effect #1
Comments
Hi @bobwatcherx from flet import *
from fletcarousel import BasicHorizontalCarousel
class CustomCarousel(UserControl):
item_width: int = 300
items_count: int = 3
def __init__(self, page: Page, images_url: list[str]):
super().__init__()
self.page = page
self.images_url = images_url
def carousel(self):
return BasicHorizontalCarousel(
page=self.page,
items_count=self.items_count,
items=[
Image(
src=url,
width=self.item_width,
fit="contain",
border_radius=15,
) for url in self.images_url
],
buttons=[
FloatingActionButton(
icon=icons.NAVIGATE_BEFORE,
),
FloatingActionButton(
icon=icons.NAVIGATE_NEXT,
)
],
vertical_alignment=CrossAxisAlignment.CENTER,
items_alignment=MainAxisAlignment.CENTER
)
def responsive(self, e):
window_width = self.page.window_width
if window_width < 600:
if self.item_width != 400:
self.item_width = 400
self.items_count = 1
self.body.content = self.carousel()
self.body.update()
elif window_width > 600:
if self.item_width != 300:
self.item_width = 300
self.items_count = 3
self.body.content = self.carousel()
self.body.update()
def build(self):
self.body = Container(
content=self.carousel()
)
return self.body
def _build(self):
super()._build()
self.page.on_resize = self.responsive
def main(page: Page):
page.padding = 0
page.spacing = 0
page.rtl = True
page.vertical_alignment = 'center'
page.horizontal_alignment = 'center'
urls = [
"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSwB7MO3r19FtBqVfGOf7fuLgzmKNvXVxYN-g&usqp=CAU",
"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQlTUDwXZ7kX2ouPA53UZf5vmzLVXOuE-odHA&usqp=CAU",
"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRUtgkhOS2Av_s1GKmy4ySUBFNk6orElAUh4w&usqp=CAU",
"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQVZU8rzFFighij-YnSf1ZaLDupdSQWhAycSw&usqp=CAU",
"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTvupidt5Hi7uXLvFhEscWFMUwhWGErVPEqJA&usqp=CAU"
]
page.add(
CustomCarousel(
page=page,
images_url=urls
)
)
app(target=main) we should use |
I want it to be responsive at all sizes. and I want there to be a slide effect or a custom effect on this basic carousel and whether you can activate the zoom effect when the image is in the middle
code
The text was updated successfully, but these errors were encountered: