Experiments >

Code animation: Better snapping

Experiment #18110th May, 2021by Joshua Nussbaum

In a previous experiment, I added the ability to move events based on a grid, aka “snapping”.

But there were some bugs, so I revisted it again.

It turned the bugs were caused by calculating the snap value too early.

// calculating snap early
const delta = snap(last - event.pageX)
step.width = initial.width + delta

// calculating snap later
const delta = last - event.pageX
step.width = snap(initial.width + delta)

That fixed most of it.





  • What about multiple selections? maybe overkill for now.
view all experiments

Stay tuned in

Learn how to add more experimentation to your workflow