Nuxt.js: Layout transitions (layoutTransition) javascript hooks

Created on 3 Jul 2019  路  12Comments  路  Source: nuxt/nuxt.js

What problem does this feature solve?

When I change route page and new page has another layout, I need vue transition hooks, to detect and handle it (in my case - I update store state in beforeLeave/afterEnter hooks)
Vue transition hooks: https://vuejs.org/v2/api/#transition

I tried write transition/layoutTransition inside layouts, but it doesn't work.
UPD: tried in nuxt.config - same result

layoutTransition: {
  beforeEnter: function () {
    debugger
  }
}

Nuxt version: 2.8.1

What does the proposed changes look like?

Same what you did here: https://github.com/nuxt/nuxt.js/issues/34
But for layouts

This feature request is available on Nuxt community (#c9453)
feature-request

Most helpful comment

Still waiting, thx

All 12 comments

Anybody? :D

@crutch12 I'll take a look soon.

Still waiting, thx

+, it's very important for me too

+1 Would be much appreciated

Anybody? :D [2]
A year has passed

I tried to use function (like pageTransition) in layoutTransition and it didn't work.

As stated in the official documentation, this works as expected.

// nuxt.config.js
{
  pageTransition: {
    name: 'page',
    mode: 'out-in',
    beforeEnter (el) {
      console.log('This works...');
    }
  }
}

But if you try that for a layout, it won't work.

// nuxt.config.js
{
   layoutTransition: {
    name: 'layout',
    mode: 'out-in',
    beforeEnter (el) {
      console.log('This doesnt work...');
    }
}

Layout transition only work with css, at the moment.

// nuxt.config.js
{
   layoutTransition: {
    name: 'layout',
    mode: 'out-in'
  }
}
/* global css */

.layout-enter-active,
.layout-leave-active {
  transition: opacity 0.5s;
}
.layout-enter,
.layout-leave-active {
  opacity: 0;
}

Nuxt version: 2.14.5

Any updates on this? In my case i want the page transition hooks in layouts. Because i want the same transition (and other things) when i navigate from the error layout to default layout. Thanks. 馃檹

I need this too, same case as @marcoribeiroweb
Any updates yet?

@galvez We would appreciate if you could give us some feedback, can we expect a fix soon? 馃槂

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pehbehbeh picture pehbehbeh  路  3Comments

bimohxh picture bimohxh  路  3Comments

lazycrazy picture lazycrazy  路  3Comments

danieloprado picture danieloprado  路  3Comments

gary149 picture gary149  路  3Comments