triniwiz / nativescript-pager

Apache License 2.0
90 stars 48 forks source link

when made to to auto play only images are changing not indicators at the bottom #159

Closed vikasacharya16 closed 4 years ago

vikasacharya16 commented 4 years ago

When i tried to auto play the images by below code

const carousel = args.object.getViewById("myCarousel");
    setInterval(() => {
        if (carousel.selectedIndex == carousel.items.length - 1)
            carousel.selectedIndex = 0;
        else
            ++carousel.selectedIndex;
    }, 3000);
}

only the images will auto play. but not indicators at the bottom.

but when i manually scroll it, the indicators will change and no problem.

this is my xml

<pager:Pager items="{{ image_array }}" row="0" id="myCarousel" loaded="carouselLoaded" unloaded="carouselUnloaded" spacing="0%" peaking="0%"  showIndicator="true" backgroundColor="lightsteelblue">
                <pager:Pager.itemTemplate>
                    <GridLayout>
                        <Image src="{{ image }}" stretch="aspectFill" />
                    </GridLayout>
                </pager:Pager.itemTemplate>
            </pager:Pager>