Yes, the instructions are the way to go and its quite simple once you understand keyframes (divided over a 100% duration). What makes this task a bit easier is that you're doubling the image quantity, so similarly, you can expect to apply either a halving or doubling logic to any of the provided values.
So, the first things to do is to create the markup for those extra frames. Do that in your html, and sequentially increase the id/class accordingly (sixth, seventh, eighth, etc.) That's the easy part.
Next, head over to the "styles.css" file and also check the part of the tutorial which references the calculations;
1. Define the total number of images to use in the slider
5
2. Define the length of animation for each image
5 seconds
3. Define the total duration of the animation
Multiply the total number of images by the duration of each image:
5 images × 5 seconds = 25 seconds
4. Calculate how many keyframes equals one second
Divide the total number of keyframes by the total duration of the animation.
100 keyframes / 25 seconds = 4 keyframes
4 keyframes = 1 second
Substitute in your changes;
1. Define the total number of images to use in the slider
10
2. Define the length of animation for each image
5 seconds
3. Define the total duration of the animation
Multiply the total number of images by the duration of each image:
10 images × 5 seconds = 50 seconds
4. Calculate how many keyframes equals one second
Divide the total number of keyframes by the total duration of the animation.
100 keyframes / 50 seconds = 2 keyframes
2 keyframes = 1 second
What we can see is that the total animation duration has increased from 25s to 50s (makes sense, as you've doubled the amount of images), so now open your "styles.css" file and increase the animation sequences from 25s to 50s - those are the lines that look like this;
Code:
#slider li.firstanimation {
-moz-animation:cycle 50s linear infinite;
-webkit-animation:cycle 50s linear infinite;
}
Do that for all the #slider li.firstanimation, #slider li.secondanimation, #slider li.thirdanimation, #slider li.fourthanimation, etc. definitions, right up to and including the ones you will add for #slider li.tenthanimation
Now head over to the "animation.css" file. Look at the % values for the 5 animations slides and you can see that overall, their total animation spans 100% (ie, a full slideshow cycle), while the animation for each slide spans approximately a 5th or 20% of the total time - most of the animation for slide 1 happens between 0% and 20%, most of the animation for slide 2 happens between 20% and 40% and most of the animation for slide 3 happens between 40% and 60%, etc.
Now, we already know that the quantity of slides has doubled from 5 to 10, so in effect, the animation for each slides needs to be halved to make room for the extra 5 slides, so the changes that we make (corresponding to the new keyframe value of 2 frames per second instead of 4 frames per second) can easily be done by halving (most of) the percentages within the total keyframes boundary of 0% and 100%. So this;
Code:
@-moz-keyframes cycle {
0% { top:0px; }
4% { top:0px; }
16% { top:0px; opacity:1; z-index:0; }
20% { top:325px; opacity:0; z-index:0; }
21% { top:-325px; opacity:0; z-index:-1; } /* just a 1% tickover to change z-index quickly */
50% { top:-325px; opacity:0; z-index:-1; }
92% { top:-325px; opacity:0; z-index:0; }
96% { top:-325px; opacity:0; }
100%{ top:0px; opacity:1; }
}
Would become this;
Code:
@-moz-keyframes cycle {
0% { top:0px; }
2% { top:0px; }
8% { top:0px; opacity:1; z-index:0; }
10% { top:325px; opacity:0; z-index:0; }
11% { top:-325px; opacity:0; z-index:-1; } /* just a 1% tickover to change z-index quickly */
25% { top:-325px; opacity:0; z-index:-1; }
96% { top:-325px; opacity:0; z-index:0; }
98% { top:-325px; opacity:0; }
100%{ top:0px; opacity:1; }
}
Conveniently, when you transpose this logic on to the remaining 4 original slides, and then add in the extras up to 10 slides, you can work in sequential values of 10 - the CSS for slides 2 to 9 are identical apart from the animation percentages - do you see the emerging pattern?;
Code:
@-moz-keyframes cycle {
0% { top:0px; }
2% { top:0px; }
8% { top:0px; opacity:1; z-index:0; }
10% { top:325px; opacity:0; z-index:0; }
11% { top:-325px; opacity:0; z-index:-1; }
25% { top:-325px; opacity:0; z-index:-1; }
96% { top:-325px; opacity:0; z-index:0; }
98% { top:-325px; opacity:0; }
100%{ top:0px; opacity:1; }
}
@-moz-keyframes cycletwo {
0% { top:-325px; opacity:0; }
8% { top:-325px; opacity:0; }
10% { top:0px; opacity:1; }
12% { top:0px; opacity:1; }
18% { top:0px; opacity:1; z-index:0; }
20% { top:325px; opacity:0; z-index:0; }
21% { top:-325px; opacity:0; z-index:-1; }
100%{ top:-325px; opacity:0; z-index:-1; }
}
@-moz-keyframes cyclethree {
0% { top:-325px; opacity:0; }
18% { top:-325px; opacity:0; }
20% { top:0px; opacity:1; }
22% { top:0px; opacity:1; }
28% { top:0px; opacity:1; z-index:0; }
30% { top:325px; opacity:0; z-index:0; }
31% { top:-325px; opacity:0; z-index:-1; }
100%{ top:-325px; opacity:0; z-index:-1; }
}
@-moz-keyframes cyclefour {
0% { top:-325px; opacity:0; }
28% { top:-325px; opacity:0; }
30% { top:0px; opacity:1; }
32% { top:0px; opacity:1; }
38% { top:0px; opacity:1; z-index:0; }
40% { top:325px; opacity:0; z-index:0; }
41% { top:-325px; opacity:0; z-index:-1; }
100%{ top:-325px; opacity:0; z-index:-1; }
}
@-moz-keyframes cyclefive {
0% { top:-325px; opacity:0; }
38% { top:-325px; opacity:0; }
40% { top:0px; opacity:1; }
42% { top:0px; opacity:1; }
48% { top:0px; opacity:1; z-index:0; }
50% { top:325px; opacity:0; z-index:0; }
51% { top:-325px; opacity:0; z-index:-1; }
100%{ top:-325px; opacity:0; z-index:-1; }
}
@-moz-keyframes cyclesix {
0% { top:-325px; opacity:0; }
48% { top:-325px; opacity:0; }
50% { top:0px; opacity:1; }
52% { top:0px; opacity:1; }
58% { top:0px; opacity:1; z-index:0; }
60% { top:325px; opacity:0; z-index:0; }
61% { top:-325px; opacity:0; z-index:-1; }
100%{ top:-325px; opacity:0; z-index:-1; }
}
@-moz-keyframes cycleseven {
0% { top:-325px; opacity:0; }
58% { top:-325px; opacity:0; }
60% { top:0px; opacity:1; }
62% { top:0px; opacity:1; }
68% { top:0px; opacity:1; z-index:0; }
70% { top:325px; opacity:0; z-index:0; }
71% { top:-325px; opacity:0; z-index:-1; }
100%{ top:-325px; opacity:0; z-index:-1; }
}
@-moz-keyframes cycleeight {
0% { top:-325px; opacity:0; }
68% { top:-325px; opacity:0; }
70% { top:0px; opacity:1; }
72% { top:0px; opacity:1; }
78% { top:0px; opacity:1; z-index:0; }
80% { top:325px; opacity:0; z-index:0; }
81% { top:-325px; opacity:0; z-index:-1; }
100%{ top:-325px; opacity:0; z-index:-1; }
}
@-moz-keyframes cyclenine {
0% { top:-325px; opacity:0; }
78% { top:-325px; opacity:0; }
80% { top:0px; opacity:1; }
82% { top:0px; opacity:1; }
88% { top:0px; opacity:1; z-index:0; }
90% { top:325px; opacity:0; z-index:0; }
91% { top:-325px; opacity:0; z-index:-1; }
100%{ top:-325px; opacity:0; z-index:-1; }
}
@-moz-keyframes cycleten {
0% { top:-325px; opacity:0; }
88% { top:-325px; opacity:0; }
90% { top:0px; opacity:1; }
92% { top:0px; opacity:1; }
98% { top:0px; opacity:1; z-index:0; }
100%{ top:325px; opacity:0; z-index:0; }
}
The only real difference is with slide 1 which, as outlined in the tutorial, needs extra keyframes (I put those in grey higher up this post) to make it ready for the second cycle without creating an obvious jump. The changes with these are based on there now being 2 keyframes per second instead of 4, so that why this;
Code:
96% { top:-325px; opacity:0; z-index:0; }
98% { top:-325px; opacity:0; }
100%{ top:0px; opacity:1; }
now only needs to jump up in 2% increments on the last 2 lines, instead of the original CSS which jumped up in 4% increments;
Code:
92% { top:-325px; opacity:0; z-index:0; }
96% { top:-325px; opacity:0; }
100%{ top:0px; opacity:1; }
That's it for tackling the animation sequences. Now all that's left to do is duplicate ALL the CSS with vendor prefixes for Opera, and no vendor prefix for IE - something like this;
Code:
@-o-keyframes cycle {
/* styles for Opera */
}
@keyframes cycle {
/* styles for IE */
}
But follow the patterns, and make all necessary changes, in both the "styles.css" file and "animation.css" file.
And the final result is this: http://fofwebdesign.co.uk/template/_...how/index.html
Bookmarks