-
-
Notifications
You must be signed in to change notification settings - Fork 241
Default transition of Frame is not used when using NsRouterLink #1784
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
As soon as this bug is validated, I could create a PR for this. Should be relatively easy to fix. For now I have monkey-patched this issue like this: import { Frame } from 'tns-core-modules/ui/frame';
import { NSRouterLink } from 'nativescript-angular/router/ns-router-link';
// Monkey-patch NS router link to not set empty transition
const originalGetTransition = NSRouterLink.prototype['getTransition'];
NSRouterLink.prototype['getTransition'] = function() {
const transition = originalGetTransition.apply(this);
return {
...transition,
transition: (transition.transition && Object.keys(transition.transition).length === 0)
? undefined
: transition.transition
};
};
// Set default transition
Frame.defaultTransition = {
name: 'slideBottom',
duration: 500
}; |
Hi @flore2003, |
@tsonevn I added the PR, is there anything left to do on my part or will you just review the PR now? |
HI @flore2003 , Thank you for your contribution, I am currently reviewing your PR. You can follow the discussion there, if anything needs to change I will update you there. |
Environment
Provide version numbers for the following components (information can be retrieved by running
tns info
in your project folder or by inspecting thepackage.json
of the project):Describe the bug
When setting the static
defaultTransition
property on theFrame
class, the transition is not used, when navigation is initiated by tapping on an nsRouterLink that does not specify any transition using the[transition]
input.To Reproduce
Set
Frame.defaultTransition
to any validNavigationTransition
object. Tap on a button that has ansRouterLink
directive with no explicitly set transition. The default transition is not applied to this navigation.Expected behavior
The default transition specified by setting
Frame.defaultTransition
should be used when there is no explicitly set transition on an nsRouterLink.Additional context
This is due to NsRouterLink returning an empty object for the transition in the
getTransition
method (https://github.com/NativeScript/nativescript-angular/blob/master/nativescript-angular/router/ns-router-link.ts#L117) when no transition is explicitly set. In this case, the transition input defaults totrue
, which leads thegetTransition
method to return an empty object for thetransition
property. As the Frame checks whether the transition property isundefined
to decide whether to use the default transition, this leads to the default transition not being used.The text was updated successfully, but these errors were encountered: