MCPcopy
hub / github.com/midrender/revideo / toggle

Method toggle

packages/examples/src/components/Switch.tsx:63–83  ·  view source on GitHub ↗
(duration: number)

Source from the content-addressed store, hash-verified

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}

Callers 2

updateClassMethod · 0.80
components.tsxFile · 0.80

Calls 5

allFunction · 0.90
tweenFunction · 0.90
easeInOutCubicFunction · 0.90
positionMethod · 0.80
lerpMethod · 0.65

Tested by

no test coverage detected