mirror of
https://github.com/Maks1mS/bubbles.git
synced 2024-12-24 14:44:38 +03:00
Fix comments + minimum lifetime should work in conjunction with HideFor
This commit is contained in:
parent
e8526ec4ef
commit
084d0acefd
@ -44,8 +44,13 @@ type Model struct {
|
|||||||
// (per github.com/muesli/termenv).
|
// (per github.com/muesli/termenv).
|
||||||
BackgroundColor string
|
BackgroundColor string
|
||||||
|
|
||||||
// Minimum amount of time the spinner can run. Any logic around this can
|
// MinimumLifetime is the minimum amount of time the spinner can run. Any
|
||||||
// be implemented in view that implements this spinner. Optional.
|
// logic around this can be implemented in view that implements this
|
||||||
|
// spinner. If HideFor is set MinimumLifetime will be added on top of
|
||||||
|
// HideFor. In other words, if HideFor is 100ms and MinimumLifetime is
|
||||||
|
// 200ms then MinimumLifetime will expire after 300ms.
|
||||||
|
//
|
||||||
|
// MinimumLifetime is optional.
|
||||||
MinimumLifetime time.Duration
|
MinimumLifetime time.Duration
|
||||||
|
|
||||||
// HideFor can be used to wait to show the spinner until a certain amount
|
// HideFor can be used to wait to show the spinner until a certain amount
|
||||||
@ -54,7 +59,8 @@ type Model struct {
|
|||||||
// Optional.
|
// Optional.
|
||||||
HideFor time.Duration
|
HideFor time.Duration
|
||||||
|
|
||||||
// HiddenState is the
|
// HiddenState is the state to render the spinner when HideFor is in effect.
|
||||||
|
// For more control you can also use Model.Hidden() in the parent view.
|
||||||
HiddenState string
|
HiddenState string
|
||||||
|
|
||||||
frame int
|
frame int
|
||||||
@ -78,7 +84,7 @@ func (m Model) MinimumLifetimeReached() bool {
|
|||||||
if m.MinimumLifetime == 0 {
|
if m.MinimumLifetime == 0 {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return m.startTime.Add(m.MinimumLifetime).Before(time.Now())
|
return m.startTime.Add(m.HideFor).Add(m.MinimumLifetime).Before(time.Now())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hidden returns whether or not the view should be rendered. Works in
|
// Hidden returns whether or not the view should be rendered. Works in
|
||||||
|
Loading…
Reference in New Issue
Block a user