add null check to back drop element - fix js errors
This commit is contained in:
@@ -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();
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user