fix: Fix Layouts transitions

This commit is contained in:
Atinux 2017-11-06 18:30:15 +01:00
parent e80a77782a
commit fb44c2eb8e
2 changed files with 9 additions and 22 deletions

View File

@ -18,16 +18,20 @@ export default {
head: <%= serialize(head).replace('titleTemplate(', 'function(') %>,
render(h, props) {
<% if (loading) { %>const loadingEl = h('nuxt-loading', { ref: 'loading' })<% } %>
const layoutEl = h(this.nuxt.err ? 'nuxt' : this.layout, {
const layoutEl = h(this.layout || 'nuxt')
const templateEl = h('div', {
domProps: {
id: '__layout'
},
key: this.layoutName
})
}, [ layoutEl ])
const transitionEl = h('transition', {
props: {
name: '<%= layoutTransition.name %>',
mode: '<%= layoutTransition.mode %>'
}
}, [ layoutEl ])
}, [ templateEl ])
return h('div',{
domProps: {

View File

@ -2,26 +2,11 @@ export default {
name: 'nuxt-child',
functional: true,
render (h, { parent, data }) {
const nuxt = parent.$root.nuxt
const component = parent.$route.matched[0].components.default
const layoutUid = parent._uid
const layoutName = component.options ? component.options.layout : null
// If we're changing layout render the stored vnode
if (nuxt._layoutUid === layoutUid &&
nuxt._layoutName !== layoutName
) {
return nuxt._childVnode
}
nuxt._layoutUid = layoutUid
nuxt._layoutName = layoutName
data.nuxtChild = true
const _parent = parent
const transitions = parent.$nuxt.nuxt.transitions
const defaultTransition = parent.$nuxt.nuxt.defaultTransition
let depth = 0
while (parent) {
if (parent.$vnode && parent.$vnode.data.nuxtChild) {
@ -44,14 +29,12 @@ export default {
}
})
nuxt._childVnode = h('transition', {
return h('transition', {
props: transitionProps,
on: listeners
}, [
h('router-view', data)
])
return nuxt._childVnode
}
}