feat(docs/hold-tap): Implement tap-unless-interrupted animations
This commit is contained in:
parent
578543b02b
commit
97b3e3f4e9
10 changed files with 141 additions and 3 deletions
|
@ -71,15 +71,19 @@ On the other hand, if the interrupting key is released before the hold-tap, the
|
||||||
|
|
||||||
<TabItem value="tap-preferred">
|
<TabItem value="tap-preferred">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<AnimationPlayer auto small name="tap_preferred_hold_tap_up" />
|
<AnimationPlayer auto small name="tap_preferred_hold_tap_up" />
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
|
||||||
<TabItem value="tap-unless-interrupted">
|
<TabItem value="tap-unless-interrupted">
|
||||||
|
|
||||||

|
As seen below, the hold duration of the 'tap-unless-interrupteed' hold-tap does not have an effect on the output. The 'tap' behavior will always be invoked.
|
||||||
|
|
||||||
|
<AnimationPlayer auto small name="tap_unless_interrupted" />
|
||||||
|
|
||||||
|
Only another key being pressed can invoke the 'hold' behavior.
|
||||||
|
|
||||||
|
<AnimationPlayer auto small name="tap_unless_interrupted_invoke_hold" />
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"version": 0
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
import { makeProject } from "@motion-canvas/core/lib";
|
||||||
|
|
||||||
|
import tap_unless_interrupted from "../scenes/hold_tap/tap_unless_interrupted?scene";
|
||||||
|
|
||||||
|
export default makeProject({
|
||||||
|
scenes: [tap_unless_interrupted],
|
||||||
|
background: "#FFFFFF",
|
||||||
|
});
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"version": 0
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
import { makeProject } from "@motion-canvas/core/lib";
|
||||||
|
|
||||||
|
import tap_unless_interrupted_invoke_hold from "../scenes/hold_tap/tap_unless_interrupted_invoke_hold?scene";
|
||||||
|
|
||||||
|
export default makeProject({
|
||||||
|
scenes: [tap_unless_interrupted_invoke_hold],
|
||||||
|
background: "#FFFFFF",
|
||||||
|
});
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"version": 0
|
||||||
|
}
|
|
@ -0,0 +1,54 @@
|
||||||
|
import { makeScene2D } from "@motion-canvas/2d/lib/scenes";
|
||||||
|
import { Text } from "@motion-canvas/2d/lib/components";
|
||||||
|
import { createRef, makeRefs } from "@motion-canvas/core/lib/utils";
|
||||||
|
import { all, chain, delay, waitFor } from "@motion-canvas/core/lib/flow";
|
||||||
|
import Key, { KeyTravel } from "../../components/Key";
|
||||||
|
import Output from "../../components/Output";
|
||||||
|
import { linear } from "@motion-canvas/core/lib/tweening";
|
||||||
|
|
||||||
|
export default makeScene2D(function* (view) {
|
||||||
|
const tap = makeRefs<typeof Key>();
|
||||||
|
view.add(<Key refs={tap} binding={"&ht_tui"} params={"\u21e7 F"} />);
|
||||||
|
tap.group.position.x(-400);
|
||||||
|
tap.group.position.y(-150);
|
||||||
|
tap.duration.fill("#D9D9D9");
|
||||||
|
|
||||||
|
const tap_output = makeRefs<typeof Output>();
|
||||||
|
view.add(<Output refs={tap_output} />);
|
||||||
|
tap_output.group.position(tap.group.position());
|
||||||
|
tap_output.group.position.y(tap_output.group.position.y() + 300);
|
||||||
|
|
||||||
|
const hold = makeRefs<typeof Key>();
|
||||||
|
view.add(<Key refs={hold} binding={"&ht_tui"} params={"\u21e7 F"} />);
|
||||||
|
hold.group.position.x(400);
|
||||||
|
hold.group.position.y(-150);
|
||||||
|
hold.duration.fill("#D9D9D9");
|
||||||
|
|
||||||
|
const hold_output = makeRefs<typeof Output>();
|
||||||
|
view.add(<Output refs={hold_output} />);
|
||||||
|
hold_output.group.position(hold.group.position());
|
||||||
|
hold_output.group.position.y(hold_output.group.position.y() + 300);
|
||||||
|
|
||||||
|
yield* waitFor(0.5);
|
||||||
|
yield* all(
|
||||||
|
tap.body.position.y(KeyTravel, 0.15),
|
||||||
|
hold.body.position.y(KeyTravel, 0.15)
|
||||||
|
);
|
||||||
|
yield* all(
|
||||||
|
tap.duration.grow(0.5, 1, linear),
|
||||||
|
delay(1, tap.body.position.y(0, 0.15)),
|
||||||
|
hold.duration.grow(1, 2, linear)
|
||||||
|
);
|
||||||
|
yield* chain(
|
||||||
|
all(tap.group.rotation(3, 0.03), hold.group.rotation(3, 0.03)),
|
||||||
|
all(tap.group.rotation(-3, 0.06), hold.group.rotation(-3, 0.06)),
|
||||||
|
all(tap.group.rotation(0, 0.03), hold.group.rotation(0, 0.03)),
|
||||||
|
all(tap_output.output.text("f", 0), hold_output.output.text("f", 0))
|
||||||
|
);
|
||||||
|
yield* waitFor(0.25);
|
||||||
|
yield* hold.body.position.y(0, 0.15);
|
||||||
|
yield* delay(
|
||||||
|
0.5,
|
||||||
|
all(tap.duration.grow(0, 0.15), hold.duration.grow(0, 0.15))
|
||||||
|
);
|
||||||
|
});
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"version": 0
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
import { makeScene2D } from "@motion-canvas/2d/lib/scenes";
|
||||||
|
import { makeRefs } from "@motion-canvas/core/lib/utils";
|
||||||
|
import { any, all, chain, delay, waitFor } from "@motion-canvas/core/lib/flow";
|
||||||
|
import Key, { KeyTravel } from "../../components/Key";
|
||||||
|
import Output from "../../components/Output";
|
||||||
|
import { linear } from "@motion-canvas/core/lib/tweening";
|
||||||
|
|
||||||
|
export default makeScene2D(function* (view) {
|
||||||
|
const interrupt = makeRefs<typeof Key>();
|
||||||
|
view.add(<Key refs={interrupt} binding={"&kp"} params={"J"} />);
|
||||||
|
interrupt.group.position.x(125);
|
||||||
|
interrupt.group.position.y(-150);
|
||||||
|
interrupt.duration.fill("#D9D9D9");
|
||||||
|
|
||||||
|
const hold = makeRefs<typeof Key>();
|
||||||
|
view.add(<Key refs={hold} binding={"&ht_tui"} params={"\u21e7 F"} />);
|
||||||
|
hold.group.position.x(-125);
|
||||||
|
hold.group.position.y(-150);
|
||||||
|
hold.duration.fill("#D9D9D9");
|
||||||
|
|
||||||
|
const hold_output = makeRefs<typeof Output>();
|
||||||
|
view.add(<Output refs={hold_output} />);
|
||||||
|
hold_output.group.position(hold.group.position().addX(125));
|
||||||
|
hold_output.group.position.y(hold_output.group.position.y() + 300);
|
||||||
|
|
||||||
|
yield* waitFor(0.5);
|
||||||
|
yield* any(
|
||||||
|
hold.body.position.y(KeyTravel, 0.15),
|
||||||
|
hold.duration.grow(0.75, 1.5, linear)
|
||||||
|
);
|
||||||
|
yield* delay(
|
||||||
|
1.2,
|
||||||
|
all(
|
||||||
|
interrupt.body.position.y(KeyTravel, 0.15),
|
||||||
|
hold.duration.fill("F21D00", 0.15)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
yield* chain(
|
||||||
|
hold.group.rotation(3, 0.03),
|
||||||
|
hold.group.rotation(-3, 0.06),
|
||||||
|
hold.group.rotation(0, 0.03),
|
||||||
|
all(
|
||||||
|
delay(0.15, hold_output.output.text("J", 0)),
|
||||||
|
hold_output.shift.fill("#969696", 0.15)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
yield* waitFor(0.25);
|
||||||
|
yield* hold.body.position.y(0, 0.15);
|
||||||
|
yield* delay(0.5, hold.duration.grow(0, 0.15));
|
||||||
|
});
|
|
@ -10,6 +10,8 @@ export default defineConfig({
|
||||||
"./src/hold_tap/balanced_other_key_up.ts",
|
"./src/hold_tap/balanced_other_key_up.ts",
|
||||||
"./src/hold_tap/balanced_hold_tap_up.ts",
|
"./src/hold_tap/balanced_hold_tap_up.ts",
|
||||||
"./src/hold_tap/tap_preferred_hold_tap_up.ts",
|
"./src/hold_tap/tap_preferred_hold_tap_up.ts",
|
||||||
|
"./src/hold_tap/tap_unless_interrupted.ts",
|
||||||
|
"./src/hold_tap/tap_unless_interrupted_invoke_hold.ts",
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
|
Loading…
Add table
Reference in a new issue