JSFiddle - React, Tailwind, and code Playground

by ericwilligers

HTML

<table id="results">
  <tr id="timeline"></tr>
</table>
<svg id="parent">
  <g id="child"/>
</svg>

CSS

#results {
  color: black;
  background-color: white;
}

#parent {
  fill-opacity: -2;
  stroke-opacity: -2;
  flood-opacity: -2;
  stop-opacity: -2;
  opacity: -2;
  shape-image-threshold: -2;
  color: rgba(7, 8, 9, -2);
  stroke-dashoffset: -2;
}

#child {
  animation-duration: 1s;
  animation-timing-function: linear;
  animation-fill-mode: both;
  animation-play-state: paused;
  animation-name: anim;
}

@keyframes anim {
  0% {
    fill-opacity: inherit;
    stroke-opacity: inherit;
    flood-opacity: inherit;
    stop-opacity: inherit;
    opacity: inherit;
    shape-image-threshold: inherit;
    color: inherit;
    stroke-dashoffset: inherit;
  }
  100% {
    fill-opacity: 2;
    stroke-opacity: 2;
    flood-opacity: 2;
    stop-opacity: 2;
    opacity: 2;
    shape-image-threshold: 2;
    color: rgba(7, 8, 9, 2);
    stroke-dashoffset: 2;
  }
}

JavaScript

'use strict';
const properties = [
  'fill-opacity',
  'stroke-opacity',
  'flood-opacity',
  'stop-opacity',
  'opacity',
  'shape-image-threshold',
  'color',
  'stroke-dashoffset'
];
const results = document.getElementById('results');
const timeline = document.getElementById('timeline');
const resultRows = [];


function appendCell(row, content) {
  const cell = document.createElement('td');
  cell.textContent = ' | ' + content;
  row.appendChild(cell);
}

{
  appendCell(timeline, 'progress');

  for (const property of properties) {
    const row = document.createElement('tr');
    appendCell(row, property);
    resultRows.push(row);
    results.appendChild(row);
  }
}

const child = document.getElementById('child');
for (let i = 0; i <= 8; ++i) {
  const progress = i / 8;
  const animationDelay = (-progress) + 's';
  appendCell(timeline, progress);
  child.style['animation-delay'] = animationDelay;
  for (let j = 0; j < properties.length; ++j) {
    const property = properties[j];
    const value = getComputedStyle(child)[property];
    appendCell(resultRows[j], value);
  }
}

appendCell(timeline, '');
for (let j = 0; j < properties.length; ++j) {
  appendCell(resultRows[j], '');
}