⏰ 30 mins
- In this exercise, we’ll practice template refs but also a lot of other concepts you’ve learned throughout the first 2 days
- Your goal for this exercise is to create an auto rotating image carousel
- In
exercise-13-begin.vue there is some boilerplate that displays 10 user images, 1 at a time
- All the styles are already in place, it is your job to make the slider actually work.
- It should rotate between images every 3 seconds
- It should have a nice transition when moving between different images
<aside>
💡 HINT: You can use a dynamic inline style on the image slides that like so:
transform: translateX(-[whatever slide is active * the clientWidth of an individual slide]px) - A transition rule is already applied so that the browser will move smoothly between the different positions
</aside>
- It should be responsive and work at multiple screen sizes
- It should be responsible and clean up any event listeners and/or intervals it creates on unMounted
exercise-13.mp4
💪 Bonus
If you finish early, try making the carousel stop moving when you hover over it with your mouse and then resume once the mouse leaves again.
Helpful Resources
- Vue.js Docs - Template Refs
- Vue.js Docs - Lifecycle Hooks
- MDN Docs - clientWidth
- MDN Docs - setInterval