Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Bootstrap
bootstrap
Commits
24ae068f
Commit
24ae068f
authored
10 years ago
by
Heinrich Fenkart
Browse files
Options
Download
Email Patches
Plain Diff
Tooltip: Rely on `getBoundingClientRect` for `width` and `height`
Fixes
#14553
.
parent
e70fc61e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
js/tests/unit/tooltip.js
+38
-0
js/tests/unit/tooltip.js
js/tooltip.js
+1
-5
js/tooltip.js
with
39 additions
and
5 deletions
+39
-5
js/tests/unit/tooltip.js
+
38
-
0
View file @
24ae068f
...
...
@@ -919,4 +919,42 @@ $(function () {
.
bootstrapTooltip
(
'
show
'
)
})
test
(
'
should correctly position tooltips on transformed elements
'
,
function
()
{
var
styleProps
=
document
.
documentElement
.
style
if
(
!
(
'
transform
'
in
styleProps
)
&&
!
(
'
webkitTransform
'
in
styleProps
)
&&
!
(
'
msTransform
'
in
styleProps
))
{
expect
(
0
)
return
}
stop
()
var
styles
=
'
<style>
'
+
'
#qunit-fixture { top: 0; left: 0; }
'
+
'
.tooltip, .tooltip *, .tooltip *:before, .tooltip *:after { box-sizing: border-box; }
'
+
'
.tooltip { position: absolute; }
'
+
'
.tooltip .tooltip-inner { width: 24px; height: 24px; font-family: Helvetica; }
'
+
'
#target { position: absolute; top: 100px; left: 50px; width: 100px; height: 200px; -webkit-transform: rotate(270deg); -ms-transform: rotate(270deg); transform: rotate(270deg); }
'
+
'
</style>
'
var
$styles
=
$
(
styles
).
appendTo
(
'
head
'
)
var
$element
=
$
(
'
<div id="target" title="1"/>
'
).
appendTo
(
'
#qunit-fixture
'
)
$element
.
on
(
'
shown.bs.tooltip
'
,
function
()
{
var
offset
=
$
(
'
.tooltip
'
).
offset
()
$styles
.
remove
()
ok
(
Math
.
abs
(
offset
.
left
-
88
)
<=
1
,
'
tooltip has correct horizontal location
'
)
ok
(
Math
.
abs
(
offset
.
top
-
126
)
<=
1
,
'
tooltip has correct vertical location
'
)
$element
.
bootstrapTooltip
(
'
hide
'
)
start
()
})
.
bootstrapTooltip
({
container
:
'
body
'
,
placement
:
'
top
'
,
trigger
:
'
manual
'
})
$element
.
bootstrapTooltip
(
'
show
'
)
})
})
This diff is collapsed.
Click to expand it.
js/tooltip.js
+
1
-
5
View file @
24ae068f
...
...
@@ -329,7 +329,6 @@
var
el
=
$element
[
0
]
var
isBody
=
el
.
tagName
==
'
BODY
'
var
isSvg
=
window
.
SVGElement
&&
el
instanceof
window
.
SVGElement
var
elRect
=
el
.
getBoundingClientRect
()
if
(
elRect
.
width
==
null
)
{
...
...
@@ -338,10 +337,7 @@
}
var
elOffset
=
isBody
?
{
top
:
0
,
left
:
0
}
:
$element
.
offset
()
var
scroll
=
{
scroll
:
isBody
?
document
.
documentElement
.
scrollTop
||
document
.
body
.
scrollTop
:
$element
.
scrollTop
()
}
var
outerDims
=
isSvg
?
{}
:
{
width
:
isBody
?
$
(
window
).
width
()
:
$element
.
outerWidth
(),
height
:
isBody
?
$
(
window
).
height
()
:
$element
.
outerHeight
()
}
var
outerDims
=
isBody
?
{
width
:
$
(
window
).
width
(),
height
:
$
(
window
).
height
()
}
:
null
return
$
.
extend
({},
elRect
,
scroll
,
outerDims
,
elOffset
)
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment