mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 14:15:13 +00:00
parent
6ca11461ce
commit
5c36ed7b73
@ -14,12 +14,23 @@ let router
|
||||
<%= (store ? 'let store' : '') %>
|
||||
|
||||
function mapTransitions(Components, to, from) {
|
||||
const resolve = t => (typeof t.options.transition === 'function')
|
||||
? t.options.transition(to, from)
|
||||
: Object.assign({}, t.options.transition)
|
||||
|
||||
const resolveRoute = r => resolve(r.matched[0].components.default)
|
||||
|
||||
return Components.map((Component) => {
|
||||
let transition = Component.options.transition
|
||||
if (typeof transition === 'function') {
|
||||
return transition(to, from)
|
||||
}
|
||||
return transition
|
||||
let transitions = Object.assign({}, to ? resolveRoute(to) : resolve(Component))
|
||||
// Combine transitions
|
||||
// Prefer leave* transitions of from route
|
||||
let from_transitions = from ? resolveRoute(from) : {}
|
||||
Object.keys(from_transitions).forEach(key=> {
|
||||
if(from_transitions[key] && key.toLowerCase().indexOf('leave') !== -1) {
|
||||
transitions[key] = from_transitions[key]
|
||||
}
|
||||
})
|
||||
return transitions
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user