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.

Allow explicitly specifying backwards flag

See original GitHub issue

First off, this plugin is great!

I’m currently trying to implement a “stack” navigation where page transitions do horizontal slides and it works great. However, I need to make certain page transitions, which are invoked via NavigationManager.NavigateTo to specify that they are backwards. I’ve tried various hacks to try and get around this but no luck. I’ve tried to override the Transition object inside TransitionableLayoutComponent based on a global flag I set before I call NavigateTo but this seems to be changed shortly after.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
Kukkscommented, Dec 7, 2020

I’ve actually found one solution but it requires that I do js interop

await JsRuntime.InvokeVoidAsync("dispatchEventWrapper", "back");
NavigationManager.NavigateTo($"counter/{i}");
1reaction
KieranFleckneycommented, Feb 2, 2021

I know this is closed but thought I would provided a solution (If I understood the issue correctly)

First you need to create a attribute

    public class MyAttribute : Attribute
    {
        public string TIn { get; set; }

        public string Tout { get; set; }
    }

Next add this to the page. (Counter page for example)

@page "/counter"
@attribute [MyAttribute(TIn = "FadeIn", Tout = "FadeOut")]

<h1>Counter</h1>

<p>Current count: @currentCount</p>

<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>

@code {
    private int currentCount = 0;

    private void IncrementCount()
    {
        currentCount++;
    }
}

Then in your MyViewLayout.razor

@inherits TransitionableLayoutComponent
@using BlazorAnimations.Pages;

<div class="transition @transitioningClass">
    @Body
</div>

<style>
    .transition {
        position: absolute;
    }
</style>

@if (!Transition.FirstRender)
{
    <style>
        .transition-in {
            opacity: 0;
        }
    </style>
}

@code {

    private string GetAnimationClass()
    {
        string value = Transition.IntoView ? "fadeInDown" : "fadeOutDown";

        var found = Attribute.IsDefined(Transition.RouteData.PageType, typeof(MyAttribute));

        if (found)
        {
            MyAttribute MyAttribute = (MyAttribute)Attribute.GetCustomAttribute(Transition.RouteData.PageType, typeof(MyAttribute));

            if (Transition.IntoView)
            {
                if (!string.IsNullOrWhiteSpace(MyAttribute.TIn))
                {
                    value = MyAttribute.TIn;
                }
            }
            else
            {
                if (!string.IsNullOrWhiteSpace(MyAttribute.Tout))
                {
                    value = MyAttribute.Tout;
                }
            }
        }

        return value;
    }

    private string transitioningClass => Transition.FirstRender ? "" : Transition.IntoView
    ? $"animate__{GetAnimationClass()} animate__faster animate__animated"
     : $"animate__{GetAnimationClass()} animate__faster animate__animated";

}

This would allow you to specify the in and out animation for each page individually and have default animation for all pages. You could also add logic to do something if it is backwards or what ever you want.

Hope this helps.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why the U.S. Flag Is Worn Backward on Army Uniforms
American military uniforms feature the U.S. flag, which is worn facing backward. The rule is that the blue field of stars should always...
Read more >
Why do some people wear an American flag patch ...
While serving in a fraternal, government, or religious setting. As a pin, tie or scarf. At a parade, picnic or other similar setting....
Read more >
Flag code FAQs: Displaying the flag
For patches worn on your RIGHT sleeve, use a "right" or "reversed field" flag. Since the Flag Rules do not specifically address the...
Read more >
Here's Why The US Flag Sometimes Appears Backwards
The “backwards” flag is actually part of the US Flag Code, which applies to spacecraft, aircraft, and even service members' uniform insignia ...
Read more >
js regex backwards compatibility of flags - javascript
What this is about is that you can't specify flags when using the RegExp constructor as a copy constructor (or at least, couldn't...
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