This document outlines the development process and technical structure of a custom Timeline Slider built using Vanilla JavaScript, CSS, and Anime.js. The slider features horizontal scrolling, dot-based navigation, and a dynamic timeline line that syncs with slide changes.
-
Display a horizontal sequence of slides representing years or events.
-
Animate transitions between slides.
-
Highlight corresponding timeline dots and update a progress line.
-
Enable navigation via buttons and dragging.
-
Support theme switching (e.g., yellow/white).
-
Contemplate a future enhancement: making the entire timeline appear as one continuous animation for more immersive storytelling.
-
Enhance user interaction by animating slide transitions even during drag-based navigation.
HTML
-
A semantic layout with a
tl-slider__sectionfor the title and toggle. -
A
.tl-slider__wrappercontaining:-
.tl-slider__container(holds.tl-slider__sliderand nav buttons). -
.tl-slider__timeline(holds dots and timeline lines).
-
CSS
-
Custom properties (
:root) for theming. -
BEM-style class naming.
-
Responsive design for mobile support mobile and desktop, breaking point at 768px.
-
Animated transitions using
transform,transition, andanime.js.
JavaScript
-
main.js: Initializes the slider and event listeners. -
navigation.js: Handles slide navigation logic and button clicks. -
drag.js: Adds dragging support to the slider. -
theme.js: Toggles between visual themes. -
dots.js: Manages timeline dot creation and updates. -
animation.js: Controls line and slide animations.
1. Slide Navigation
-
slide-nextandslide-prevbuttons navigate through slides. -
currentIndexkeeps track of the active slide.
2. Timeline Dots
-
Dots represent each slide's associated year.
-
Clicking a dot navigates to its corresponding slide.
-
Active dot is highlighted.
3. Progress Line Animation
-
A base line and progress line sit behind the dots.
-
The progress line expands with each slide change.
4. Drag to Scroll
-
The user can drag the slider to scroll slides.
-
Scroll position updates the
currentIndexand highlighted dot. -
Future enhancement includes smooth animation during drag events for visual consistency.
5. Theme Switching
-
A theme toggle switches between yellow and white styles.
-
The theme affects background, text, and image assets.
-
Anime.js is used for animating the progress line and slide transitions.
-
Custom Cursor: A styled cursor follows the pointer on slider hover.
-
Event Binding: Modular event listeners are registered in each JS module.
-
Accessibility:
aria-labels are added for navigation buttons.
-
Add touch gesture support for mobile devices.
-
Improve accessibility (e.g., keyboard navigation).
-
Load slide content dynamically via JSON or API.
-
Add optional autoplay feature.
-
Implement a unified timeline entrance animation to reveal the entire timeline as a fluid sequence.
-
Introduce drag-based animation to make slide movements smoother and more visually cohesive.
Developed by Luka using Vanilla JavaScript and Anime.js as part of a UI component prototype.
| File | Purpose |
index.html |
Main HTML structure |
styles.css |
Layout, theme, and animations |
main.js |
Entry point, initializes modules |
navigation.js |
Slide navigation logic |
cursor.js |
Cursor styling |
theme.js |
Theme switching logic |
slider.js |
Slides rendering |
animation.js |
Slide animations |
data.js |
Slide data |