Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Now that we have all the variables set up based on the anchor link we clicked on, inside of our set up navigation links after the variable we have declared, let's hit a few line Returns and let's change the photo position. So, we'll start with a Dollar sign, beginning and ending parentheses, two tick marks, string literal, type 'marquee_photos'. We are going to target the marquee_photos div. Outside of the parentheses, type .animates.
This is jQuery's built-in function to animate the properties. Inside of animate, beginning and ending bracket, we are going to type 'left:', space. Then we are going to go get the variable newPhotoPosition, choose Command or Ctrl+C to copy that, Command or Ctrl+V to paste. So, basically, animate again, is jQeury's built-in function to animate CSS properties of HTML elements on the page.
We are going to set animate on this as well, beginning and ending parentheses, semicolon. Inside of the animate, let's get two brackets. Let's type 'top:'. This sets the top value of the CSS property, two tick marks for a string literal, 340px. This is the lowest point we want the caption to be. This shows us the top 10 pixels across the top.
Let's put a comma in here, space, 500. We want this to be half a second, so in the time it takes the photo to move one second across, we want to have the caption take half the amount of time to move down, change, and then move back up. So, over the course of one second, the photos will just do one movement; the captions will do. They will go down and up. So after 500, let's add a comma, type in 'function', beginning and ending parentheses, beginning and ending bracket.
This is going to be a callback, which is basically going to happen after the animation has triggered down to 340 pixels on the top over the course of 500 ticks. Let's split this. Let's come inside the marquee_caption. Let's create a new variable, newHTML equals, Dollar sign, beginning and ending parentheses. We are going to come up here and grab the newCaption because we said over here that this is the navClicked is going to get the marquee panel data bases on the actual index of the anchor tag that was clicked.
Type in newCaption, outside of newCaption.html, beginning and ending parentheses, semicolon. This is jQuery's built-in way to grab all of the HTML inside of this object. Next line, Dollar sign, beginning and ending parentheses, two tick marks, marquee_caption_content.html, beginning and ending parentheses, semicolon.
Inside of the marquee_caption_content, we are going to take all of the newHTML code that we got from the newCaption variable, paste it in there. And then lastly, we are going to run a custom function, setCaption, beginning and ending parentheses, and a semicolon. Now to setCaption function is something we haven't written yet. We are going to start that in the next movie. But basically, what we are going to do is once we set the newCaption information here, we are going to animate this down. We are going to have to perform some calculations to see how tall the newCaption is so that we know how to animate it back up, so that the entire caption fits on the screen, and again we will start that in the next movie.
Get unlimited access to all courses for just $25/month.Become a member
58 Video lessons · 60226 Viewers
61 Video lessons · 92812 Viewers
82 Video lessons · 104221 Viewers
56 Video lessons · 107268 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.