diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/application/umbbackdrop.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/application/umbbackdrop.directive.js index 128f54f3af..7139cd5682 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/application/umbbackdrop.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/application/umbbackdrop.directive.js @@ -28,27 +28,32 @@ // The element to highlight var highlightElement = angular.element(scope.element); - var offset = highlightElement.offset(); - var width = highlightElement.outerWidth(true); - var height = highlightElement.outerHeight(true); - // Rounding numbers - var topDistance = offset.top.toFixed(); - var topAndHeight = (offset.top + height).toFixed(); - var leftDistance = offset.left.toFixed(); - var leftAndWidth = (offset.left + width).toFixed(); + if(highlightElement) { - // The four rectangles - var rectTop = el.find(".umb-backdrop__rect--top"); - var rectRight = el.find(".umb-backdrop__rect--right"); - var rectBottom = el.find(".umb-backdrop__rect--bottom"); - var rectLeft = el.find(".umb-backdrop__rect--left"); - - // Add the css - rectTop.css({ "height": topDistance, "x": leftDistance }); - rectRight.css({ "x": leftAndWidth, "y": topDistance, "height": height }); - rectBottom.css({ "height": "100%", "y": topAndHeight, "x": leftDistance }); - rectLeft.css({ "width": leftDistance }); + var offset = highlightElement.offset(); + var width = highlightElement.outerWidth(true); + var height = highlightElement.outerHeight(true); + + // Rounding numbers + var topDistance = offset.top.toFixed(); + var topAndHeight = (offset.top + height).toFixed(); + var leftDistance = offset.left.toFixed(); + var leftAndWidth = (offset.left + width).toFixed(); + + // The four rectangles + var rectTop = el.find(".umb-backdrop__rect--top"); + var rectRight = el.find(".umb-backdrop__rect--right"); + var rectBottom = el.find(".umb-backdrop__rect--bottom"); + var rectLeft = el.find(".umb-backdrop__rect--left"); + + // Add the css + rectTop.css({ "height": topDistance, "x": leftDistance }); + rectRight.css({ "x": leftAndWidth, "y": topDistance, "height": height }); + rectBottom.css({ "height": "100%", "y": topAndHeight, "x": leftDistance }); + rectLeft.css({ "width": leftDistance }); + + } }); @@ -59,6 +64,7 @@ } events.push(scope.$watch("element", function (newValue, oldValue) { + if(!newValue) {return;} if(newValue === oldValue) {return;} setHighlight(); }));