mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-14 09:34:36 +02:00
Use transitionEnd in QUnit since we moved away from PhantomJS
This commit is contained in:
@@ -102,8 +102,7 @@ const Alert = (($) => {
|
||||
_removeElement(element) {
|
||||
$(element).removeClass(ClassName.SHOW)
|
||||
|
||||
if (!Util.supportsTransitionEnd() ||
|
||||
!$(element).hasClass(ClassName.FADE)) {
|
||||
if (!$(element).hasClass(ClassName.FADE)) {
|
||||
this._destroyElement(element)
|
||||
return
|
||||
}
|
||||
|
@@ -142,8 +142,7 @@ const Carousel = (($) => {
|
||||
this._isPaused = true
|
||||
}
|
||||
|
||||
if ($(this._element).find(Selector.NEXT_PREV)[0] &&
|
||||
Util.supportsTransitionEnd()) {
|
||||
if ($(this._element).find(Selector.NEXT_PREV)[0]) {
|
||||
Util.triggerTransitionEnd(this._element)
|
||||
this.cycle(true)
|
||||
}
|
||||
@@ -376,8 +375,7 @@ const Carousel = (($) => {
|
||||
to: nextElementIndex
|
||||
})
|
||||
|
||||
if (Util.supportsTransitionEnd() &&
|
||||
$(this._element).hasClass(ClassName.SLIDE)) {
|
||||
if ($(this._element).hasClass(ClassName.SLIDE)) {
|
||||
$(nextElement).addClass(orderClassName)
|
||||
|
||||
Util.reflow(nextElement)
|
||||
|
@@ -182,11 +182,6 @@ const Collapse = (($) => {
|
||||
$(this._element).trigger(Event.SHOWN)
|
||||
}
|
||||
|
||||
if (!Util.supportsTransitionEnd()) {
|
||||
complete()
|
||||
return
|
||||
}
|
||||
|
||||
const capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1)
|
||||
const scrollSize = `scroll${capitalizedDimension}`
|
||||
const transitionDuration = Util.getTransitionDurationFromElement(this._element)
|
||||
@@ -246,12 +241,6 @@ const Collapse = (($) => {
|
||||
}
|
||||
|
||||
this._element.style[dimension] = ''
|
||||
|
||||
if (!Util.supportsTransitionEnd()) {
|
||||
complete()
|
||||
return
|
||||
}
|
||||
|
||||
const transitionDuration = Util.getTransitionDurationFromElement(this._element)
|
||||
|
||||
$(this._element)
|
||||
|
@@ -107,7 +107,7 @@ const Modal = (($) => {
|
||||
return
|
||||
}
|
||||
|
||||
if (Util.supportsTransitionEnd() && $(this._element).hasClass(ClassName.FADE)) {
|
||||
if ($(this._element).hasClass(ClassName.FADE)) {
|
||||
this._isTransitioning = true
|
||||
}
|
||||
|
||||
@@ -168,8 +168,7 @@ const Modal = (($) => {
|
||||
}
|
||||
|
||||
this._isShown = false
|
||||
|
||||
const transition = Util.supportsTransitionEnd() && $(this._element).hasClass(ClassName.FADE)
|
||||
const transition = $(this._element).hasClass(ClassName.FADE)
|
||||
|
||||
if (transition) {
|
||||
this._isTransitioning = true
|
||||
@@ -228,8 +227,7 @@ const Modal = (($) => {
|
||||
}
|
||||
|
||||
_showElement(relatedTarget) {
|
||||
const transition = Util.supportsTransitionEnd() &&
|
||||
$(this._element).hasClass(ClassName.FADE)
|
||||
const transition = $(this._element).hasClass(ClassName.FADE)
|
||||
|
||||
if (!this._element.parentNode ||
|
||||
this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
|
||||
@@ -331,8 +329,6 @@ const Modal = (($) => {
|
||||
? ClassName.FADE : ''
|
||||
|
||||
if (this._isShown && this._config.backdrop) {
|
||||
const doAnimate = Util.supportsTransitionEnd() && animate
|
||||
|
||||
this._backdrop = document.createElement('div')
|
||||
this._backdrop.className = ClassName.BACKDROP
|
||||
|
||||
@@ -357,7 +353,7 @@ const Modal = (($) => {
|
||||
}
|
||||
})
|
||||
|
||||
if (doAnimate) {
|
||||
if (animate) {
|
||||
Util.reflow(this._backdrop)
|
||||
}
|
||||
|
||||
@@ -367,7 +363,7 @@ const Modal = (($) => {
|
||||
return
|
||||
}
|
||||
|
||||
if (!doAnimate) {
|
||||
if (!animate) {
|
||||
callback()
|
||||
return
|
||||
}
|
||||
@@ -387,8 +383,7 @@ const Modal = (($) => {
|
||||
}
|
||||
}
|
||||
|
||||
if (Util.supportsTransitionEnd() &&
|
||||
$(this._element).hasClass(ClassName.FADE)) {
|
||||
if ($(this._element).hasClass(ClassName.FADE)) {
|
||||
const backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop)
|
||||
|
||||
$(this._backdrop)
|
||||
|
@@ -151,7 +151,6 @@ const Tab = (($) => {
|
||||
|
||||
const active = activeElements[0]
|
||||
const isTransitioning = callback &&
|
||||
Util.supportsTransitionEnd() &&
|
||||
(active && $(active).hasClass(ClassName.FADE))
|
||||
|
||||
const complete = () => this._transitionComplete(
|
||||
|
@@ -333,7 +333,7 @@ const Tooltip = (($) => {
|
||||
}
|
||||
}
|
||||
|
||||
if (Util.supportsTransitionEnd() && $(this.tip).hasClass(ClassName.FADE)) {
|
||||
if ($(this.tip).hasClass(ClassName.FADE)) {
|
||||
const transitionDuration = Util.getTransitionDurationFromElement(this.tip)
|
||||
|
||||
$(this.tip)
|
||||
@@ -383,8 +383,7 @@ const Tooltip = (($) => {
|
||||
this._activeTrigger[Trigger.FOCUS] = false
|
||||
this._activeTrigger[Trigger.HOVER] = false
|
||||
|
||||
if (Util.supportsTransitionEnd() &&
|
||||
$(this.tip).hasClass(ClassName.FADE)) {
|
||||
if ($(this.tip).hasClass(ClassName.FADE)) {
|
||||
const transitionDuration = Util.getTransitionDurationFromElement(tip)
|
||||
|
||||
$(tip)
|
||||
|
@@ -14,8 +14,7 @@ const Util = (($) => {
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
let transition = false
|
||||
|
||||
const TRANSITION_END = 'transitionend'
|
||||
const MAX_UID = 1000000
|
||||
const MILLISECONDS_MULTIPLIER = 1000
|
||||
|
||||
@@ -26,8 +25,8 @@ const Util = (($) => {
|
||||
|
||||
function getSpecialTransitionEndEvent() {
|
||||
return {
|
||||
bindType: transition.end,
|
||||
delegateType: transition.end,
|
||||
bindType: TRANSITION_END,
|
||||
delegateType: TRANSITION_END,
|
||||
handle(event) {
|
||||
if ($(event.target).is(this)) {
|
||||
return event.handleObj.handler.apply(this, arguments) // eslint-disable-line prefer-rest-params
|
||||
@@ -37,16 +36,6 @@ const Util = (($) => {
|
||||
}
|
||||
}
|
||||
|
||||
function transitionEndTest() {
|
||||
if (typeof window !== 'undefined' && window.QUnit) {
|
||||
return false
|
||||
}
|
||||
|
||||
return {
|
||||
end: 'transitionend'
|
||||
}
|
||||
}
|
||||
|
||||
function transitionEndEmulator(duration) {
|
||||
let called = false
|
||||
|
||||
@@ -64,13 +53,8 @@ const Util = (($) => {
|
||||
}
|
||||
|
||||
function setTransitionEndSupport() {
|
||||
transition = transitionEndTest()
|
||||
|
||||
$.fn.emulateTransitionEnd = transitionEndEmulator
|
||||
|
||||
if (Util.supportsTransitionEnd()) {
|
||||
$.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent()
|
||||
}
|
||||
$.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -130,11 +114,12 @@ const Util = (($) => {
|
||||
},
|
||||
|
||||
triggerTransitionEnd(element) {
|
||||
$(element).trigger(transition.end)
|
||||
$(element).trigger(TRANSITION_END)
|
||||
},
|
||||
|
||||
// TODO: Remove in v5
|
||||
supportsTransitionEnd() {
|
||||
return Boolean(transition)
|
||||
return Boolean(TRANSITION_END)
|
||||
},
|
||||
|
||||
isElement(obj) {
|
||||
|
Reference in New Issue
Block a user