Created
June 7, 2012 04:42
-
-
Save inferiorhumanorgans/2886616 to your computer and use it in GitHub Desktop.
Fix popover positioning on SVG elements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/vendor/assets/javascripts/twitter/bootstrap.js b/vendor/assets/javascripts/twitter/bootstrap.js | |
index 6479673..9497ed4 100644 | |
--- a/vendor/assets/javascripts/twitter/bootstrap.js | |
+++ b/vendor/assets/javascripts/twitter/bootstrap.js | |
@@ -961,6 +961,14 @@ | |
actualWidth = $tip[0].offsetWidth | |
actualHeight = $tip[0].offsetHeight | |
+ if ((typeof(pos.height) == 'undefined') || (pos.height == 0)) { | |
+ pos.height = this.$element.attr('height') | |
+ } | |
+ | |
+ if ((typeof(pos.width) == 'undefined') || (pos.width == 0)) { | |
+ pos.width = this.$element.attr('width'); | |
+ } | |
+ | |
switch (inside ? placement.split(' ')[1] : placement) { | |
case 'bottom': | |
tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2} |
How didn't it work for you?
The gist works for me with the following caveats:
- I'm using the svgdom jquery plugin
- I'm specifying the x and y attributes on the SVG element explicitly
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Didn't work for me. http://stackoverflow.com/questions/10727892/how-to-center-the-bootstrap-tooltip-on-an-svg was helpful: