-
23 Feb 2012 5:03 PM #1
Answered: Final (I hope) Carousel example question
Answered: Final (I hope) Carousel example question
I have the following code working properly (which, for a designer, is good progress) and I need to link to an internal image within the Carousel and load that ... let's say, image 4 of row 3.
I can make external links such as URLs and mailto etc open fine, but how do I load (and go directly to) a specific image?
Thanks for any help.Code:html: [ '<div>', '<img class="my-carousel-item-img" src="', category, '-', j, '.jpg" />', '<div id="external_link">', '<a href="http://www.google.com">Open external link</a>', '</div>', '<div id="internal_link">', '<a href="????????">Load image 4 of row 3</a>', '</div>', '</div>' ]
-
Best Answer Posted by mitchellsimoens
So basically you need to add a listener to the link and do a setActiveItem on the carousel to the appropriate item, you will also need to stop the event...
Just typing from memory but something like that.Code:carousel.element.on({ scope : carousel, click : function(e, t) { var target = e.getTarget('a'); if (target) { e.stopEvent(); this.setActiveItem(...); } } });
-
24 Feb 2012 5:54 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,637
- Vote Rating
- 435
- Answers
- 3106
You want a link to scroll to a certain image or to go to another item of the carousel?
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
24 Feb 2012 12:13 PM #3
Go to another item of the carousel. Suppose you have 4 rows of 12 images, 48 images in total. From image 2, I might want a link that goes to image 27. Then if you swipe horizontally, you'd go to 26 or 28, and a vertical swipe would take you into row 2 or 4 the way it works now.
How you transition between 2 and 27 (just loading image 27 with a sudden appearance, for example) is fine for MVP.
-
24 Feb 2012 12:17 PM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,637
- Vote Rating
- 435
- Answers
- 3106
So basically you need to add a listener to the link and do a setActiveItem on the carousel to the appropriate item, you will also need to stop the event...
Just typing from memory but something like that.Code:carousel.element.on({ scope : carousel, click : function(e, t) { var target = e.getTarget('a'); if (target) { e.stopEvent(); this.setActiveItem(...); } } });Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.


Reply With Quote