feat(docs/hold-tap): Implement hold-preferred/interrupt Motion Canvas Project
This commit is contained in:
parent
60744c3181
commit
1be2023fe6
8 changed files with 77 additions and 2 deletions
|
@ -28,6 +28,11 @@ By default, the hold-tap is configured to also select the 'hold' functionality i
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
<motion-canvas-player
|
||||||
|
src={"/animations/hold_tap_interrupted.js"}
|
||||||
|
auto={true}
|
||||||
|
/>
|
||||||
|
|
||||||
We call this the 'hold-preferred' flavor of hold-taps. While this flavor may work very well for a ctrl/escape key, it's not very well suited for home-row mods or layer-taps. That's why there are two more flavors to choose from: 'tap-preferred' and 'balanced'.
|
We call this the 'hold-preferred' flavor of hold-taps. While this flavor may work very well for a ctrl/escape key, it's not very well suited for home-row mods or layer-taps. That's why there are two more flavors to choose from: 'tap-preferred' and 'balanced'.
|
||||||
|
|
||||||
#### Flavors
|
#### Flavors
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Rect, Text, Node } from "@motion-canvas/2d/lib/components";
|
import { Rect, Text } from "@motion-canvas/2d/lib/components";
|
||||||
import { makeRef } from "@motion-canvas/core/lib/utils";
|
import { makeRef } from "@motion-canvas/core/lib/utils";
|
||||||
import { KeyBorderThickness } from "./Key";
|
import { KeyBorderThickness } from "./Key";
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"version": 0
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
import {makeProject} from '@motion-canvas/core/lib';
|
||||||
|
|
||||||
|
import hold_tap_interrupted from '../scenes/hold_tap/hold_tap_interrupted?scene';
|
||||||
|
|
||||||
|
export default makeProject({
|
||||||
|
scenes: [hold_tap_interrupted],
|
||||||
|
background: '#FFFFFF',
|
||||||
|
});
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"version": 0
|
||||||
|
}
|
|
@ -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={"&mt"} 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));
|
||||||
|
});
|
|
@ -4,7 +4,10 @@ import motionCanvas from "@motion-canvas/vite-plugin";
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [
|
plugins: [
|
||||||
motionCanvas({
|
motionCanvas({
|
||||||
project: ["./src/hold_tap/hold_tap_comparison.ts"],
|
project: [
|
||||||
|
"./src/hold_tap/hold_tap_comparison.ts",
|
||||||
|
"./src/hold_tap/hold_tap_interrupted.ts",
|
||||||
|
],
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
build: {
|
build: {
|
||||||
|
|
Loading…
Add table
Reference in a new issue