mirror of
https://github.com/charmbracelet/harmonica.git
synced 2026-07-20 02:29:33 -06:00
Change waitASec to wait
waitASec sometimes sleeps for 500ms and 750ms, so sleep for a duration rather than an int
This commit is contained in:
parent
5a37ebca21
commit
987abb3735
@ -39,9 +39,9 @@ func animate() tea.Cmd {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func waitASec(ms int) tea.Cmd {
|
func wait(d time.Duration) tea.Cmd {
|
||||||
return func() tea.Msg {
|
return func() tea.Msg {
|
||||||
time.Sleep(time.Millisecond * time.Duration(ms))
|
time.Sleep(d)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -53,7 +53,7 @@ type model struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (_ model) Init() tea.Cmd {
|
func (_ model) Init() tea.Cmd {
|
||||||
return tea.Sequentially(waitASec(500), animate())
|
return tea.Sequentially(wait(time.Second/2), animate())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||||
@ -70,7 +70,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||||||
|
|
||||||
// Quit when we're basically at the target position.
|
// Quit when we're basically at the target position.
|
||||||
if math.Abs(m.x-targetX) < 0.01 {
|
if math.Abs(m.x-targetX) < 0.01 {
|
||||||
return m, tea.Sequentially(waitASec(750), tea.Quit)
|
return m, tea.Sequentially(wait(3/4*time.Second), tea.Quit)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Request next frame
|
// Request next frame
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user