Skip to content
GitLab
Explore
Projects
Groups
Snippets
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
2c41b0ae
Commit
2c41b0ae
authored
7 years ago
by
Johann-S
Browse files
Options
Download
Email Patches
Plain Diff
fix get the transition duration parent
parent
1fadad1c
3 merge requests
!28721
Hot test
,
!27561
Adds font-weight-medium to font weight classes
,
!17021
v4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
js/src/util.js
+6
-3
js/src/util.js
js/tests/unit/util.js
+5
-14
js/tests/unit/util.js
with
11 additions
and
17 deletions
+11
-17
js/src/util.js
+
6
-
3
View file @
2c41b0ae
...
...
@@ -106,19 +106,22 @@ const Util = (($) => {
},
getTransitionDurationFromElement
(
element
)
{
if
(
!
element
)
{
return
0
}
// Get transition-duration of the element
let
transitionDuration
=
$
(
element
).
css
(
'
transition-duration
'
)
const
floatTransitionDuration
=
parseFloat
(
transitionDuration
)
// Return 0 if element or transition duration is not found
if
(
!
t
ransitionDuration
)
{
if
(
!
floatT
ransitionDuration
)
{
return
0
}
// If multiple durations are defined, take the first
transitionDuration
=
transitionDuration
.
split
(
'
,
'
)[
0
]
// jQuery always converts transition durations into seconds,
// so multiply by 1000
return
parseFloat
(
transitionDuration
)
*
MILLISECONDS_MULTIPLIER
},
...
...
This diff is collapsed.
Click to expand it.
js/tests/unit/util.js
+
5
-
14
View file @
2c41b0ae
...
...
@@ -46,44 +46,35 @@ $(function () {
assert
.
expect
(
1
)
var
$div
=
$
(
'
<div style="transition: all 300ms ease-out;"></div>
'
).
appendTo
(
$
(
'
#qunit-fixture
'
))
assert
.
strictEqual
(
Util
.
getTransitionDurationFromElement
(
$div
),
300
)
assert
.
strictEqual
(
Util
.
getTransitionDurationFromElement
(
$div
[
0
]
),
300
)
})
QUnit
.
test
(
'
Util.getTransitionDurationFromElement should accept transition durations in seconds
'
,
function
(
assert
)
{
assert
.
expect
(
1
)
var
$div
=
$
(
'
<div style="transition: all .4s ease-out;"></div>
'
).
appendTo
(
$
(
'
#qunit-fixture
'
))
assert
.
strictEqual
(
Util
.
getTransitionDurationFromElement
(
$div
),
400
)
assert
.
strictEqual
(
Util
.
getTransitionDurationFromElement
(
$div
[
0
]
),
400
)
})
QUnit
.
test
(
'
Util.getTransitionDurationFromElement should get the first transition duration if multiple transition durations are defined
'
,
function
(
assert
)
{
assert
.
expect
(
1
)
var
$div
=
$
(
'
<div style="transition: transform .3s ease-out, opacity .2s;"></div>
'
).
appendTo
(
$
(
'
#qunit-fixture
'
))
assert
.
strictEqual
(
Util
.
getTransitionDurationFromElement
(
$div
),
300
)
assert
.
strictEqual
(
Util
.
getTransitionDurationFromElement
(
$div
[
0
]
),
300
)
})
QUnit
.
test
(
'
Util.getTransitionDurationFromElement should return 0 if transition duration is not defined
'
,
function
(
assert
)
{
assert
.
expect
(
1
)
var
$div
=
$
(
'
<div></div>
'
).
appendTo
(
$
(
'
#qunit-fixture
'
))
assert
.
strictEqual
(
Util
.
getTransitionDurationFromElement
(
$div
),
0
)
assert
.
strictEqual
(
Util
.
getTransitionDurationFromElement
(
$div
[
0
]
),
0
)
})
QUnit
.
test
(
'
Util.getTransitionDurationFromElement should return 0 if element is not found in DOM
'
,
function
(
assert
)
{
assert
.
expect
(
1
)
var
$div
=
$
(
'
#fake-id
'
)
assert
.
strictEqual
(
Util
.
getTransitionDurationFromElement
(
$div
),
0
)
})
QUnit
.
test
(
'
Util.getTransitionDurationFromElement should properly handle inherited transition durations
'
,
function
(
assert
)
{
assert
.
expect
(
1
)
var
$parent
=
$
(
'
<div style="transition-duration: 5s;"></div>
'
)
var
$child
=
$
(
'
<div style="transition-duration: inherit;"></div>
'
)
$
(
'
#qunit-fixture
'
).
append
(
$parent
.
append
(
$child
))
assert
.
strictEqual
(
Util
.
getTransitionDurationFromElement
(
$child
),
5000
)
assert
.
strictEqual
(
Util
.
getTransitionDurationFromElement
(
$div
[
0
]),
0
)
})
QUnit
.
test
(
'
Util.getUID should generate a new id uniq
'
,
function
(
assert
)
{
...
...
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
Menu
Explore
Projects
Groups
Snippets