- Alright, so let's finish up this application.…The only thing we have to worry about…is what happens when the mouse moves.…We've already set this up by marking down…the mouse position when the user clicks the mouse.…So, if you go over here to addEventListener mousedown,…here, we keep track of this original Y position.…This is one of our globals that we set up up here,…and we also keep track of the original frequency.…Again, both of these happen when…we click on the mouse button.…So, when somebody moves the mouse,…we need to modify these, but before we do that,…we have to set up a couple of little variables here.…
So, this is gonna be an internal variable called distanceY,…and it's gonna be equal to the event clientY,…so that's the position based on this event…that gets passed along when somebody moves the mouse.…And we're gonna take that and subtract it…from the original Y position, so it's gonna give us…the distance and movement.…Now, we're also gonna update the X position…of the mouse, so this will be mouseXpos,…
Visit other courses in the series to see how to solve the exact same challenges in languages like C++, C#, Java, PHP, Python, R, Ruby, and Swift.
Skill Level Intermediate
1. Problem One - Exploring Lake Pend Oreille
2. Problem Two: Image Analysis
3. Problem Three: Eight Queens
4. Problem Four: Accessing Peripherals
5. Problem 5 - Recursion and Directories
6. Problem 6 - Building the Web
- Mark as unwatched
- Mark all as unwatched
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.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.