cubing / cubing.js

🛠 A library for displaying and working with twisty puzzles. Also currently home to the code for Twizzle.
https://js.cubing.net/cubing/
GNU General Public License v3.0
241 stars 44 forks source link

Support mouse-moves in algorithm/animated cube correctly #6

Open rokicki opened 4 years ago

rokicki commented 4 years ago

Right now if you click a move in twizzle, the move gets appended to the algorithm and the move is executed, but there is no coalescing of moves (say, U then U into U2). If you enable automatic coalescing, then clicking the second U causes the cube to "jump" back to the state before the first U and execute a U2; this is jarring and incorrect. This should be improved to behave similarly to the original twizzle (currently at twizzle.cubing.net).

rokicki commented 4 years ago

I believe the solution here is in widget.ts. We add a boolean saying we are "animating an appended move" and a "from state" and a "move-being-animated" (the "to state" we can get from the normal place.) Whenever we are "animating an append moved" the scrubber is always at the extreme right. On any action (another move coming in, scrubber hit, play/stop/etc. hit) we kill this new state and do a quick jump to the end of the new algorithm. Otherwise, things are pretty much as with the old twizzle, except we actually animate rather than jumping.

rokicki commented 4 years ago

This is resolved on the branch betterclickanim (modulo some glitches that may need to be ironed out). Leaving it on the branch for review.