Visualize Your Ideas With Code
feat: better playback controls
aarthificial796ae3356c48
diff --git a/public/icons/pause.svg b/public/icons/pause.svgnew file mode 100644index 00000000..914f25a7--- /dev/null+++ b/public/icons/pause.svg@@ -0,0 +1 @@+<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><g><rect fill="none" height="24" width="24"/></g><g><g><path d="M12,2C6.48,2,2,6.48,2,12s4.48,10,10,10s10-4.48,10-10S17.52,2,12,2z M11,16H9V8h2V16z M15,16h-2V8h2V16z"/></g></g></svg>\ No newline at end of filediff --git a/public/icons/play_arrow.svg b/public/icons/play_arrow.svgnew file mode 100644index 00000000..1bb457c6--- /dev/null+++ b/public/icons/play_arrow.svg@@ -0,0 +1 @@+<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><g><rect fill="none" height="24" width="24"/></g><g><path d="M12,2C6.48,2,2,6.48,2,12s4.48,10,10,10s10-4.48,10-10S17.52,2,12,2z M9.5,16.5v-9l7,4.5L9.5,16.5z"/></g></svg>\ No newline at end of filediff --git a/public/icons/repeat.svg b/public/icons/repeat.svgnew file mode 100644index 00000000..cd41e84e--- /dev/null+++ b/public/icons/repeat.svg@@ -0,0 +1 @@+<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0z" fill="none"/><path d="M7 7h10v3l4-4-4-4v3H5v6h2V7zm10 10H7v-3l-4 4 4 4v-3h12v-6h-2v4z"/></svg>\ No newline at end of filediff --git a/public/icons/skip_next.svg b/public/icons/skip_next.svgnew file mode 100644index 00000000..48b0ea99--- /dev/null+++ b/public/icons/skip_next.svg@@ -0,0 +1 @@+<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0z" fill="none"/><path d="M6 18l8.5-6L6 6v12zM16 6v12h2V6h-2z"/></svg>\ No newline at end of filediff --git a/public/icons/skip_previous.svg b/public/icons/skip_previous.svgnew file mode 100644index 00000000..73472726--- /dev/null+++ b/public/icons/skip_previous.svg@@ -0,0 +1 @@+<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0z" fill="none"/><path d="M6 6h2v12H6zm3.5 6l8.5 6V6z"/></svg>\ No newline at end of filediff --git a/public/icons/volume_off.svg b/public/icons/volume_off.svgnew file mode 100644index 00000000..6c3d22f2--- /dev/null+++ b/public/icons/volume_off.svg@@ -0,0 +1 @@+<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0z" fill="none"/><path d="M16.5 12c0-1.77-1.02-3.29-2.5-4.03v2.21l2.45 2.45c.03-.2.05-.41.05-.63zm2.5 0c0 .94-.2 1.82-.54 2.64l1.51 1.51C20.63 14.91 21 13.5 21 12c0-4.28-2.99-7.86-7-8.77v2.06c2.89.86 5 3.54 5 6.71zM4.27 3L3 4.27 7.73 9H3v6h4l5 5v-6.73l4.25 4.25c-.67.52-1.42.93-2.25 1.18v2.06c1.38-.31 2.63-.95 3.69-1.81L19.73 21 21 19.73l-9-9L4.27 3zM12 4L9.91 6.09 12 8.18V4z"/></svg>\ No newline at end of filediff --git a/public/icons/volume_on.svg b/public/icons/volume_on.svgnew file mode 100644index 00000000..0362732c--- /dev/null+++ b/public/icons/volume_on.svg@@ -0,0 +1 @@+<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0z" fill="none"/><path d="M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z"/></svg>\ No newline at end of filediff --git a/public/index.html b/public/index.htmlindex 48c6cd06..8d417da9 100644--- a/public/index.html+++ b/public/index.html@@ -8,197 +8,81 @@/><meta http-equiv="X-UA-Compatible" content="ie=edge" /><link rel="icon" href="data:;base64,iVBORw0KGgo=" />- <title>Document</title>- <style>- body {- margin: 0;- padding: 0;- overflow: hidden;- display: flex;- width: 100vw;- height: 100vh;- align-items: center;- justify-content: center;- background: black;- font-family: Roboto, sans-serif;- }-- #controls {- padding: 8px;- border-radius: 8px;- display: grid;- grid-auto-flow: column;- grid-gap: 8px;- position: absolute;- top: 0;- left: 0;- color: white;- background: rgba(0, 0, 0, 0.3);- }-- #ui {- min-width: 360px;- padding: 8px;- padding-right: 24px;- border-radius: 8px;- display: grid;- grid-auto-flow: row;- grid-gap: 8px;- position: absolute;- top: 0;- right: 0;- color: white;- background: rgba(0, 0, 0, 0.3);- }-- #ui ul {- padding-left: 16px;- }-- .cancelled {- color: red;- }-- #timeline {- padding: 16px;- position: absolute;- bottom: 0;- left: 0;- right: 0;- }-- .track {- border-radius: 4px;- height: 8px;- background: rgba(255, 255, 255, 0.3);- position: relative;- }-- .fill {- background-color: white;- border-radius: 4px;- width: 25%;- position: absolute;- top: 0;- left: 0;- bottom: 0;- }-- .fill-start {- background-color: #FA6466;- }-- .marker {- position: absolute;- top: 12px;- bottom: 12px;- width: 8px;- border-radius: 4px;- background-color: #FA6466;- }-- .label {- position: absolute;- top: 0;- bottom: 0;- width: 16px;- padding: 12px;-- display: flex;- justify-content: center;- }-- .label::before {- content: '';- display: block;- width: 16px;- height: 16px;- border-radius: 8px;- background-color: #F5DC7C;- }-- .label::after {- content: attr(data-title);- display: block;- position: absolute;- color: white;- background-color: rgba(0, 0, 0, 0.87);- bottom: 48px;- text-align: center;- padding: 4px 8px;- border-radius: 2px;- opacity: 0;- pointer-events: none ;- }-- .label:hover::after {- opacity: 1;- }-- </style>+ <link rel="stylesheet" href="styles.css" />+ <title>Motion Canvas</title></head><body><div id="container"></div>- <details id="ui">+ <details id="threads"><summary>THREADS</summary></details>- <div id="timeline">- <div class="track">- <div class="fill fill-seek"></div>- <div class="fill fill-time"></div>- <div class="fill fill-start"></div>+ <div id="ui">+ <div id="timeline">+ <div class="timeline-text js-current-time">0</div>+ <div class="track">+ <div class="fill fill-seek"></div>+ <div class="fill fill-time"></div>+ <div class="fill fill-start"></div>+ <div class="marker"></div>+ </div>+ <div class="timeline-text js-duration">10,000</div></div>- <div class="marker"></div>- </div>- <form id="controls">- <div>- <input type="checkbox" id="controls-play" name="play" checked />- <label for="controls-play">Play</label>- </div>- <div>- <input type="checkbox" id="controls-loop" name="loop" checked />- <label for="controls-loop">Loop</label>- </div>- <div>- <input type="checkbox" id="controls-audio" name="audio" checked />- <label for="controls-audio">Audio</label>- </div>- <input type="number" id="controls-from" name="from" value="0" />- <input type="button" id="controls-reset" name="refresh" value="Reset" />- <input type="button" id="controls-next" name="next" value="Next" />- <div>- <label for="controls-current">Current:</label>+ <form id="controls">+ <div class="icon-checkbox">+ <input type="checkbox" id="controls-audio" name="audio" checked />+ <label for="controls-audio"></label>+ </div><input- type="number"- readonly- id="controls-current"- name="current"- value="0"+ class="icon-button"+ type="button"+ id="controls-reset"+ name="refresh"/>- </div>- <div>- <label for="controls-speed">Speed:</label>- <select name="speed" id="controls-speed">- <option value="2">2x</option>- <option value="1.5">1.5x</option>- <option value="1" selected>1x</option>- <option value="0.5">0.5x</option>- <option value="0.25">0.25x</option>- </select>- </div>- <div>- <label for="controls-fps">FPS:</label>+ <div class="icon-checkbox">+ <input type="checkbox" id="controls-play" name="play" checked />+ <label for="controls-play"></label>+ </div><input- type="number"- readonly- id="controls-fps"- name="fps"- value="0"+ class="icon-button"+ type="button"+ id="controls-next"+ name="next"/>- </div>- <input type="button" id="controls-render" name="render" value="Render" />- <div id="loading">Loading...</div>- </form>+ <div class="icon-checkbox">+ <input type="checkbox" id="controls-loop" name="loop" checked />+ <label for="controls-loop"></label>+ </div>+ <div hidden>+ <div>+ <label for="controls-speed">Speed:</label>+ <select name="speed" id="controls-speed">+ <option value="2">2x</option>+ <option value="1.5">1.5x</option>+ <option value="1" selected>1x</option>+ <option value="0.5">0.5x</option>+ <option value="0.25">0.25x</option>+ </select>+ </div>+ <div>+ <label for="controls-fps">FPS:</label>+ <input+ type="number"+ readonly+ id="controls-fps"+ name="fps"+ value="0"+ />+ </div>+ <input+ type="button"+ id="controls-render"+ name="render"+ value="Render"+ />+ <div id="loading">Loading...</div>+ </div>+ </form>+ </div><script src="index.js"></script></body></html>diff --git a/public/styles.css b/public/styles.cssnew file mode 100644index 00000000..6eaaec0d--- /dev/null+++ b/public/styles.css@@ -0,0 +1,262 @@+:root {+ --theme: #33a6ff;+}++* {+ box-sizing: border-box;+}++body {+ margin: 0;+ padding: 0;+ overflow: hidden;+ display: flex;+ width: 100vw;+ height: 100vh;+ align-items: center;+ justify-content: center;+ background: black;+ font-family: Roboto, sans-serif;+}++#threads {+ min-width: 360px;+ padding: 8px;+ padding-right: 24px;+ border-radius: 8px;+ display: grid;+ grid-auto-flow: row;+ grid-gap: 8px;+ position: absolute;+ top: 0;+ right: 0;+ color: white;+ background: rgba(0, 0, 0, 0.3);+}++#threads ul {+ padding-left: 16px;+}++.cancelled {+ color: red;+}++#ui {+ position: absolute;+ bottom: 0;+ left: 0;+ right: 0;+ background: #242424;+}++#controls {+ margin-bottom: 16px;+ padding: 8px;+ display: flex;+ justify-content: center;+}++.icon-checkbox {+}++.icon-button {+ -webkit-appearance: none;+ width: 24px;+ height: 24px;+ padding: 12px;+ margin: 12px;+ display: block;+ cursor: pointer;+ border: 0;+ opacity: 0.54;+}++.icon-button:hover {+ opacity: 1;+}++#controls-reset {+ -webkit-mask-image: url('icons/skip_previous.svg');+}++#controls-next {+ -webkit-mask-image: url('icons/skip_next.svg');+}++.icon-checkbox input {+ display: none;+}++.icon-checkbox label {+ width: 24px;+ height: 24px;+ padding: 12px;+ margin: 12px;+ display: block;+ background: #ffffff;+ cursor: pointer;+}++.icon-checkbox input + label:hover {+ opacity: 1 !important;+}++#controls-play + label {+ -webkit-mask-image: url('icons/play_arrow.svg');+ transform: scale(2);+ transition: transform 50ms;+}+#controls-play:checked + label {+ -webkit-mask-image: url('icons/pause.svg');+}+#controls-play + label:hover {+ transform: scale(2.1);+}+#controls-play + label:active {+ transform: scale(2);+}++#controls-audio + label {+ opacity: 0.54;+ -webkit-mask-image: url('icons/volume_off.svg');+}+#controls-audio:checked + label {+ opacity: 1;+ background: var(--theme);+ -webkit-mask-image: url('icons/volume_on.svg');+}++#controls-loop + label {+ opacity: 0.54;+ -webkit-mask-image: url('icons/repeat.svg');+}+#controls-loop:checked + label {+ background: var(--theme);+ opacity: 1;+}++#timeline {+ padding: 16px;+ display: flex;+ align-items: center;+}++.timeline-text {+ color: rgba(255, 255, 255, 0.6);+ width: 60px;+ font-family: 'JetBrains Mono', sans-serif;+}++.js-current-time {+ text-align: right;+}++.track {+ border-radius: 4px;+ height: 8px;+ margin: 0 16px;+ background: rgba(255, 255, 255, 0.3);+ position: relative;+ flex-grow: 1;+}++.fill {+ background-color: white;+ border-radius: 4px;+ width: 25%;+ position: absolute;+ top: 0;+ left: 0;+ bottom: 0;+}++.fill-seek {+ opacity: 0;+}++#timeline:hover .fill-seek {+ opacity: 0.32;+}++.fill-start {+ background-color: var(--theme);+}++.marker {+ position: absolute;+ top: -4px;+ bottom: -4px;+ width: 8px;+ border-radius: 4px;+ background-color: var(--theme);++ display: flex;+ justify-content: center;+}++.marker::after {+ content: attr(data-title);+ display: block;+ position: absolute;+ color: rgba(0, 0, 0, 0.87);+ background-color: rgba(255, 255, 255, 0.87);+ bottom: 24px;+ text-align: center;+ padding: 4px 8px;+ border-radius: 2px;+ opacity: 0;+ pointer-events: none;+}++.marker:hover::after {+ opacity: 1;+}++.label {+ position: absolute;+ top: -16px;+ bottom: -16px;+ width: 40px;+ padding: 12px;+ cursor: pointer;++ display: flex;+ justify-content: center;+ align-items: center;+}++.label.hidden {+ display: none;+}++.label.inverted::before {+ background-color: var(--theme);+}++.label::before {+ content: '';+ display: block;+ width: 6px;+ height: 6px;+ border-radius: 3px;+ background-color: #ffffff;+}++.label::after {+ content: attr(data-title);+ display: block;+ position: absolute;+ color: rgba(0, 0, 0, 0.87);+ background-color: rgba(255, 255, 255, 0.87);+ bottom: 36px;+ text-align: center;+ padding: 4px 8px;+ border-radius: 2px;+ opacity: 0;+ pointer-events: none;+}++.label:hover::after {+ opacity: 1;+}diff --git a/src/player/Controls.ts b/src/player/Controls.tsindex 60aaf3c7..12611527 100644--- a/src/player/Controls.ts+++ b/src/player/Controls.ts@@ -4,8 +4,6 @@ export class Controls {private play: HTMLInputElement;private loop: HTMLInputElement;private audio: HTMLInputElement;- private from: HTMLInputElement;- private current: HTMLInputElement;private speed: HTMLInputElement;private fps: HTMLInputElement;private loadingIndicator: HTMLElement;@@ -21,8 +19,6 @@ export class Controls {this.play = form.play;this.loop = form.loop;this.audio = form.audio;- this.from = form.from;- this.current = form.current;this.speed = form.speed;this.fps = form.fps;this.loadingIndicator = document.getElementById('loading');@@ -36,9 +32,6 @@ export class Controls {this.audio.addEventListener('change', () =>this.player.toggleAudio(this.audio.checked),);- this.from.addEventListener('change', () =>- this.player.updateState({startFrame: parseInt(this.from.value)}),- );this.speed.addEventListener('change', () =>this.player.updateState({speed: parseFloat(this.speed.value)}),);@@ -47,10 +40,6 @@ export class Controls {form.next.addEventListener('click', () => this.player.requestNextFrame());form.render.addEventListener('click', () => this.player.toggleRendering());- this.current.addEventListener('click', () =>- this.player.updateState({startFrame: parseInt(this.current.value)}),- );-document.addEventListener('keydown', event => {switch (event.key) {case ' ':@@ -86,8 +75,6 @@ export class Controls {this.play.checked = !state.paused;this.loop.checked = state.loop;this.audio.checked = !state.muted;- this.from.value = state.startFrame.toString();- this.current.value = state.frame.toString();this.speed.value = state.speed.toString();this.loadingIndicator.hidden = !state.loading;};@@ -107,7 +94,6 @@ export class Controls {const average = this.overallTime / this.updateTimes.length;this.fps.value = Math.floor(1000 / average).toString();- this.current.value = Math.floor(frame).toString();this.lastUpdate = performance.now();}diff --git a/src/player/Navigator.ts b/src/player/Navigator.tsnew file mode 100644index 00000000..6eff7502--- /dev/null+++ b/src/player/Navigator.ts@@ -0,0 +1,83 @@+const ZOOM_SPEED = 0.05;++export class Navigator {+ private scale = 1;+ private isPanning = false;+ private startPosition = {x: 0, y: 0};+ private panStartPosition = {x: 0, y: 0};+ private position = {x: 0, y: 0};++ public constructor(private readonly root: HTMLElement) {+ document.addEventListener('wheel', this.handleWheel);+ document.addEventListener('mousedown', this.handleMouseDown);+ document.addEventListener('mouseup', this.handleMouseUp);+ document.addEventListener('mousemove', this.handleMouseMove);++ document.addEventListener('keydown', event => {+ switch (event.key) {+ case '0':+ this.scale = 1;+ this.position = {x: 0, y: 0};+ this.update();+ break;+ case '=':+ this.scale *= 1 + ZOOM_SPEED;+ this.update();+ break;+ case '-':+ this.scale *= 1 - ZOOM_SPEED;+ this.update();+ break;+ }+ });+ }++ private handleWheel = (event: WheelEvent) => {+ if (this.isPanning) return;++ const pointer = {+ x: event.x - document.body.offsetWidth / 2,+ y: event.y - document.body.offsetHeight / 2,+ };++ const ratio = 1 - Math.sign(event.deltaY) * ZOOM_SPEED;+ this.scale *= ratio;++ this.position = {+ x: pointer.x + (this.position.x - pointer.x) * ratio,+ y: pointer.y + (this.position.y - pointer.y) * ratio,+ };++ this.update();+ };++ private handleMouseDown = (event: MouseEvent) => {+ if (event.button === 1) {+ event.preventDefault();+ this.isPanning = true;+ this.startPosition = {...this.position};+ this.panStartPosition = {x: event.x, y: event.y};+ }+ };++ private handleMouseUp = (event: MouseEvent) => {+ if (event.button === 1) {+ event.preventDefault();+ this.isPanning = false;+ }+ };++ private handleMouseMove = (event: MouseEvent) => {+ if (this.isPanning) {+ this.position = {+ x: this.startPosition.x - this.panStartPosition.x + event.x,+ y: this.startPosition.y - this.panStartPosition.y + event.y,+ };+ this.update();+ }+ };++ private update() {+ this.root.style.transform = `translate(${this.position.x}px, ${this.position.y}px) scale(${this.scale})`;+ }+}diff --git a/src/player/Player.ts b/src/player/Player.tsindex e79aca34..aa69d02d 100644--- a/src/player/Player.ts+++ b/src/player/Player.ts@@ -230,6 +230,9 @@ export class Player {// handle finishingif (state.finished) {state.duration = this.project.frame;+ if (commands.seek >= 0) {+ this.requestSeek(state.startFrame);+ }}this.updateState({@@ -257,9 +260,9 @@ export class Player {private request() {requestAnimationFrame(async () => {try {- this.updateState({loading: true});+ // this.updateState({loading: true});await this.run();- this.updateState({loading: false});+ // this.updateState({loading: false});} catch (e) {console.error(e);}diff --git a/src/player/Timeline.ts b/src/player/Timeline.tsindex baf7c705..97d1c2bc 100644--- a/src/player/Timeline.ts+++ b/src/player/Timeline.ts@@ -1,5 +1,6 @@import {clampRemap} from '../tweening';import {Player, PlayerState} from './Player';+import {clamp} from 'three/src/math/MathUtils';export class Timeline {private readonly fillTime: HTMLElement;@@ -7,9 +8,12 @@ export class Timeline {private readonly fillStart: HTMLElement;private readonly track: HTMLElement;private readonly marker: HTMLElement;+ private readonly timeText: HTMLElement;+ private readonly durationText: HTMLElement;private duration: number;private labelElements: Record<string, HTMLElement> = {};+ private lastState: PlayerState;public constructor(private readonly player: Player,@@ -19,19 +23,21 @@ export class Timeline {this.fillTime = root.querySelector('.fill-time')!;this.fillSeek = root.querySelector('.fill-seek')!;this.fillStart = root.querySelector('.fill-start')!;+ this.timeText = root.querySelector('.js-current-time')!;+ this.durationText = root.querySelector('.js-duration')!;this.track = root.querySelector('.track')!;this.marker = root.querySelector('.marker')!;- this.fillSeek.style.opacity = '0';-this.player.StateChanged.sub(this.update);this.root.addEventListener('click', e => {const target = <HTMLElement>e.target;+ if (target === this.timeText) {+ this.player.updateState({startFrame: this.lastState.frame});+ return;+ }this.player.requestSeek(target.classList.contains('label')- ? this.player.project.secondsToFrames(- parseFloat(target.dataset.time!),- )+ ? parseFloat(target.dataset.time!): this.mousePositionToFrame(e.clientX),);});@@ -42,23 +48,25 @@ export class Timeline {});});this.root.addEventListener('mousemove', e => {+ const target = <HTMLElement>e.target;const rect = this.track.getBoundingClientRect();- const x = e.clientX - rect.left;+ let x = clamp(e.clientX - rect.left, 8, rect.width);++ if (target.classList.contains('label')) {+ const frame = parseInt(target.dataset.time!);+ x = (frame / this.duration) * rect.width;+ }this.fillSeek.style.width = `${x}px`;});- this.root.addEventListener('mouseleave', () => {- this.fillSeek.style.opacity = '0';- });- this.root.addEventListener('mouseenter', () => {- this.fillSeek.style.opacity = '0.32';- });for (const label in labels) {const element = document.createElement('div');element.classList.add('label');element.dataset.title = label;- element.dataset.time = labels[label].toString();- root.appendChild(element);+ element.dataset.time = this.player.project+ .secondsToFrames(labels[label])+ .toString();+ this.track.appendChild(element);this.labelElements[label] = element;}}@@ -70,7 +78,10 @@ export class Timeline {}private update = (state: PlayerState) => {- this.duration = state.duration;+ this.lastState = {...state};+ this.timeText.innerText = state.frame.toString();+ this.marker.dataset.title = `Frame:${state.startFrame}`;+const width = this.track.clientWidth;const fillWidth = clampRemap(1, state.duration, 8, width, state.frame);const startWidth = clampRemap(@@ -80,26 +91,20 @@ export class Timeline {width,state.startFrame,);- const left =- clampRemap(1, state.duration, 0, width - 8, state.startFrame) + 16;- this.marker.style.left = `${left}px`;- this.fillTime.style.width = `${fillWidth}px`;+ this.marker.style.left = `${startWidth - 8}px`;this.fillStart.style.width = `${startWidth}px`;+ this.fillTime.style.width = `${fillWidth}px`;+ this.durationText.innerText = state.duration.toString();+ this.duration = state.duration;for (const label in this.labels) {const element = this.labelElements[label];- const elementFrame = this.player.project.secondsToFrames(- this.labels[label],- );- const elementLeft = clampRemap(- 1,- state.duration,- 0,- width - 8,- elementFrame,- );- element.style.left = `${elementLeft}px`;+ const time = parseInt(element.dataset.time);+ const elementLeft = clampRemap(1, state.duration, 8, width, time) - 4;+ element.style.left = `${elementLeft - 20}px`;+ element.classList.toggle('hidden', time > state.duration);+ element.classList.toggle('inverted', time > state.startFrame);}};}diff --git a/src/utils/index.ts b/src/utils/index.tsindex 2d090d0c..eeda101a 100644--- a/src/utils/index.ts+++ b/src/utils/index.ts@@ -1 +1,2 @@-export * from './pop';\ No newline at end of file+export * from './pop';+export * from './useRef';diff --git a/src/utils/useRef.ts b/src/utils/useRef.tsnew file mode 100644index 00000000..3afec8d1--- /dev/null+++ b/src/utils/useRef.ts@@ -0,0 +1,5 @@+import type {Node} from 'konva/lib/Node';++export function useRef<T extends Node>(): {value: T} {+ return {value: null};+}