Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Now before we start creating our animations for the captions we need to figure out exactly where we need to animate the captions to. So I'm going to bring up a sketch and on the sketch what we figured out is with our thumbnails being 200 pixels wide by 115 pixels tall, all we want to do is first figure out how tall each caption is, since some captions might only be in one line and some might be three or four lines. So what we want to do is take the amount of padding that we set on the captions, top and bottom which is 35 pixels, 20 and 15 and we're going to take 115 which is the total height of the thumbnail, subtract 35 which is going to give us 80.
Then we're going to add five additional pixels so that the bottom has five pixels of padding, and what we're going to do is take that number which is now 85 and subtract the height of whatever the height of the caption is. Then what we're going to do is use that value to animate to our new top position. So let's come back out into Dreamweaver, we're going to come over to the video_gallery related file, let's click on Code view, inside of jQuery's document ready we're going to come in here, I'm going to add a few lines and we're going to start by typing a dollar sign, beginning and ending parentheses, two tick marks inside for string literal, a.videoLink, outside of the parentheses we're going to type .hover beginning and ending parentheses then a semicolon.
So what this hover function does is it actually invokes any of the instructions inside of this function if our mouse hovers over any anchor tag with a videoLink class. Now what we're going to do inside of hover, let's split this open and we're going to define two functions. First, let's type function(), then a Return, then we're going to type function again, parentheses, brackets, and I'll remove the space.
So inside of the hover function what happens is the first function happens when the mouse rolls into the object, the second function happens when the mouse rolls outside of the area. So those two different functions that happen when we invoke the hover function inside of jQuery. So inside of the first function, inside of those brackets let's split that open, so inside of the first function what we want to do in here is create the two variables that we're going to set the position of that new caption based on the map that we just looked out inside of the sketch. I'm going to start by typing var captionPosition = 85-$(this) which refers back to the actual anchor link with the video class that we rolled over.
So (this).children, we want to search for all of the children inside of the anchor tag that we just rolled over, beginning and ending parentheses, inside of the parentheses two tick marks for the string literal, .caption, outside of the parentheses .height();. So the new height, the new captionPosition is going to be 85 minus whatever the height of the child inside of the anchor link we rolled over and we're going to get the height value of that object.
Let's hit Return, we're going to set a second variable, var iconPosition = captionPosition - 32. So if you remember from the introduction video we had the icon always just overlapping the very top of the caption. So whatever the caption height is going to be we're going to take our 50x50 pixel icon and shift it upwards -32 pixels, which is going to give us an 18 pixel overlap on the very bottom of the Play icon, regardless of how high the caption animates up and down.
At this point, let's go to the File menu, choose Save All and in the next movie we'll create the animations based on these variable values.
Get unlimited access to all courses for just $25/month.Become a member
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.