question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Page transition broken with nuxt-i18n

See original GitHub issue

Version

v5.3.0

Reproduction link

https://github.com

Steps to reproduce

I have simple fade page transition

.page-enter-active {
  backface-visibility: hidden;
  will-change: opacity;
  opacity: 1;
  transition: opacity 450ms linear;
}

.page-leave-active {
  backface-visibility: hidden;
  will-change: opacity;
  opacity: 1;
  transition: opacity 450ms linear;
}

.page-enter {
  opacity: 0;
}

.page-leave-active {
  opacity: 0;
}

The problem is, when I change locale, text content changes instantly while page transition is not complete. In result I have a blink of content.

Is there’a a way to solve this?

What is expected ?

No blink, smooth transition

What is actually happening?

Transition broken, content blink

<div align="right">This bug report is available on Nuxt community (#c163)</div>

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:9
  • Comments:34

github_iconTop GitHub Comments

4reactions
imSharacommented, Feb 26, 2019

@lu40 thanks, but returning transition name should not be empty '' becouse it will be replaced to default. Should return any character, e.g:

export default function pageTransition (from, to) {
  const pageTransitionName = 'my-page-transition'
  if (!from || !to || !from.name || !to.name) return pageTransitionName
  return stripLocale(from.name) === stripLocale(to.name) ? '-' : pageTransitionName
}
4reactions
lu40commented, Feb 26, 2019

@thariddler could you provide a gif of the issue? That is the routing? (from > to) Or did you solved it already?

simplescreenrecorder-2019-02-09_22 40 42

The transition is copy-pasted from the original issue description. @thariddler I guess this is the behaviour you were talking about?


For me the following workaround does the job:

// utils/page-transition.js

function stripLocale (name) {
  const routeNameSeperator = '__' // or whatever you set it to
  return name.substring(0, name.indexOf(routeNameSeperator))
}

export default function pageTransition (from, to) {
  const pageTransitionName = 'my-page-transition'
  if (!from || !to || !from.name || !to.name) return pageTransitionName
  return stripLocale(from.name) === stripLocale(to.name) ? '' : pageTransitionName
}


// pages/index.vue

import pageTransition from '~/utils/page-transition'
export default {
  transition: pageTransition
}

However this disables page transitions when switching the language instead of replacing the translated content smoothly while fading back in.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Page transition broken with nuxt-i18n · Issue #150 - GitHub
The problem is, when I change locale, text content changes instantly while page transition is not complete. In result I have a blink...
Read more >
Locale keeps resetting between switching pages. Nuxt-i18n
I am trying to set up localization for my Nuxt frontend. Every time I switch to English and then move to an other...
Read more >
[Solved]-Nuxt transition not working on diffents layouts-Vue.js
Nuxt separates the two because page transitions are more granular and may need more specific body adjustments between shared page layouts.
Read more >
Lang Switcher - i18n-module
Wait for page transition. By default, the locale will be changed right away when navigating to a route with a different locale which...
Read more >
Options - i18n-module
This is useful if you want to wait for the page transition to end before setting the locale yourself using finalizePendingLocaleChange .
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found