interactions-timeline
v1.0.1
Published
A page timeline recorder and interactive visualizer with time-scrubbing for CSS animations, CSS transitions, WAAPI, Scroll-Driven Animations, scroll positions, and user interactions
Maintainers
Readme
<interactions-timeline>
A zero-dependency Web Component (<interactions-timeline>) with Shadow DOM encapsulation that records and visualizes a page's timeline:
- CSS Animations (
animationstart,animationiteration,animationend,animationcancel, including delays, iterations, andinfiniteanimations) - CSS Transitions (
transitionrun,transitionstart,transitioncancel,transitionend, including delays betweentransitionrunandtransitionstart) - Web Animations API (
element.animate()) & Active Animations viadocument.getAnimations() - Scroll-Driven Animations (
ScrollTimelineandViewTimeline) with progress visualization over the recorded time axis - User Interactions & Scroller Positions (
click,scroll,keydown,keyup, andscrollTop/scrollLefton bothwindow/root and scrollable elements) - Disconnected DOM Elements (
!element.isConnected), rendered as greyed-out rows with a warning badge and outline duration boxes/markers - Full Time-Scrubbing: Pauses all page animations and transitions when the bottom-sheet visualizer opens, and lets you scrub the playhead backward and forward through the page's visual history (re-creating completed CSS transitions and one-shot animations from snapshotted keyframes and timing). Closing or resetting the visualizer restores and unpauses the page back to its normal interactive state.
👉 Live Demo & Documentation: https://interactions-timeline.netlify.app
Features
- Shadow DOM Encapsulation & Subtree Exclusion: The top-right recorder button and collapsible/resizable bottom sheet live inside
<interactions-timeline>'s Shadow DOM. All clicks, scrolls, and UI animations inside the recorder itself are explicitly ignored during recording and pausing. - Pinned Global Row & Element Rows: Features a pinned
window / documentrow for root scroll and global keyboard events alongside rows for each tracked element (tag#id.class). Hovering an element row highlights the element on the page if still connected. - Color-Coded Lifecycle Markers: Duration boxes match the recorded duration on the timeline and display color-coded lines for
run(cyan),start(green),iteration(amber),end(blue), andcancel(red), plus an inline SVG progress sparkline and aTime/ScrollTimeline/ViewTimelinebadge. - Removed Element Detection: Uses a
MutationObserverto track if/when a recorded element is removed from the DOM (!element.isConnected), greying out its row, displaying a⚠️ Removedwarning indicator, and rendering its recorded boxes and events as outlines. - Interactive Playhead Scrubber: Drag the playhead or slider to seek both scroller offsets (
scrollTop,scrollLeft) and animation/transition frames (currentTimeor percentage progress for scroll-driven animations) without triggering new recording events.
Quick Start
1. Installation
npm install interactions-timeline2. Usage
<script type="module" src="interactions-timeline"></script>
<!-- Optional: explicitly place in DOM (auto-mounted if omitted) -->
<interactions-timeline></interactions-timeline>JavaScript API
| Method / Property | Description |
|---|---|
| startRecording() | Starts recording page animations, transitions, scrolls, interactions, and DOM removals. |
| stopRecording() | Stops recording, pauses all page animations/transitions, and opens the bottom-sheet timeline visualizer. Returns the TimelineStore. |
| scrubToTime(ms) | Seeks all recorded scrollers and animations/transitions (including re-created completed transitions/animations) to ms relative to recording start. |
| toggleCollapse() | Collapses or expands the bottom-sheet visualizer. |
| setSheetHeight(px) | Resizes the bottom-sheet height in pixels. |
| closeVisualizer() | Closes the bottom sheet and restores/unpauses all page animations back to normal. |
| reset() | Clears recorded data, closes the bottom sheet, and restores the page to its normal interactive state. |
Development & Testing
# Start local demo server
npm start
# Run unit and end-to-end Puppeteer tests
npm test
# Build ./dist for publishing
npm run buildLicense
MIT © Bramus Van Damme
