MCPcopy Create free account
hub / github.com/microsoft/SandDance / _finalizeElementPosition

Function _finalizeElementPosition

docs/app/js/sanddance-app.js:31978–31988  ·  view source on GitHub ↗

* Finalizes the element positon based on the hostElement. Only returns the * rectangle values to position such that they are anchored to the target. * This helps prevent resizing from looking very strange. * For instance, if the target edge is top and aligned with the left side then * the bottom

(elementRectangle, hostElement, targetEdge, bounds, alignmentEdge, coverTarget, doNotFinalizeReturnEdge)

Source from the content-addressed store, hash-verified

31976 * For instance, if the target edge is top and aligned with the left side then
31977 * the bottom and left values are returned so as the callou shrinks it shrinks towards that corner.
31978 */ function _finalizeElementPosition(elementRectangle, hostElement, targetEdge, bounds, alignmentEdge, coverTarget, doNotFinalizeReturnEdge) {
31979 var returnValue = {};
31980 var hostRect = _getRectangleFromElement(hostElement);
31981 var elementEdge = coverTarget ? targetEdge : targetEdge * -1;
31982 var elementEdgeString = (0, _positioningTypes.RectangleEdge)[elementEdge];
31983 var returnEdge = alignmentEdge ? alignmentEdge : _getFlankingEdges(targetEdge).positiveEdge;
31984 if (!doNotFinalizeReturnEdge) returnEdge = _finalizeReturnEdge(elementRectangle, returnEdge, bounds);
31985 returnValue[elementEdgeString] = _getRelativeEdgeDifference(elementRectangle, hostRect, elementEdge);
31986 returnValue[(0, _positioningTypes.RectangleEdge)[returnEdge]] = _getRelativeEdgeDifference(elementRectangle, hostRect, returnEdge);
31987 return returnValue;
31988}
31989// Since the beak is rotated 45 degrees the actual height/width is the length of the diagonal.
31990// We still want to position the beak based on it's midpoint which does not change. It will
31991// be at (beakwidth / 2, beakwidth / 2)

Callers 1

_finalizePositionDataFunction · 0.85

Calls 4

_getRectangleFromElementFunction · 0.85
_getFlankingEdgesFunction · 0.85
_finalizeReturnEdgeFunction · 0.85

Tested by

no test coverage detected