You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

github.com/Geeksltd/Zebble.Carousel

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/Geeksltd/Zebble.Carousel

v4.6.346+incompatible
Source
Go
Version published
Created
Source

Zebble.Carousel

logo

Carousel plugin allows the user to swipe from side to side to navigate through views, like a gallery slider.

NuGet


Setup


Api Usage

<Carousel Id="MyCarousel">
	<ImageView Path="..../Slide1.png" />
	<ImageView Path="..../Slide2.png" />
	<ImageView Path="..../Slide3.png" />
	...
</Carousel>

For adding a slide view in code behind to you Carousel use AddSlide(myView) method.

MyCarousel.AddSlide(new Canvas());

You can style the Carousel-Bullet and it's active state like this:

Carousel-Bullet{ 
	background-color:#eee;
	  &:active{ background-color:#333; 
	  } 
	}

Dynamic data source

In the above example, you can use a loop to dynamically create slides from a data source. For instance, the following code will show a slide for each image file inside the MySlides folder in the application resources:

<Carousel Id="MyCarousel">
	<z-foreach var="file" in="@GetSlideFiles()">
	   <ImageView Path="@file" />
	</z-foreach>
    <AnyOtherView />
</Carousel>

Code behind:

IEnumerable<string> GetSlideFiles()
{
     return Device.IO.Directory("Images/MySlides").GetFiles().Select(x => x.FullName);
}

Properties

PropertyTypeAndroidiOSWindows
CenterAlignedboolxxx
SlideWidthfloat?xxx
EnableZoomingboolxxx

Methods

MethodReturn TypeParametersAndroidiOSWindows
AddSlideTaskView => childxxx
NextTaskbool => animatexxx
PreviousTaskbool => animatexxx

RecyclerCarousel

Normal carousel is very flexible. Each slide can be any view object. But it requires all slides to be pre-rendered, which is not efficient if you have many.

In cases where you have several views all with the same templates, it's much more efficient to use RecyclerCarousel which is much much faster.

<RecyclerCarousel z-of="Product, SlideTemplate" DataSource="@Products">
    <z-Component z-type="SlideTemplate" z-base="RecyclerCarouselSlide[Product]">
        <ImageView Path="@{Item, x=>x?.Thumbnail}" />
        <TextView  Text="@{Item, x=>x?.Name}"/>
    </z-Component>
</RecyclerCarousel>

In the above example, Products is an IEnumerable<Product> which is the data source from which to populate the slides. For example you may have 10 product instances in an array. The carousel will always render a maximum of 3 items. As you swipe through the slides, it will reuse the slide ui objects and just change their X position and also update the data source which is the Item property. Please note that Item is a Bindable<Product> which means you need to use the @{Item, x=>x.Something} syntax in your template.

FAQs

Package last updated on 08 Dec 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts