Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ui): add number input dragging #917

Merged
merged 5 commits into from
Jan 12, 2024

Conversation

jmaen
Copy link
Contributor

@jmaen jmaen commented Jan 11, 2024

Add a new NumberInput component that supports dragging to edit numbers. When hovering over the input, the cursor is a left-right arrow to indicate the dragging option. For the dragging behavior, the PointerLock API is used.

In order to edit the value manually via keyboard input, users can click the component without dragging. Dragging is then disabled and the cursor switches to a regular text cursor, allowing text selection. Up and down arrow keys are also supported through the regular <input type="number"/> element.

The new NumberInput also supports min, max and step properties for input via the arrow keys and via dragging.

Closes #799

input-dragging.mov

Copy link
Contributor

@aarthificial aarthificial left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should add the following handler to the input as well:

onKeyDown={event => {
  if (event.key === 'Enter') {
    inputRef.current.blur();
  }
  if (event.key === 'Escape') {
    inputRef.current.value = currentValue.toString();
    inputRef.current.blur();
  }
}}

packages/ui/src/components/controls/NumberInput.tsx Outdated Show resolved Hide resolved
packages/ui/src/components/controls/NumberInput.tsx Outdated Show resolved Hide resolved
packages/ui/src/components/controls/NumberInput.tsx Outdated Show resolved Hide resolved
packages/ui/src/components/controls/NumberInput.tsx Outdated Show resolved Hide resolved
packages/ui/src/components/controls/NumberInputSelect.tsx Outdated Show resolved Hide resolved
packages/ui/src/components/controls/NumberInput.tsx Outdated Show resolved Hide resolved
jmaen and others added 2 commits January 11, 2024 17:36
Co-authored-by: Jacob <64662184+aarthificial@users.noreply.github.com>
@jmaen
Copy link
Contributor Author

jmaen commented Jan 11, 2024

I think I adressed all your requested changes. Apparently the pipeline failed to build, but the error seems to have occured in core which is not something I worked on.

@aarthificial aarthificial merged commit 1b5c232 into motion-canvas:main Jan 12, 2024
9 checks passed
@aarthificial
Copy link
Contributor

Awesome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dragging MetaFieldView Input
2 participants