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(') %>, head: <%= serialize(head).replace('titleTemplate(', 'function(') %>,
render(h, props) { render(h, props) {
<% if (loading) { %>const loadingEl = h('nuxt-loading', { ref: 'loading' })<% } %> <% 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 key: this.layoutName
}) }, [ layoutEl ])
const transitionEl = h('transition', { const transitionEl = h('transition', {
props: { props: {
name: '<%= layoutTransition.name %>', name: '<%= layoutTransition.name %>',
mode: '<%= layoutTransition.mode %>' mode: '<%= layoutTransition.mode %>'
} }
}, [ layoutEl ]) }, [ templateEl ])
return h('div',{ return h('div',{
domProps: { domProps: {

View File

@ -2,26 +2,11 @@ export default {
name: 'nuxt-child', name: 'nuxt-child',
functional: true, functional: true,
render (h, { parent, data }) { 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 data.nuxtChild = true
const _parent = parent const _parent = parent
const transitions = parent.$nuxt.nuxt.transitions const transitions = parent.$nuxt.nuxt.transitions
const defaultTransition = parent.$nuxt.nuxt.defaultTransition const defaultTransition = parent.$nuxt.nuxt.defaultTransition
let depth = 0 let depth = 0
while (parent) { while (parent) {
if (parent.$vnode && parent.$vnode.data.nuxtChild) { if (parent.$vnode && parent.$vnode.data.nuxtChild) {
@ -44,14 +29,12 @@ export default {
} }
}) })
nuxt._childVnode = h('transition', { return h('transition', {
props: transitionProps, props: transitionProps,
on: listeners on: listeners
}, [ }, [
h('router-view', data) h('router-view', data)
]) ])
return nuxt._childVnode
} }
} }