Fix: transition property beeing a function

This commit is contained in:
Sébastien Chopin 2017-06-19 23:30:05 +02:00
parent b6d82a7c5b
commit 664ce12662
1 changed files with 7 additions and 6 deletions

View File

@ -14,20 +14,21 @@ let router
<%= (store ? 'let store' : '') %>
function mapTransitions(Components, to, from) {
function componentTransitions(component) {
const componentTransitions = (component) => {
if (!component || !component.options || !component.options.transition) {
return {}
}
if(typeof component.options.transition === 'function') {
return component.options.transition(to, from)
let transition = component.options.transition
if (typeof transition === 'function') {
transition = transition(to, from)
}
return component.options.transition
return (typeof transition === 'string' ? { name: transition } : transition)
}
return Components.map((Component) => {
// Clone original object to prevent overrides
const transitions = Object.assign({}, componentTransitions(Component))
// Combine transitions & prefer *leave* transitions of 'from' route
if(from && from.matched.length && from.matched[0].components.default) {
// Combine transitions & prefer `leave` transitions of 'from' route
if (from && from.matched.length && from.matched[0].components.default) {
const from_transitions = componentTransitions(from.matched[0].components.default)
Object.keys(from_transitions)
.filter(key => from_transitions[key] && key.toLowerCase().indexOf('leave') !== -1)