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.

Transition without `position: absolute;`

See original GitHub issue

In demos, <Lorem /> Component’s position is set to absolute, So transition seems to work well. https://github.com/maisano/react-router-transition/blob/master/demos/index.html#L36

but If you can’t set router’s position to absolute, (like each router’s height are different and it can be changed) transition wouldn’t work well.

I’ve tried to set position: absolute on atLeave only, but it didn’t work. Also, I couldn’t figure out how to handle it using mapStyes.

Any ideas? 😞

Issue Analytics

  • State:open
  • Created 8 years ago
  • Reactions:2
  • Comments:26 (3 by maintainers)

github_iconTop GitHub Comments

41reactions
JurJeancommented, Apr 15, 2017

The solution from @akeelm is very nice, but I still had a problem with the footer of the page to toggle up and down. Using code below this is fixed.

                <RouteTransition
                    pathname={this.props.location.pathname}
                    atEnter={{ opacity: 0, foo: 0 }}
                    atLeave={{ opacity: 0, foo: 2 }}
                    atActive={{ opacity: 1, foo: 1 }}
                    mapStyles={(styles) => {
                    return {
                        position: (styles.foo <= 1) ? 'relative': 'absolute',
                        width: '100%',
                        height: '100%',
                        opacity: styles.opacity
                    }
                    }}>

I only still have the footer problem when I toggle routes really quick.

25reactions
albermavcommented, Jul 6, 2016

I have a similar solution, it just fades only the appearing div, and hides the older one:

<RouteTransition
  pathname={this.props.location.pathname}
  atEnter={{ opacity: 0 }}
  atLeave={{ opacity: 2 }}
  atActive={{ opacity: 1 }}
  mapStyles={styles => {
    if(styles.opacity > 1){
      return { display: 'none'}
    }
    return { opacity: styles.opacity}
  }}
>
  {this.props.children}
</RouteTransition>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Creating css transitions without using position:absolute
The best way to move elements around when animating is translating using css transforms. For example, to transition when hovering over the ...
Read more >
Using CSS transitions - CSS: Cascading Style Sheets | MDN
CSS transitions provide a way to control animation speed when changing CSS properties. Instead of having property changes take effect ...
Read more >
transition | CSS-Tricks
The transition property is a shorthand property used to represent up to four transition-related longhand properties:
Read more >
Transitions with position: absolute • REPL • Svelte
import { fly, fade } from 'svelte/transition'; ... padding: 2em; text-align: center; margin-top: 20em; position:sticky; bottom:0; } ...
Read more >
An Interactive Guide to CSS Transitions - Josh W Comeau
The main ingredient we need to create an animation is some CSS that changes. Here's an example of a button that moves on...
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