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

Function _getTargetRect

docs/app/js/sanddance-app.js:32080–32108  ·  view source on GitHub ↗
(bounds, target)

Source from the content-addressed store, hash-verified

32078 return new (0, _utilities.Rectangle)(rect.left, rect.right, rect.top, rect.bottom);
32079}
32080function _getTargetRect(bounds, target) {
32081 var targetRectangle;
32082 if (target) {
32083 // eslint-disable-next-line no-extra-boolean-cast
32084 if (!!target.preventDefault) {
32085 var ev = target;
32086 targetRectangle = new (0, _utilities.Rectangle)(ev.clientX, ev.clientX, ev.clientY, ev.clientY);
32087 // eslint-disable-next-line no-extra-boolean-cast
32088 } else if (!!target.getBoundingClientRect) targetRectangle = _getRectangleFromElement(target);
32089 else {
32090 var rectOrPoint = target;
32091 // eslint-disable-next-line deprecation/deprecation
32092 var left = rectOrPoint.left || rectOrPoint.x;
32093 // eslint-disable-next-line deprecation/deprecation
32094 var top_1 = rectOrPoint.top || rectOrPoint.y;
32095 var right = rectOrPoint.right || left;
32096 var bottom = rectOrPoint.bottom || top_1;
32097 targetRectangle = new (0, _utilities.Rectangle)(left, right, top_1, bottom);
32098 }
32099 if (!_isRectangleWithinBounds(targetRectangle, bounds)) {
32100 var outOfBounds = _getOutOfBoundsEdges(targetRectangle, bounds);
32101 for(var _i = 0, outOfBounds_1 = outOfBounds; _i < outOfBounds_1.length; _i++){
32102 var direction = outOfBounds_1[_i];
32103 targetRectangle[(0, _positioningTypes.RectangleEdge)[direction]] = bounds[(0, _positioningTypes.RectangleEdge)[direction]];
32104 }
32105 }
32106 } else targetRectangle = new (0, _utilities.Rectangle)(0, 0, 0, 0);
32107 return targetRectangle;
32108}
32109/**
32110 * If max height is less than zero it returns the bounds height instead.
32111 */ function _getMaxHeightFromTargetRectangle(targetRectangle, targetEdge, gapSpace, bounds, coverTarget) {

Callers 1

_positionElementRelativeFunction · 0.85

Calls 3

_getRectangleFromElementFunction · 0.85
_isRectangleWithinBoundsFunction · 0.85
_getOutOfBoundsEdgesFunction · 0.85

Tested by

no test coverage detected