views:

691

answers:

5

I'm using the anythingSlider by Chris Coyier.

Basically it makes list-items slide in from the left after a specified time.

I'd like to tweak the code, so that the first <li> is visible for twice as long as the others.

E.g. If the slides are visible for 7 seconds, the first slide needs to be visible for 14 seconds.

Any ideas?

A: 

You could change the startStop function to this (notice var extraTime):

     // Handles stopping and playing the slideshow
 // Pass startStop(false) to stop and startStop(true) to play
 base.startStop = function(playing){
  if(playing !== true) playing = false; // Default if not supplied is false

  // Update variable
  base.playing = playing;

  // Toggle playing and text
  if(base.options.autoPlay) base.$startStop.toggleClass("playing", playing).html( playing ? base.options.stopText : base.options.startText );

  var extraTime = 0;
  if(base.currentPage == 1){
   extraTime = base.options.delay;
  }

  if(playing){
   base.clearTimer(); // Just in case this was triggered twice in a row
   base.timer = window.setInterval(function(){
    base.goForward(true);
   }, base.options.delay + extraTime);
  } else {
   base.clearTimer();
  };
 };

This is in line 223 of jquery.anythingslider.js.

RamboNo5
+2  A: 

Should be easy enough

var timeVisible = 7000;
$('.anythingSlider').anythingSlider({
    autoPlay: true,
    startStopped: true,
    delay: timeVisible ,
    ...
});

setTimeout(function() {
    $("div.anythingSlider a#start-stop").trigger("click");
}, timeVisible);
jitter
This would be in the head of the page the slider is on, rather than editing the anythingSlider code it's self?? Is that true?
Jonny Haynes
Yes, exactly. No fiddling with anythingSlider source code needed. You just start the slider stopped and then programmatically start it after a certain amount of time via a `setTimeout`function. This way you can even show the first slide as long as you want
jitter
Genius! :-) Thanks for this!
Jonny Haynes
This is actually more of a fiddling, because it breaks the auto-start functionality and thereby relies on user interaction (i.e. click). Don't blame ya. This is alright, when that's it what the OP was searching for.
RamboNo5
You are totally wrong, auto-start functionality is not broken. Had you tried it you would have seen that no user interaction at all is required. jQuery starts the autoPlay after the defined period. The user doesn't need to click with the mouse or do anything at all.
jitter
I think here is a misunderstanding. I said auto-start. I never claimed autoPlay wouldn't work.Though one could fire the timer on the document ready event, which then would basically auto-start.
RamboNo5
I still can't grasp what your problem is. Check this demo page and tell me how it doesn't do what Jonny Haynes requested http://jsbin.com/usuti First image is shown 6 seconds, every other image is shown only 3 seconds. No user interaction required not even to start the slider
jitter
langsam dämmerts ;) I does indeed work very good. Sorry for causing trouble! You may edit your post so I can give it a thumbs up instead!
RamboNo5
Hab editiert. Her mit meinem Punkt ;-)
jitter
offtopic: something is wrong with stackoverflow. The points did show two for me and out of curiosity I clicked again on the up arrow and it switched back to 1 and remains the same. just saying...
RamboNo5
Clicking the uparrow a second time "undos" your vote. But you should be able to click a third time to vote up again
jitter
Thanks. I'm new to the site :)
RamboNo5
A: 

anythingSlider doesn't seem to work in Opera 10.10 (at least for me).

.anythingSlider .wrapper ul { width: 99999px; ---> .anythingSlider .wrapper ul { width: 9999px;

HOSOIToshiya
A: 

*HOSOIToshiya thank you!

kolgan
A: 

@HOSOIToshiya another thank you from me! Had a client complaining it wasn't working on Opera. I tried to reason that no-one uses it - I lost, but now I've Won!

Vince