O'Reilly logo

Web Design Blueprints by Benjamin LaGrone

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

What can be done in the shared levels service

Next, I want to move some more functions from level1.js to the general pattern file levels.js. We will cut out the moveRocket and moveEarth functions and paste them into levels.js. And of course, rename them to levels.moveRocket and levels.moveEarth. And be sure to rename the function calls as well. Next, move the setElementLeftPostion function to levels.js. Rename it levels.setElementLeftPosition and the function calls also. This function is called a number of times, so you may want to use a find and replace pattern, or at least find to identify them all. Next, move the window.smoothScrollTo function into the levels.js file and leave it as is.

Updating elements on the scroll

Let's look at the updateElement ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required