-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prefer adjusting cursors over recreating them #2
Conversation
Won't the animation effect go wrong when cursors are added/removed, as the offsets of "corresponding" cursors won't match across the transaction? Say you have a cursor and then add a second one above it. The old cursor will move to the new position, though conceptually it stays in place. |
This is exactly what happens - and actually it kind of looks interesting. I don't mind it - but it probably shouldn't be an effect. I'll make a commit to prevent that behavior. |
There - now whenever a cursor is added or removed, the plugin will instead redraw all cursors. That way, there doesn't need to be any memory of what cursors are new or whatever. Cursors will only 'adjust' when they move. |
That sounds like a reasonable solution. But now it looks like the Also, the library targets IE11 which doesn't have |
Oops, fixed. |
FIX: The `drawSelection` extension will now reuse cursor DOM nodes when the number of cursors stays the same, allowing some degree of cursor transition animation. Issue #2
Thanks for the adjustments. Merged as 66c7a28 |
This makes it so that the
drawSelection
plugin will 'adjust' old cursors in thecursorLayer
rather than simply recreating them.Why? Well, to be honest, it's purely for gratuitous visual flair.
(it's hard to see in a gif, but the movement is buttery smooth.)
There is a potential argument about this being more efficient, as most of the time only a single cursor will need to be updated, and when it is updated only its style properties are changed. I doubt that this gives a practical improvement in performance regardless.
I have "tested" this, but I'm pretty unfamiliar with the innards of CodeMirror and the maintainer(s) probably needs to check if this change affects something that I wouldn't know about.