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.

[Spec] Transitions

See original GitHub issue

Transitions

Maui already has a complete animations API allowing you to create a live and fluid content on a page. However, what happens when navigating between pages?.

This spec defines a Maui transitions API. We have two types of well-differentiated transitions:

  • Traditional transitions: Traditionally transitions between different pages involved enter and exit transitions that animated entire view hierarchies independent to each other.
  • Shared element transitions: Many times, there are elements common to both activities and providing the ability to transition these shared elements separately emphasizes continuity between transitions and breaks activity boundaries as the user navigates the app.

shared_transitions

API

Traditional transitions

For the traditional transitions, we need a new enumeration with the supported transitions:

public enum NavigationTransitionType
{
    None,
    Fade,
    Flip,
    Scale,
    SlideFromLeft,
    SlideFromRight,
    SlideFromTop,
    SlideFromBottom,
    Turnstile
}

And, include new properties in the Page to allow page transitions using NavigationPage and Shell:

  • TransitionType: The transition effect used.
  • TransitionDuration: The transition duration in milliseconds.
public static readonly BindableProperty TransitionTypeProperty =
     BindableProperty.Create(nameof(TransitionType), typeof(NavigationTransitionType),   typeof(NavigationPage), PageTransitionType.None,
     BindingMode.TwoWay, null);

public NavigationTransitionType TransitionType
{
    get { return (NavigationTransitionType)GetValue(TransitionTypeProperty); }
    set { SetValue(TransitionTypeProperty, value); }
}

public static readonly BindableProperty TransitionDurationProperty =
     BindableProperty.Create(nameof(TransitionDuration), typeof(double), typeof(NavigationPage), 500d,
     BindingMode.TwoWay, null);

public double TransitionDuration
{
    get { return (double)GetValue(TransitionDurationProperty); }
    set { SetValue(TransitionDurationProperty, value); }
}

Shared element transitions

On the other hand, we need a way to allow the shared element transitions. The key is a way to “link” the same item available in two different pages.

We will have the TransitionTag attached property to the supported elements inherited from View:

public static readonly BindableProperty TransitionTagProperty =    
     BindableProperty.CreateAttached("TransitionTag", typeof(int), typeof(Transition), 0,
propertyChanged: OnPropertyChanged);

The use would be:

<Image Source="xamarin.jpg" TransitionTag="logo" WidthRequest="100" />

Tag the control to transition in the source page.

<Image Source="xamarin.jpg" TransitionTag="logo" WidthRequest="300" />

And tag the control to transition in the destination page.

Scenarios

Let’s see some examples.

XAML Example

A sample using transitions between pages:

<ContentPage
     TransitionType=“SlideFromBottom”
     TransitionDuration="750" />

A sample using shared transitions elements:

Page 1:

<Image  
     Source="xamagon_preview.png"
     TransitionTag="xamagon"/>

Page 2:

<Image  
     Source="xamagon.png"
     TransitionTag="xamagon"/>

Notes

  • The TransitionTag in source and destination page needs to match in order to display the transition.
  • You can animate multiple views at once, but every TransitionTag in a page needs to be unique.

Difficulty : Medium

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:103
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

29reactions
Laftekcommented, Sep 4, 2022

This should have much higher priority in my opinion.

27reactions
Inregocommented, Apr 12, 2022

What’s the status on this? It’s the oldest open issue in this repo. Added to “Under consideration” about 6 months ago. Is it still under consideration? Shared transitions like these really do help improve look and feel for an app, as well as perceived speed of the app.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Transitions Lenses | Light Intelligent Photochromic Lenses
**Transitions lenses block 100% UV & filter at least 26% of blue-violet light indoors & at least 86% outdoors. Tests performed on grey...
Read more >
CSS View Transitions Module Level 1
This specification introduces a DOM API and associated CSS features that allow developers to create animated visual transitions, called view ...
Read more >
The motion system - Material Design
The motion system is a set of transition patterns that can help users understand and ... Use the tabs above the timeline to...
Read more >
How to best spec animations/transitions for engineering ...
There are transitions between views and animations for certain elements on the page. I have shown the prototype to the engineers who are...
Read more >
transition - CSS: Cascading Style Sheets - MDN Web Docs
Transitions enable you to define the transition between two states of an element. Different states may be defined using pseudo-classes like : ...
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 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