Skip to content

Instantly share code, notes, and snippets.

@Akryum
Created February 5, 2017 21:06
Show Gist options
  • Save Akryum/254a6d5da52995c48d0450446a8808ec to your computer and use it in GitHub Desktop.
Save Akryum/254a6d5da52995c48d0450446a8808ec to your computer and use it in GitHub Desktop.
const field = this._leaving ? 'leave' : 'enter'
const lastField = '_lastDuration_' + field
const duration = this.duration
const explicitDuration = parseDuration((
duration !== null &&
typeof duration === 'object' &&
duration[field]
) || duration)
const el = child.elm
// Did explicit duration change?
if (el && explicitDuration !== this[lastField]) {
this[lastField] = explicitDuration
const cb = this._leaving ? el._leaveCb : el._enterCb
if (el._transitionTimer) {
clearTimeout(el._transitionTimer)
}
if (typeof explicitDuration !== 'undefined') {
const lastedDuration = Date.now() - el._transitionStarted
const remainingDuration = explicitDuration - lastedDuration
// console.log('remainingDuration', remainingDuration)
if (el._offTransitionEnds) {
el._offTransitionEnds()
el._offTransitionEnds = null
}
el._transitionTimer = setTimeout(cb, remainingDuration)
} else {
el._transitionTimer = null
el._offTransitionEnds = whenTransitionEnds(el, this.type, cb)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment