Last active
May 25, 2018 11:14
-
-
Save perjansson/0226e31d79dc796b5092cd1218eef523 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { routerTransition } from 'router.animations' | |
... | |
@Component({ | |
selector: '...', | |
styleUrls: ['...'], | |
templateUrl: './app.template.html', | |
animations: [routerTransition], | |
}) | |
export class AppComponent { | |
private previousPath: string = '' | |
getPageTransition(routerOutlet: RouterOutlet) { | |
if (routerOutlet.isActivated) { | |
let transitionName = 'section' | |
const { path } = routerOutlet.activatedRoute.routeConfig | |
const isSame = this.previousPath === path | |
const isBackward = this.previousPath.startsWith(path) | |
const isForward = path.startsWith(this.previousPath) | |
if (isSame) { | |
transitionName = 'none' | |
} else if (isBackward && isForward) { | |
transitionName = 'initial' | |
} else if (isBackward) { | |
transitionName = 'backward' | |
} else if (isForward) { | |
transitionName = 'forward' | |
} | |
this.previousPath = path | |
return transitionName | |
} | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment