mirror of
https://github.com/Maks1mS/bubbles.git
synced 2025-03-13 20:43:44 +03:00
Add WithSpringOptions to customize spring in NewModel
This commit is contained in:
parent
90d8eaffeb
commit
e723cfd15e
@ -98,6 +98,13 @@ func WithWidth(w int) Option {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func WithSpringOptions(frequency, damping float64) Option {
|
||||||
|
return func(m *Model) {
|
||||||
|
m.SetSpringOptions(frequency, damping)
|
||||||
|
m.springCustomized = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// FrameMsg indicates that an animation step should occur.
|
// FrameMsg indicates that an animation step should occur.
|
||||||
type FrameMsg struct {
|
type FrameMsg struct {
|
||||||
id int
|
id int
|
||||||
@ -130,10 +137,11 @@ type Model struct {
|
|||||||
PercentageStyle lipgloss.Style
|
PercentageStyle lipgloss.Style
|
||||||
|
|
||||||
// Members for animated transitons.
|
// Members for animated transitons.
|
||||||
spring harmonica.Spring
|
spring harmonica.Spring
|
||||||
percent float64
|
springCustomized bool
|
||||||
targetPercent float64
|
percent float64
|
||||||
velocity float64
|
targetPercent float64
|
||||||
|
velocity float64
|
||||||
|
|
||||||
// Gradient settings
|
// Gradient settings
|
||||||
useRamp bool
|
useRamp bool
|
||||||
@ -158,7 +166,9 @@ func NewModel(opts ...Option) Model {
|
|||||||
ShowPercentage: true,
|
ShowPercentage: true,
|
||||||
PercentFormat: " %3.0f%%",
|
PercentFormat: " %3.0f%%",
|
||||||
}
|
}
|
||||||
m.SetSpringOptions(defaultFrequency, defaultDamping)
|
if !m.springCustomized {
|
||||||
|
m.SetSpringOptions(defaultFrequency, defaultDamping)
|
||||||
|
}
|
||||||
|
|
||||||
for _, opt := range opts {
|
for _, opt := range opts {
|
||||||
opt(&m)
|
opt(&m)
|
||||||
|
Loading…
Reference in New Issue
Block a user