From the course: CSS: Scrolling and Parallax
Unlock this course with a free trial
Join today to access over 22,600 courses taught by industry experts.
Request animation frame - CSS Tutorial
From the course: CSS: Scrolling and Parallax
Request animation frame
- [Instructor] There's a special method that you can use in JavaScript to make sure your animations sync properly to the browser. Now this is called requestAnimationFrame(). This method can call another function which is called a Callback, that will perform your animation. Now this Callback will be passed a timestamp of when the animation happened in relation to the beginning of the document's lifetime. But you don't have to use this. It's called "DOMResTimeStamp." Again you don't have to use it, but it is provided for you and it's sometimes useful in some instances. Now there is another really interesting and useful method that we can use in JavaScript. This is the "getBoundingClientRect()" method. And we can use this to determine the position of an object. Now this is going to return a rectangle, which allows you access to all of these dimensions. Now we can bind this with requestAnimationFrame, and we can use it to…
Contents
-
-
-
-
-
Building your new monsters section9m 41s
-
(Locked)
Smooth scrolling on link clicks2m 48s
-
(Locked)
Request animation frame4m 22s
-
(Locked)
Adding classes when scrolling4m 3s
-
(Locked)
Removing the header cue when scrolling3m 50s
-
(Locked)
Parallax scrolling with JavaScript8m 35s
-
(Locked)
Determining when an object first appears7m 36s
-
(Locked)
Animating when objects enter the screen4m 15s
-
(Locked)
Randomizing the appearance5m 26s
-
-
-
-
-