Skip to content

Commit

Permalink
Fixed issue with the switch button in the Server Options for switchin…
Browse files Browse the repository at this point in the history
…g between using a local and remote server.
  • Loading branch information
flemming-n-larsen committed Feb 3, 2025
1 parent b807d42 commit 83156d8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 2 additions & 0 deletions VERSIONS.MD
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ A new sample bot, PaintingBot, has been introduced to showcase the use of debug

- Server:
- Log messages printed out `{}` instead of content.
- UI:
- Fixed issue with the switch button in the Server Options for switching between using a local and remote server.

## 📦 0.29.0 - All about colors - 19-Jan-2024

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import javax.swing.Timer
class SwitchButton(initialSelected: Boolean) : JComponent() {

private var knobLocation: Float = 2f
private val animationSpeed: Float = 0.05f
private val animationTimer = createAnimationTimer()

var isSelected = initialSelected
Expand Down Expand Up @@ -49,19 +48,19 @@ class SwitchButton(initialSelected: Boolean) : JComponent() {
})
}

private fun createAnimationTimer(): Timer = Timer(0) { _ ->
private fun createAnimationTimer(): Timer = Timer(1000 / 60) { _ ->
if (isSelected) {
val endLocation = width - height + 2f
if (knobLocation < endLocation) {
knobLocation += animationSpeed
knobLocation += 4f
} else {
animationTimer.stop()
knobLocation = endLocation
}
} else {
val endLocation = 2f
if (knobLocation > endLocation) {
knobLocation -= animationSpeed
knobLocation -= 4f
} else {
animationTimer.stop()
knobLocation = endLocation
Expand Down

0 comments on commit 83156d8

Please sign in to comment.