Start learning with our library of video tutorials taught by experts. Get started
Viewed by members. in countries. members currently watching.
Covering diverse topics such as improving workflow and managing CSS styles, Dreamweaver CS3 Beyond the Basics is a hands-on course that teaches users how to move beyond standard, static websites. Instructor James Williamson explores how to increase productivity, interactivity, and accessibility with Dreamweaver. He also discusses how to extend the application's capabilities with XML and XSL. Exercise files accompany the tutorials.
We are already passing in a couple of variable so we are just going to add another variable. So I'll put my cursor right after the defaultpanel variable and I'll type in another comma since we are going to add another one. And we are going to pass another one of those hidden variables, one that doesn't come up as a code hint. We are going to type in duration. Now duration deals with the animation itself and the value and duration is actually passing along in milliseconds. The default is 500, and that's going to be half a second. So those panels are opening and closing in half of a second. So we are going to pass along a value of 1000. We do that by typing in a colon, and then typing in the value of 1000.
Now what that's going to do for us is its slow our animation down and the opening and closing of these panels is now going to take a full one second rather than half a second. So let's save this file and we'll test that functionality in our browser. So go ahead and preview that in a browser. It should open up. I'll scroll down so I can see my entire Accordion and then when I click it, now it's taken a lot longer to animate between them than it did before. Now, you might say to yourself, wow, that's really too slow but that's really not the point of what we're looking at here. What we are looking at is the fact that in addition to being slow, the animation is starting to get a little bit chunky. Now the reason the animation is getting a little bit chunky is because there's more than just duration that goes into calculating the animation.
Hopefully, it goes without saying that if you are going to attempt to modify this file, you might want to go ahead and make a backup prior to modifying it. Anytime you are going to modify a core functionality file, you are going to want to have that back up some place else. So if you want to examine the SpryAccordion file or any of the Spry widget files for that matter, just go ahead and start scrolling down there. They are very well commented as you can see. You are going to find a lot of functions, a lot of variable declarations. And just noticing around a little bit, you can find exactly what you are looking for. Now, we are looking to control our animation. So I will save you some scrolling and I am going to use my Go to Line again. So I am going to click on my Go to Line icon, and again, if you don't have that, we'll just scroll down to where we are going. So we are going to type in Line 402 and we'll click OK.
Now, when we go down to Line 402, we can actually see that this is the Spry.Widget.Accordion.panelAnimator function. So this is the function that controls our panel animation. So let's scroll down a little bit. Notice that it is looking for three variable values. The accordion, and that would be the actual widget that's being controlled. The panel, so which panel is animating, and then any options that are going to be passed into this. Now that's a really important part because that's option's plural. Now, we have only passed duration in and right now that is the only variable that's turned on. But there are two other variables that we can switch on and looking down at the function, it's pretty easy to determine which variables we could also pass in. Look at the second block of code. We have this.fps (frames per second), this.steps, this.duration, and this.onComplete.
So frames per second, steps and duration is where we really want to focus. We have an interval and the interval is being determined, and if I scroll down, we can see this. The interval being determined by first checking to see if frames per second are being used. If frames per second are being used, it converts them into steps. But if frames per second isn't being used, then the interval is actually created by taking the duration time and dividing that by the number of steps. So how many steps am I going to animate and over how long. So we changed the duration, and made the duration longer but we didn't really change the steps.
I am going to scroll back up here. So our initial steps are 10 and our duration is 500. So by increasing our duration to 1000, without also increasing the number of steps. That's why it's getting so chunky. So the same amount of steps over a longer period of time. So we need to increase the steps as well. But if scroll back up, I notice that when the function is being called, it's expecting to pass in the name of the Accordion, the panel that's being animated and then these options. So what we need to define now is where these options are being defined so that we can also pass along the steps. So what we need to do is go up in our code and establish where this function is being called, and see if the variables that are being passed into this function call are being defined.
Once again, I am going to use my Go to Line icon and if you have got that handy, just go ahead and click that; if you don't, you might want to just scroll back on up and we are going to move up to Line 163. So on 163, and we can actually see that there's a call on that line that says Spry.Widget.Accordion.panelAnimator. So, this is where the function is being called. Just to move up briefly to see which function this is, it's a function for opening the panel. So when the panel is opened as part of opening the panel, it calls the animation function, so that it will animate it as well.
Now the part that we are really interested in is right here on Line 163 directly after the function call. It says this. so it's referring to itself because it's called within a function and then it says panelB. Now panelB is identifying which panel somebody is clicking on. So don't assume that that's the second panel. Now, the next value is what we're really looking at, there's a curly brace and it says duration, and the value it is passing is this.duration. Now, because in the constructor function, we passed in a duration value, we're able to change that. If not, it sticks with the default value.
So let's go ahead and save that. We'll go back to our current.htm and on Line 116, let's go ahead and pass this steps value. Since we made the duration twice what it normally is, we'll go ahead and do the same thing for the steps. So on Line 116, right after we call the duration, let's type in a comma and we're going to type in steps, so again because of variable we don't have code hinting for it, because we just turned it on. And then colon, and we are going to pass in a value of 20. So the default value is 10, we will double that and make it 20. So let's save this file and let's test that in our browser again. I'll scroll down and now when we click on our animation, even though it's taking a second, it's a lot smoother than it was before, because it's moving shorter distance over that time in each step. So we get a much nicer, smoother animation, even though it's a lot longer than it was before.
Find answers to the most frequently asked questions about Dreamweaver CS3 Beyond the Basics.
Here are the FAQs that matched your search "":
Sorry, there are no matches for your search ""—to search again, type in another word or phrase and click search.
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.