You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
The text was updated successfully, but these errors were encountered:
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?
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?
The text was updated successfully, but these errors were encountered: