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

View2D edge accessors are not in proper space #881

Open
hhenrichsen opened this issue Dec 22, 2023 · 1 comment
Open

View2D edge accessors are not in proper space #881

hhenrichsen opened this issue Dec 22, 2023 · 1 comment
Labels
a-2d Relates to the 2d package b-bug Something isn't working c-discussion The issue is being discussed

Comments

@hhenrichsen
Copy link
Contributor

hhenrichsen commented Dec 22, 2023

Describe the bug

View2D's edge accessors (left, right, top, bottom, etc.) return components in absolute coordinates rather than more usable View2D space.

To Reproduce

import { Rect, makeScene2D } from "@motion-canvas/2d";

export default makeScene2D(function* (view) {
  view.add(<Rect left={view.left} size={100} fill="green" />);
});

image
Hmm yes this is certainly aligned with something.

Expected behavior

Shapes referring to the view's edge accessors should appear relative to the view. Currently, absolutePosition must be used instead (node().absolutePosition(view.left)).

Package versions:

  • core: 3.11.0
  • two: 3.11.0
  • ui: 3.11.0
  • vitePlugin: 3.11.0
@hhenrichsen hhenrichsen added the b-bug Something isn't working label Dec 22, 2023
@aarthificial
Copy link
Contributor

Cardinal points in general operate in the parent space. This is meant to mirror how position works.
They sort of answer the question: if I wanted to put a sibling of this node over its left/right/etc edge, what position would that be?
View2D is always the root node so its parent space just happens to be the absolute canvas space.

Here, the question is more: if I wanted to put a child of this node over its left edge, what position would that be?
This can already be achieved with getOriginDelta (admittedly a bit more verbose),

export default makeScene2D(function* (view) {
  view.add(
    <Rect left={view.getOriginDelta(Origin.Left)} size={100} fill="green" />,
  );
});

I don't think changing the implementation of View2D specifically would be a good solution here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a-2d Relates to the 2d package b-bug Something isn't working c-discussion The issue is being discussed
Projects
None yet
Development

No branches or pull requests

2 participants