I've added two new animations, with a total of three working in unison. The code seems redundant…I'm thinking there must be a solution for simplifying / chaining it together.
I've re-written the code slightly…using setTimeout for animation 2 and 3. The syntax of animation 1, while valid, still seems redundant though. Is there a better practice for simplifying the syntax…or is it fine the way it is?
You can put the 'one' animate function inside the setTimeout callback with the other animate function and remove the delay function: http://jsfiddle.net/MvQsT/97/
Hello,
I'm rather new to writing jQuery and was curious if those with experience can suggest a cleaner method for writing the following code. Thank You.
Essentially this will fade in a div…delay for 2 seconds…slide down from the top while fading out.
Update
I've added two new animations, with a total of three working in unison. The code seems redundant…I'm thinking there must be a solution for simplifying / chaining it together.
Example: http://jsfiddle.net/MvQsT/89/
Any help is appreciated…thanks again
Update #2
I've re-written the code slightly…using setTimeout for animation 2 and 3. The syntax of animation 1, while valid, still seems redundant though. Is there a better practice for simplifying the syntax…or is it fine the way it is?
Example 2: http://jsfiddle.net/MvQsT/92/
You can put the 'one' animate function inside the setTimeout callback with the other animate function and remove the delay function: http://jsfiddle.net/MvQsT/97/
Or perhaps put the setTimeout inside the callback for when the fadeIn ends: http://jsfiddle.net/MvQsT/98/
Maybe make the duration for the animation (and the timeout) vars: http://jsfiddle.net/MvQsT/99/
@CrocoDillon
Hey…thanks for the suggestions. I think your first example is the most appropriate for what I'm after.