Skip to content
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

Promotion animation is lagging (chessground and lichess.org) #240

Open
elsiniestra opened this issue Oct 18, 2022 · 9 comments
Open

Promotion animation is lagging (chessground and lichess.org) #240

elsiniestra opened this issue Oct 18, 2022 · 9 comments

Comments

@elsiniestra
Copy link

When you try to promote a pawn to the last rank and create a new piece, the animation does not work correctly. I guess it should be the same as the smooth capture animation, but instead, it transfers to the destination in a moment, and the ghost piece (captured opponent piece or just a pawn that moved) fades with a lag effect. This issue is suitable either for lichess.org or chessground.js. Tested on Chrome and Safari (PC and mobile).

Screen.Recording.2022-10-18.at.3.52.24.AM.mov
@thinktt
Copy link

thinktt commented Dec 28, 2022

I fixed this by turning off animation right before promotion and turning it on again right after.

cg.set({ animation: { enabled: false} })
// do promotion stuff
cg.set({ animation: { enabled: true } }) 

When I did this it pretty much mimics how the board is working on lichess when you promote.


Unrelated question... you have the promotion overlay here? I couldn't figure out how to do this in the library itself so I rebuilt it myself. Is the promotion overlay actually in this library?

@elsiniestra
Copy link
Author

elsiniestra commented Dec 28, 2022

When I did this it pretty much mimics how the board is working on lichess when you promote.

I don't know how and where you're testing it, but this exact bug I recorded on lichess.org, not my own board. I checked this now again and it still has the same lag on the website.

you have the promotion overlay here? I couldn't figure out how to do this in the library itself so I rebuilt it myself. Is the promotion overlay actually in this library?

Speaking of this, I do believe I was finding smth in the library since I also rewrote pretty heavily the source library but cannot say that I'm sure about it because I did put off my project for the last 1.5 months

@elsiniestra
Copy link
Author

elsiniestra commented Dec 28, 2022

@thinktt yep, this approach did remove the lag, but, since I have the arrow bindings for the move navigation, it looks pretty bizarre when all the moves perform smoothly and then happens non-animated promotion, so I'm still looking for a more good-looking/user-friendly approach. The way chess.com handles it is pretty fine but I didn't make it to find out how to realize the same approach for the chessground

@thinktt
Copy link

thinktt commented Dec 28, 2022

I went back and looked, I was testing on the analysis board. I was able to play around with it and see the ghosting effect you mentioned.

When I was actually using Chesground it was giving me some extra funky animations so I just played with the animation until it at least wasn't distracting for me. Now I'm curious how chess.com does it. I'll take a look.

@thinktt
Copy link

thinktt commented Dec 28, 2022

@capitalistelite
So I looked at how chess.com does it. This is what I saw.

  1. At the point of promotion they turn off the animation completely (the pawn never moves to the square it just disappears and the promotion box appears).
  2. When replaying the move the piece changes into its promotion and then moves to the square as if capturing.

I think I might be able to recreate both of those effects using the chess ground interface as is. I might try it and if I get it working I'll let you know.

@elsiniestra
Copy link
Author

@thinktt thank you, I'll appreciate it a lot!

@elsiniestra
Copy link
Author

@thinktt Hello! I'd like to know have you tried the method you talked about to recreate those effects? If yes, and you did not get it working, can you share what exactly your idea was? Maybe based on the info, I might try to do my own research on this

@Hugos68
Copy link

Hugos68 commented Feb 14, 2023

I have the same issue here on promotion its a bit buggy

@thinktt
Copy link

thinktt commented Feb 28, 2023

Howdy @capitalistelite

So I got bogged down with my project and didn't really have any time to look into it, and right now I've moved on to something else at the moment... however I just looked at it and created a gist of kind of what I'm doing. I don't know if it'll be helpful, as it's not really complete, but take a look and maybe it'll give you an idea.

https://gist.github.com/thinktt/5b1d5933755c45dce152178f73a94696

The main thing to play with is, in the Chess Ground config is { movable: { events: { after: onMove } } }

Create an onMove function then test for promotions, then play around with turning the animation on and off on the board, then updating it however you want to.

I hope that's helpful, maybe I can give more details later or if you have a question I'll try and explain more at some point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants