camdendotlol / topstersorg

Book and music charts
https://topsters.org
GNU Affero General Public License v3.0
18 stars 9 forks source link

Chart rendering and localstorage logic cleanup #40

Closed camdendotlol closed 2 months ago

camdendotlol commented 3 months ago

Summary

This PR fixes some inefficiencies in the code related to rendering charts and writing to localStorage.

Chart rendering

Interaction Layer

Additionally, this PR splits the ChartCanvas component into two as suggested by #13:

  1. ChartCanvas contains the canonical rendered chart (plus empty item placeholders) and only re-renders when the chart state changes.
  2. InteractionCanvas handles the drag-and-drop interactivity. This canvas is set to the same size as the ChartCanvas and sits on top of it, but the only thing it ever renders is when the user is dragging an item around on the chart.

This system nearly eliminates the jankiness that could occur when moving around items on a large chart on a slower device, as we're not re-rendering everything on the chart for every frame of movement.

Notes

It's possible that the localStorage refactor will unblock #36.

netlify[bot] commented 3 months ago

Deploy Preview for topsters3 ready!

Name Link
Latest commit 0b877d5cf91e97d2ee7a765f91a1f222e44b0d59
Latest deploy log https://app.netlify.com/sites/topsters3/deploys/6649097b99c6d5000820688c
Deploy Preview https://deploy-preview-40--topsters3.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.