mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-06 21:10:38 +00:00
Fix: transition property beeing a function
This commit is contained in:
parent
b6d82a7c5b
commit
664ce12662
@ -14,20 +14,21 @@ let router
|
|||||||
<%= (store ? 'let store' : '') %>
|
<%= (store ? 'let store' : '') %>
|
||||||
|
|
||||||
function mapTransitions(Components, to, from) {
|
function mapTransitions(Components, to, from) {
|
||||||
function componentTransitions(component) {
|
const componentTransitions = (component) => {
|
||||||
if (!component || !component.options || !component.options.transition) {
|
if (!component || !component.options || !component.options.transition) {
|
||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
if(typeof component.options.transition === 'function') {
|
let transition = component.options.transition
|
||||||
return component.options.transition(to, from)
|
if (typeof transition === 'function') {
|
||||||
|
transition = transition(to, from)
|
||||||
}
|
}
|
||||||
return component.options.transition
|
return (typeof transition === 'string' ? { name: transition } : transition)
|
||||||
}
|
}
|
||||||
return Components.map((Component) => {
|
return Components.map((Component) => {
|
||||||
// Clone original object to prevent overrides
|
// Clone original object to prevent overrides
|
||||||
const transitions = Object.assign({}, componentTransitions(Component))
|
const transitions = Object.assign({}, componentTransitions(Component))
|
||||||
// Combine transitions & prefer *leave* transitions of 'from' route
|
// Combine transitions & prefer `leave` transitions of 'from' route
|
||||||
if(from && from.matched.length && from.matched[0].components.default) {
|
if (from && from.matched.length && from.matched[0].components.default) {
|
||||||
const from_transitions = componentTransitions(from.matched[0].components.default)
|
const from_transitions = componentTransitions(from.matched[0].components.default)
|
||||||
Object.keys(from_transitions)
|
Object.keys(from_transitions)
|
||||||
.filter(key => from_transitions[key] && key.toLowerCase().indexOf('leave') !== -1)
|
.filter(key => from_transitions[key] && key.toLowerCase().indexOf('leave') !== -1)
|
||||||
|
Loading…
Reference in New Issue
Block a user