commit d43c83fc3cafd9aafce483d2cb3d8d36eaa482dc
parent a591d54b2e2916ba90de53a59dc43cea6c905e45
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Sun, 11 Jun 2023 16:31:45 -0700
cleanup
Diffstat:
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/pkg/web/handlers/handlers.go b/pkg/web/handlers/handlers.go
@@ -5198,6 +5198,8 @@ Loop:
continue
}
+ const animationMs = 400
+
animate := func(s1, s2 chess.Square, id string) {
x1, y1 := int(s1.File()), int(s1.Rank())
x2, y2 := int(s2.File()), int(s2.Rank())
@@ -5210,7 +5212,7 @@ Loop:
}
i++
send(fmt.Sprintf(`<style>@keyframes move_anim_%d { from { left: calc(%d*12.5%%); top: calc(%d*12.5%%); } to { left: calc(%d*12.5%%); top: calc(%d*12.5%%); } }</style>`, i, x1, y1, x2, y2))
- send(fmt.Sprintf(`<style>#%s { animation-name: move_anim_%d; animation-duration: 400ms; animation-fill-mode: forwards; }</style>`, id, i))
+ send(fmt.Sprintf(`<style>#%s { animation-name: move_anim_%d; animation-duration: %dms; animation-fill-mode: forwards; }</style>`, id, i, animationMs))
}
animate(payload.Move.S1(), payload.Move.S2(), payload.IDStr1)
@@ -5221,7 +5223,7 @@ Loop:
if payload.Move.Promo() != chess.NoPieceType {
go func(payload interceptors.ChessMove, c echo.Context) {
select {
- case <-time.After(400 * time.Millisecond):
+ case <-time.After(animationMs * time.Millisecond):
case <-quit:
return
}