-
Notifications
You must be signed in to change notification settings - Fork 137
Open
Labels
BugSoftware defects or other problems that should be fixed.Software defects or other problems that should be fixed.
Description
Powertip's isMouseOver function does not properly calculate the height of SVG elements, which causes it to determine that the mouse is not over an object when it really is.
The reason for this is that getBoundingClientRect does not include the height of stroke-width in its calculation. I fixed this with the following monkey-hack:
function isMouseOver(element) {
// use getBoundingClientRect() because jQuery's width() and height()
// methods do not work with SVG elements
// compute width/height because those properties do not exist on the object
// returned by getBoundingClientRect() in older versions of IE
var elementPosition = element.offset(),
elementBox = element[0].getBoundingClientRect(),
elementWidth = elementBox.right - elementBox.left,
elementHeight = elementBox.bottom - elementBox.top;
// Add stroke width to paths
var (element[0].tagName == 'path') {
var stroke = window.getComputedStyle(element[0])
.getPropertyValue("stroke-width");
if (stroke && stroke.length && parseFloat(stroke) > 0) {
elementHeight += parseFloat(stroke)
}
}
return session.currentX >= elementPosition.left &&
session.currentX <= elementPosition.left + elementWidth &&
session.currentY >= elementPosition.top &&
session.currentY <= elementPosition.top + elementHeight;
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugSoftware defects or other problems that should be fixed.Software defects or other problems that should be fixed.