(duration: number)
| 61 | } |
| 62 | |
| 63 | public *toggle(duration: number) { |
| 64 | yield* all( |
| 65 | tween(duration, value => { |
| 66 | const oldColor = this.isOn ? this.accent() : this.offColor; |
| 67 | const newColor = this.isOn ? this.offColor : this.accent(); |
| 68 | |
| 69 | this.container().fill( |
| 70 | Color.lerp(oldColor, newColor, easeInOutCubic(value)), |
| 71 | ); |
| 72 | }), |
| 73 | |
| 74 | tween(duration, value => { |
| 75 | const currentPos = this.indicator().position(); |
| 76 | |
| 77 | this.indicatorPosition( |
| 78 | easeInOutCubic(value, currentPos.x, this.isOn ? -50 : 50), |
| 79 | ); |
| 80 | }), |
| 81 | ); |
| 82 | this.isOn = !this.isOn; |
| 83 | } |
| 84 | } |
no test coverage detected