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

More points other than top, bottom, left, and right? #118

Open
Velcro1 opened this issue Oct 7, 2020 · 1 comment
Open

More points other than top, bottom, left, and right? #118

Velcro1 opened this issue Oct 7, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@Velcro1
Copy link

Velcro1 commented Oct 7, 2020

Hey Pierpo,

I see in the code you can only point top, bottom, left, and right.
Couldn't you add a top-left, top-right, bottom-left, and bottom-right?

function computeCoordinatesFromAnchorPosition(
anchorPosition: AnchorPositionType,
rect: ClientRect,
): Point {
switch (anchorPosition) {
case 'top':
return rectToPoint(rect).add(new Point(rect.width / 2, 0));
case 'bottom':
return rectToPoint(rect).add(new Point(rect.width / 2, rect.height));
case 'left':
return rectToPoint(rect).add(new Point(0, rect.height / 2));
case 'right':
return rectToPoint(rect).add(new Point(rect.width, rect.height / 2));
case 'middle':
return rectToPoint(rect).add(new Point(rect.width / 2, rect.height / 2));
default:
return new Point(0, 0);
}
}

So just add a case for the new positions?
case 'top-left':
return rectToPoint(rect).add(new Point(rect.width - rect.width, 0));
case 'top-right':
return rectToPoint(rect).add(new Point(rect.width, 0));

then do the same for the bottom?

@pierpo
Copy link
Owner

pierpo commented Oct 9, 2020

Hi!

That would be great indeed 😊
You can open a PR if you want, it shouldn't be too hard indeed 😊

If you don't, I'll do it eventually but I can't give an ETA!

Thanks 😉

@pierpo pierpo added the enhancement New feature or request label Oct 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants