PDA

View Full Version : Carousel: How to prevent it from remembering which card it was on.



teammedich
5 Jan 2011, 11:53 AM
Hello -- I'm hoping to learn of how to force a carousel to always return to the first card if a user leaves that carousel and then returns to it. Thank you in advance for the help.

gkatz
5 Jan 2011, 12:00 PM
try looking into the API docs for events you can use...

teammedich
5 Jan 2011, 12:27 PM
I added a listener, and tried using events like deactivate, hide, remove, but so far, it only appears to reset to the first card if I use cardswitch:



listeners: {
cardswitch: function(carousel) {
carousel.setActiveItem(0);
}
}

I'm guessing there's some other function that I need to override?

dennishatcher
11 Sep 2011, 11:39 AM
When I close the overlay, I setActiveItem then before hiding the overlay:


dockedItems: [{
dock: 'top',
width: 1024,
html: '<div class="close" style="width:100%;text-align: right;">
<a href="#" ><img src="assets/Close.jpg" /> </a></div>',
listeners:{
body:{
tap: function(e) {
if (e.getTarget('.close')) {
carousel.setActiveItem(0, 'slide');
popup.hide();
}
},
delegate: ['.close']
}
},
}]

The problem I have now is how to reset the scroll position back to the top of each card in the carousel. As the user flicks through the carousel, and if they scroll down any card in the carousel, it will maintain the scroll position. It does go to the first card when closed, but the card the user scrolled down on, retains that scroll position. I have tried scroll, scrollTo, scrollToTop, etc... with no luck.