September 26, 2019
•Last updated November 5, 2023
Let's Build with JavaScript - Using Mouse Events To Animate Text
In this installment of my Let's Build with JavaScript series I talk about using mouse events to animate text.
This tutorial is heavily inspired by a video from Wes Bos' course JavaScript 30 which I highly recommend for a crash course in JavaScript.
We'll be building a text-shadow animation that takes place on mouse hover. As you move your cursor over a containing div the text can animate in real-time thanks to JavaScript events. We'll target the mousemove
event specifically to hook into coordinates defined in the browser relative to where your cursor lands on the screen. Combine some math and some ES6 and we've got a pretty cool little animation effect.
Relative links:
The Series So Far
- Letβs Build: With JavaScript β DIY Dropdowns and Responsive Menus
- Let's Build: With JavaScript - Broadcast Bar with Cookies
- Let's Build: With JavaScript - Sticky Nav
- Let's Build: With JavaScript - Dynamic Tabs
- Let's Build: With JavaScript - Modals
- Let's Build: With JavaScript - HTML5 Video Player
- Let's Build: With JavaScript - Accordions
- Let's Build: With JavaScript - Skeleton Screen Effect
- How to Code an Off-Canvas Menu - Let's Build: With JavaScript
- Show More β Show Less Toggle with JavaScript
- How to use Local Storage with JavaScript
- Let's Build: With JavaScript - Dynamic Checkboxes
Categories
Collection
Part of the Let's Build: With JavaScript collection
Products and courses
-
Hello Hotwire
A course on Hotwire + Ruby on Rails.
-
Hello Rails
A course for newcomers to Ruby on Rails.
-
Rails UI
UI templates and components for Rails.