Add a Wraparound Effect for a Marquee with jQuery and Dreamweaver
Illustration by John Hersey

Add a Wraparound Effect for a Marquee with jQuery and Dreamweaver

with Chris Converse

Video: Positioning all photos in the lineup

Now that we are finished cloning and rearranging our photos, let's add a few more lines after those last two statements. And now let's set up the positioning of all of the photos inside of the marquee-photos div. So let's start by typing dollar sign, parentheses, tick marks inside for a string literal .marquee_photos, space, img. So now we want to search for all of the images that are now inside of that marquee-photos div. Outside of the parentheses, type .each, parentheses, semicolon.

Start your free trial now, and begin learning software, business and creative skills—anytime, anywhere—with video instruction from recognized industry experts.

Start Your Free Trial Now
please wait ...
Watch the Online Video Course Add a Wraparound Effect for a Marquee with jQuery and Dreamweaver
41m 46s Intermediate May 18, 2012

Viewers: in countries Watching now:

Join Chris Converse as he teaches how to add a wraparound effect to your homepage marquee with Dreamweaver and a concise bit of jQuery code. The course covers positioning the photos, adjusting the navigation, activating the marquee, and making sure the marquee auto-plays. In a few short movies, designers can learn how to add this dynamic feature to their web sites.

For more information on creating the marquee, please watch Create an Interactive Homepage Marquee with jQuery and Dreamweaver.

Subject:
Web
Software:
Dreamweaver jQuery
Author:
Chris Converse

Positioning all photos in the lineup

Now that we are finished cloning and rearranging our photos, let's add a few more lines after those last two statements. And now let's set up the positioning of all of the photos inside of the marquee-photos div. So let's start by typing dollar sign, parentheses, tick marks inside for a string literal .marquee_photos, space, img. So now we want to search for all of the images that are now inside of that marquee-photos div. Outside of the parentheses, type .each, parentheses, semicolon.

Inside the parentheses for each, we are going to type function, parentheses, and then beginning and ending bracket. Let's split that open on the brackets. Let's back up and inside of the parentheses for function we are going to type index. This way we will have a count for each image that's found inside of marquee-photos. The first thing we are going to do inside of here is declare a variable, var, space, photoPosition. We are going to set that equal to index multiplied times window.photoWidth, then a semicolon.

Next line, dollar sign, parentheses. Inside of the parentheses, we will type this.css, beginning and ending parentheses semicolon. Inside of the parentheses for CSS, two tick marks for a string literal, type left. Outside of string literal but still inside of the parentheses, type a comma, and then two more tick marks, and then the letters px for pixels.

Now let's come outside of the string literal but still on the right side of the comma. And let's type photoPosition. So we are going to add that variable in there and then hit a plus sign. So what we are doing here is taking the value of photoPosition and adding px to it so this becomes a CSS property value. Next line, dollar sign, beginning and ending parentheses, tick marks inside for a string literal, .marqeee_photos. Outside of the parentheses, .css, beginning and ending parentheses, semicolon.

Inside of the parentheses for CSS, two tick marks for a string literal, width. Outside of the string literal but still inside of the parentheses for CSS, comma, two tick marks again for string literal, then the letters px. Now before the string literal we are going to have to come in here and calculate how wide this outermost container needs to be hold all the photographs that are inside. So let's come up to photoPosition. Let's copy that variable name. Let's paste that before the string literal.

So we are going to take photoPosition+ window.photoWidth and then a plus sign and add the px. So after these statements, all six photographs are going to be positioned inside of the marquee-photos div, and the marquee -photos div width the setting is going to be set to be wide enough to encompass six photos instead of four we had in the previous version of this course. Now the last adjustment we need to make is when somebody goes to this marquee, when the marquee loads, we want them to see the second photo, because that's actually the first photo in the four sets of photos that are part of our marquee.

But the way this script is written now, it'll take the first photo and place that in place, which is actually our last photo, because we actually manipulated the position of that up here on line 47. So to make that adjustment, let's hit a few line returns after the statements we just made. Let's start with the dollar sign, beginning and ending parentheses, tick marks for a string literal .marquee_ photos. Outside of the parentheses .css, beginning and ending parentheses, semicolon.

Inside of CSS, we are going to type two tick marks for a string literal, left, outside of the first string literal hit a comma, two tick marks for another string literal, let's put a minus sign, then type two plus signs, then two tick marks for another string literal, then the letter px. Now inside of the two plus signs we are going add window.photoWidth. So now what this statement is doing is after we've rearranged all of the photographs we are going to go through and take the marquee-photos, set the CSS property with a left value of a negative photo width +px.

So this is going to take the marquee- photos when the marquee loads and move it -700 pixels to the left. So when the initial screen loads we are going to see the second photo, which is going to be the picture that we have for London. Now we are at the point where we can test this, so let's save our file. Let's go back to our operating system, and let's take the index.html file and open this up in a browser. Now when this loads in a browser we will notice that our timePassed variables are not counting up because we have disabled the auto play by commenting out that set interval. And we will notice that we see the London photograph with the London caption in place.

So if you can imagine thinking back to the introduction video, we are actually looking at the second photo up here in the photo lineup. The very first photo is the picture of Milan, which is actually the last of the four sequence photos. And there is a sixth photo on the very end, which is a copy of this particular London photo. And these photos on the individual ends are going to give us that wraparound effect. So now at this point our initial screen loads properly, but what you might notice if you start clicking around on the individual pictures, the photos aren't actually going to be compensating for the fact that there are six in here and we only have four navigation items.

So as I go through here and click the navigation items, the pictures aren't going to match up properly with the navigation items. In the next movie, we will start creating our compensation scripts inside our navigation so that we actually go between the proper four photos.

Find answers to the most frequently asked questions about Add a Wraparound Effect for a Marquee with jQuery and Dreamweaver .


Expand all | Collapse all
please wait ...
Q: This course was updated in April, 2013. What changed?
A: Since the release of this course, Chrome conflicts with jQuery 1.6, and browsers run the autoplay when the windows is not in focus. To remedy these issues, the author has added a movie to Chapter 5 that will show you how to:
- Update the version of jQuery
- Detect the focus state of a web window
- Create a compound conditional JavaScript statement
 
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ .

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now Already a member? Log in

* Estimated file size

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Add a Wraparound Effect for a Marquee with jQuery and Dreamweaver.

Return to your organization's learning portal to continue training, or close this page.


OK

Course retiring soon

Add a Wraparound Effect for a Marquee with jQuery and Dreamweaver will be retired from the lynda.com library on March 18, 2015. Training videos and exercise files will no longer be available, but the course will still appear in your course history and certificates of completion.


Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member ?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferences from the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

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.

Learn more, save more. Upgrade today!

Get our Annual Premium Membership at our best savings yet.

Upgrade to our Annual Premium Membership today and get even more value from your lynda.com subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.