1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-06-15 00:15:32 +02:00

Add constant for LoaderAnimationInterval

Since Loader and renderAppStatus need to agree on it, it helps for it to be a
constant in case we want to change it.
This commit is contained in:
Stefan Haller
2023-08-29 14:15:36 +02:00
parent 64012d67a9
commit cdad0b998e
2 changed files with 7 additions and 3 deletions

View File

@ -24,12 +24,15 @@ func GetProjectRoot() string {
return strings.Split(dir, "lazygit")[0] + "lazygit"
}
// The duration between two frames of the loader animation in milliseconds
const LoaderAnimationInterval = 50
// Loader dumps a string to be displayed as a loader
func Loader() string {
characters := "|/-\\"
now := time.Now()
nanos := now.UnixNano()
index := nanos / 50000000 % int64(len(characters))
milliseconds := now.UnixMilli()
index := milliseconds / LoaderAnimationInterval % int64(len(characters))
return characters[index : index+1]
}