Anchor Link to Caroufredsel

Hi Guys,
Just a quick question… I have implemented the caroufredsel into the following website, which is all working great.

My question is I’d like to #anchor link from images on the homepage to the carousel on the (portfolio page) - but when I try doing that it stuffs up the carousel order. (By that I mean instead of the carousel starting and ending where it should, the anchor link seems to be resetting the start and end point to where the linked image is located within the carousel.)

The javascript used is:

$("#foo2").carouFredSel({
					responsive	: true,
					circular: false,
					infinite: false,
					auto : false,
					prev : "#foo1_prev",
					next : "#foo1_next",
					scroll		: {
						fx			: "crossfade"
					},
					items		: {
						start		: true,
						visible		: 1,
						width		: 767,
						height		: "100%"
					}
				});
				
				$("#foo2 img").each(function(n) {
					$(this).attr("id", "item"+n);
				});

It’s the “items: start: true,” that I think is causing the carousel to reset from wherever the linked image is located within the carousel… but I am not sure what to change it to to fix the problem.
Hoping someone can suggest a fix.
Thanks

Hi ikandee,
It seems

...
infinite: true,
...

will do it.

Hi Francky, Thanks for your response but unfortunately that is not what I am after as the carousels needs to have a start and end point. Therefore it can not be infinite. Any other suggestions?

Hi ikandee,

I had a look at the site you link to, but couldn’t find any occurrence of caroufredsel.
Did you remove it in the meantime?

Hi Pullo,
The carousel is on the projects page: http://roncorbettbuildingdesign.com.au/housedesigns-additions/projects.php
Thanks.

Doh! How did I miss that?
I guess I was waiting for something to slide, but it seems you have to hit the button.

Anyway, back to your question.
Do I understand you correctly, that you want to be able to link to individual images in the carousel?

If that is what you would like to do, then this is the way to achieve it.

From any page on your site, link to your carousel page passing in the desired slide as a parameter in the url:

<a href="http://roncorbettbuildingdesign.com.au/housedesigns-additions/projects.php?slide=5">My Link</a>

Don’t forget that the first slide has a value of 0

Then, on your carousel page, drop in this code directly before the closing </body> tag:

// Function taken from: http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values
function getParameterByName(name) {
  name = name.replace(/[\\[]/, "\\\\\\[").replace(/[\\]]/, "\\\\\\]");
  var regex = new RegExp("[\\\\?&]" + name + "=([^&#]*)"),
      results = regex.exec(location.search);
  return results == null ? "" : decodeURIComponent(results[1].replace(/\\+/g, " "));
}

var slideNo = getParameterByName("slide");

if (slideNo){
  $('#foo2').trigger('slideTo', slideNo);
}

where “#foo2” is the id of your carousel div.

Job done :slight_smile: