alex / nyt-2020-election-scraper

https://alex.github.io/nyt-2020-election-scraper/battleground-state-changes.html
MIT License
1.76k stars 289 forks source link

Use CSS for table shrink/expand #371

Closed saleemrashid closed 3 years ago

saleemrashid commented 3 years ago
Motivation

Currently, the shrink/expand table button is implemented in JavaScript, but it's slow because it has to iterate over each row.

Changes

Add an always-visible class to specific rows when generating the HTML, then use JavaScript to add/remove a CSS class shrunk when the Shrink Tables/Expand Tables button is clicked. This should be much faster.

/cc @JulesDT