Jon Haider
Posts: 0
Joined: Thu Oct 16, 2014 2:53 pm

How to programmatically change the default slide on a carousel after navigating to another page.

Hi guys,
I'm trying to figure out the best way to achieve the following:

On my home-screen, I have a carousel. On the LAST slide/frame of the carousel, I have a button that navigates to another page (page2). When someone clicks the "Back" button from that new page, it navigates back to my home-screen, but it automatically takes them back to the FIRST slide/frame. Is there anyway I can force them back to the LAST slide/frame upon returning from the second page, since that's where they navigated from?

I essentially want to accomplish the equivalent of:

pre
var carousel = Appery("mobilecarousel_438");
var newitem = Appery("mobilecarouselitem_445");
carousel.carouselRoot.carousel("slide", false, newitem );
//or equivalently:
//carousel.carouselRoot.carousel("to", index ); //where index corresponds to my last frame
/pre

after navigating back to my home-page, but without the user seeing the "sliding" transition. They should instantly be taken back to the appropriate frame.

Is this possible?
(Perhaps I can use the "to" method with a very small animation duration - like 50 milliseconds to simulate a fast transition)?
Thank you in advance!

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

How to programmatically change the default slide on a carousel after navigating to another page.

Hello Jon,

It is possible to use "to" method. Also you can change "Animation duration" parameter. Please read this article for more information: https://devcenter.appery.io/documenta...

Jon Haider
Posts: 0
Joined: Thu Oct 16, 2014 2:53 pm

How to programmatically change the default slide on a carousel after navigating to another page.

Thank you Sergiy!
Unfortunately, with the "to" method you have to (as you've mentioned) change the animation duration. The problem is that when you execute the animation duration change:
pre
carousel.carouselRoot.carousel({
animationDuration: 10
});
/pre
then you need to change it back after jumping to the last frame, but when you use:
pre
carousel.carouselRoot.carousel({
animationDuration: 250
});
/pre
it snaps back to the first frame upon firing. Not a smooth solution.

I guess a better question would be, can we change the "default" frame of a carousel (the frame that is automatically displayed when the carousel is loaded). I saw somewhere that there's a function like:
pre
$(document).ready(function() {
$('#mycarousel').jcarousel({
start: 2,
auto: 2,
scroll: 1,
wrap: "circular"
});
});
/pre
to change the "Start" frame, but this is intended for a specific jQuery plugin (jCarousel), and there is no "Start" on the Appery Carousel component documentation page (same page you posted).

Is there an equivalent function that changes the "start" frame on a carousel?

Thank you!

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

How to programmatically change the default slide on a carousel after navigating to another page.

There are not such method. But you can use jcarousel, if you want

Return to “Issues”