Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: Step Carousel Viewer and current item?

  1. #1
    Join Date
    Feb 2008
    Posts
    137
    Thanks
    18
    Thanked 2 Times in 2 Posts

    Question Step Carousel Viewer and current item?

    Step Carousel Viewer

    http://www.dynamicdrive.com/dynamici...epcarousel.htm

    I have used this wonderful script to create dynamically loaded menu of images, these images are linked to bigger images with id's used as filters.
    PHP Code:
    pagename.php?id=<id from db
    How do I keep the current state after clicking the carousel item.
    I have 16 menu item (images) - each one has a different link
    I click on item number 19 (which has been scrolled into view) - the page refreshes and I loose the item that I scrolled to previously.

    Is there something that could be used to remember the previously clicked item?

    Cheers

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    You could just add in some boiler plate cookie code (this one's from http://www.quirksmode.org/js/cookies.html):

    Code:
    function createCookie(name,value,days) {
    	if (days) {
    		var date = new Date();
    		date.setTime(date.getTime()+(days*24*60*60*1000));
    		var expires = "; expires="+date.toGMTString();
    	}
    	else var expires = "";
    	document.cookie = name+"="+value+expires+"; path=/";
    }
    
    function readCookie(name) {
    	var nameEQ = name + "=";
    	var ca = document.cookie.split(';');
    	for(var i=0;i < ca.length;i++) {
    		var c = ca[i];
    		while (c.charAt(0)==' ') c = c.substring(1,c.length);
    		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    	}
    	return null;
    }
    
    function eraseCookie(name) {
    	createCookie(name,"",-1);
    }
    Then in the setup:

    Code:
    stepcarousel.setup({
    galleryid: 'mygallery', //id of carousel DIV
    beltclass: 'belt', //class of inner "belt" DIV containing all the panel DIVs
    panelclass: 'panel', //class of panel DIVs each holding content
    statusvars: ['statusA', 'statusB', 'statusC'], // Register 3 "status" variables
    onslide:function(){
    createCookie('mygallery',statusB);
    },
    oninit:function(){
    if(readCookie('mygallery'))
    stepcarousel.stepTo('mygallery', readCookie('mygallery'));
    },
    contenttype: ['inline'] // content type
    })
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Feb 2008
    Posts
    137
    Thanks
    18
    Thanked 2 Times in 2 Posts

    Default

    WOW cool, but it scrolls 8 items as soon as the page loads, or when I click the first item.

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Well it will scroll to the item that was displaying. I don't know what you mean about:

    or when I click the first item
    Please post a link to the page on your site that contains the problematic code so we can check it out.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Feb 2008
    Posts
    137
    Thanks
    18
    Thanked 2 Times in 2 Posts

    Default

    It's not online - it's on my PC.
    When I change the stepTo to stepBy it sort of works, sort of.
    Or changin statusB to statusA or statusC as well.

    I will try to drop it online now.

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Using stepBy() will move the viewer that number of 'slides'. Starting from the first slide (as it would be when reloading) it should amount to the same thing as stepTo(). However, in local testing it messes up for me. Only stepTo() works here.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. #7
    Join Date
    Feb 2008
    Posts
    137
    Thanks
    18
    Thanked 2 Times in 2 Posts

    Default

    Here is what I got:

    http://www.kleyn.co.za/home_2.php?catid=1
    If you clicked on any of the links on the left you have to click on To 1st Panel to see all the cars

    I hope the site loads for you.
    Last edited by student101; 07-19-2008 at 10:25 AM.

  8. #8
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Well what do you want to have happen? I thought you wanted that on page load/reload that the scroller would scroll to the state that it was last scrolled to. If you want something different to happen, please be specific.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  9. #9
    Join Date
    Feb 2008
    Posts
    137
    Thanks
    18
    Thanked 2 Times in 2 Posts

    Default

    The item clicked should stay clicked.
    If you click item 13 then it just scrolls uncontrollably to the next 8 items.

    In that example I only loaded 8 items, let me load the same amount so there will be 16 of them.

    Currently even with the 8 items it still scrolls on it's own, even if you click the third item.

  10. #10
    Join Date
    Feb 2008
    Posts
    137
    Thanks
    18
    Thanked 2 Times in 2 Posts

    Default

    Quote Originally Posted by jscheuer1 View Post
    Well what do you want to have happen? I thought you wanted that on page load/reload that the scroller would scroll to the state that it was last scrolled to. If you want something different to happen, please be specific.
    Cool now there are more, yet it still scrolls on it's own, it may be a bit confusing as some of the images are the same.

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
  •