SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2005
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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:

    Code:
    $("#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

  2. #2
    SitePoint Evangelist silver trophybronze trophy
    Join Date
    Jul 2013
    Posts
    406
    Mentioned
    22 Post(s)
    Tagged
    0 Thread(s)
    Hi ikandee,
    It seems
    Code:
    ...
    infinite: true,
    ...
    will do it.

  3. #3
    SitePoint Enthusiast
    Join Date
    Sep 2005
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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?

  4. #4
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,997
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    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?

  5. #5
    SitePoint Enthusiast
    Join Date
    Sep 2005
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Pullo View Post
    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....s/projects.php
    Thanks.

  6. #6
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,997
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    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?

  7. #7
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,997
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    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:

    HTML Code:
    <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:

    Code JavaScript:
    // 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


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •