views:

51

answers:

1

how can i auto slide this slider link text i have little knowledge on jQuery and less on how to do this. the thing is that this slider slides when i click on an image but i also want this to start sliding automatic and when i hover on it it stops / pause sliding and then when i point my mouse out it continues sliding...

here is wat im using to slide the images on click

jQuery( document ).ready( function(){
    jQuery( '#flip' ).jcoverflip({
      current: 2,
      beforeCss: function( el, container, offset ){
        return [
          $.jcoverflip.animationElement( el, { left: ( container.width( )/2 - 210 - 110*offset + 20*offset )+'px', bottom: '40px' }, { } ),
          $.jcoverflip.animationElement( el.find( 'img' ), { width: Math.max(10,100-20*offset*offset) + 'px' }, {} )
        ];
      },
      afterCss: function( el, container, offset ){
        return [
          $.jcoverflip.animationElement( el, { left: ( container.width( )/2 + 110 + 110*offset )+'px', bottom: '40px' }, { } ),
          $.jcoverflip.animationElement( el.find( 'img' ), { width: Math.max(10,100-20*offset*offset) + 'px' }, {} )
        ];
      },
      currentCss: function( el, container ){
        return [
          $.jcoverflip.animationElement( el, { left: ( container.width( )/2 - 100 )+'px', bottom: 0 }, { } ),
          $.jcoverflip.animationElement( el.find( 'img' ), { width: '200px' }, { } )
        ];
      },

 }); });

I would be grateful if someone can help me with this...

A: 

I thing something like this should work:

jQuery(function() { //This is the same that document ready. If you already are in document ready function you shouldnt put this line.
  var move = true;
  jQuery("#flip").hover(function() {
    move = false;
  }, function() {
    move = true;
  });

  setTimeout(function() {
    if(move) {
      var eq = $("#flip").find("li").index($("#flip").find("li.current"));
      eq++;
      if ($("#flip").find("li:eq(" + eq + ")").length == 0)
        eq = 0;
      $("#flip").find("li:eq(" + eq + ")").click();
    }
  }, 600);
});

The current li should have "current" class.

The last update:

You had this code in the change event:

jQuery('#scrollbar').slider('value', ui.to -1);

It does not work, don't know why. Add in cahnge event this lines (before the one you already have because it throws error):

jQuery('#flip li.current').removeClass("current");
jQuery('#flip li:eq(' + ui.to + ')').addClass("current");

Also I made some changes to my code so that when it ends it start moving back. Here it is:

var move = 1,
    moving = true;
  jQuery("#flip").hover(function() {
    moving = false;
  }, function() {
    moving = true;
  });

  setInterval(function() {
    if(moving) {
      var eq = $("#flip").find("li").index($("#flip").find("li.current"));
      if(move == 1)
        eq++;
      else
        eq--;
      if(eq == -1) {
        eq = eq + 2;
        move = 1;
      }
      if ($("#flip").find("li:eq(" + eq + ")").length == 0) {
        eq = eq - 2;
        move = 0;
      }
      $("#flip").find("li:eq(" + eq + ")").click();
    }
  }, 600);
Diego
@Diego ummm i added The "current" class to the li tags like you said and didn't work, Did you test the code.?
donvitto
@donvitto: The current class doesn't have to be in all li. You said: "i added The "current" class to the li tags". The current class has to be ONLY in the selected or current li. The one wich was clicked.
Diego
@diego umm let me see...
donvitto
donvitto
@donvitto I've just updated the code. Read the first comment.
Diego
donvitto
@donvitto: that's it. My last update.
Diego
@Diego this works like how i wanted.! you are amazing ... but there is one more thing how do i make it when it finish to start to the first image fast not one by one ... because it slides back to the first image one by one
donvitto
@donvitto: what you want is event simpler that what i did but it looks very bad. Try it: click the last one and then the first one, you'll see how ugly it looks.
Diego
@Diego well im not really a jquery expert i just know the basic's but this works good.! anyway im still learning jquery is there a website you recommend me to learn some good tutorials ... my goal is to learn jquery like you, you figure this out in no time when i took weeks without success
donvitto
@donnvitto: jquery documents are really great when you don't get what a method does. (also jquery-ui docs). But the best way to learn is using it. Also this is a great forum!! Good luck
Diego
@Diego Alright man thank you very much you helped me alot and this means alot to me thank's again... See you around...
donvitto