Skip to content
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

[Proposal] Allow disabling the scaling animation of the FloatingActionButton #145585

Closed
navaronbracke opened this issue Mar 22, 2024 · 6 comments · Fixed by #146126
Closed

[Proposal] Allow disabling the scaling animation of the FloatingActionButton #145585

navaronbracke opened this issue Mar 22, 2024 · 6 comments · Fixed by #146126
Assignees
Labels
a: animation Animation APIs c: new feature Nothing broken; request for a new capability c: proposal A detailed proposal for a change to Flutter f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. r: fixed Issue is closed as already fixed in a newer version team-design Owned by Design Languages team

Comments

@navaronbracke
Copy link
Contributor

Use case

Currently when the FloatingActionButton widget is added or removed from a Scaffold, it animates its transition.

We can control parts of this transition, using the FloatingActionButtonAnimator. By default this uses the scaling animator from the framework itself.

However, if I want to disable both the rotation and scaling animations with the following animator subclass:

class _NoAnimationFloatingActionButtonAnimator extends FloatingActionButtonAnimator {
  const _NoAnimationFloatingActionButtonAnimator();

  @override
  Offset getOffset({required Offset begin, required Offset end, required double progress}) {
    return end;
  }

  @override
  Animation<double> getRotationAnimation({required Animation<double> parent}) {
    return const AlwaysStoppedAnimation(1.0);
  }

  @override
  Animation<double> getScaleAnimation({required Animation<double> parent}) {
    return const AlwaysStoppedAnimation(1.0);
  }
}

and I pass an instance to the floatingActionButtonAnimator of a Scaffold, I still see a scale transition on the FAB.

Proposal

Allow disabling both the scaling and rotation transition, using the aforementioned FloatingActionButtonAnimator, either through a subclass, or by providing a FloatingActionButtonAnimator.noAnimation constant.

@danagbemava-nc danagbemava-nc added in triage Presently being triaged by the triage team c: new feature Nothing broken; request for a new capability framework flutter/packages/flutter repository. See also f: labels. a: animation Animation APIs f: material design flutter/packages/flutter/material repository. c: proposal A detailed proposal for a change to Flutter team-design Owned by Design Languages team and removed in triage Presently being triaged by the triage team labels Mar 22, 2024
@HansMuller
Copy link
Contributor

HansMuller commented Mar 28, 2024

@TahaTesser - Maybe this could be handled by giving FAB a pair of AnimationStyle parameters? Or maybe just a fix for the way FloatingActionButtonAnimator is handled is what's needed.

@TahaTesser
Copy link
Member

@TahaTesser - Maybe this could be handled by giving FAB a pair of AnimationStyle parameters? Or maybe just a fix for the way FloatingActionButtonAnimator is handled is what's needed.

This would be for Scaffold. floatingActionButtonAnimator
I already have a fix, just need tests.

@TahaTesser TahaTesser self-assigned this Mar 28, 2024
@TahaTesser
Copy link
Member

floatingActionButtonAnimator is bit niche for AnimationStyle. Since this is implemented and handled by Scaffold.

@HansMuller
Copy link
Contributor

I was trying to imply FAB.scaleAnimationStyle and FAB.rotationAnimationStyle. But I think you're right. The animations are a feature of the Scaffold, not FAB. Maybe we just have a bug here?

@TahaTesser
Copy link
Member

TahaTesser commented Mar 28, 2024

Yep, the bug is default entrance and exit animation curves are hard coded and combined with custom AlwaysStopAnimation curve, as a result you still get defaults curves.

My fix will try to override the default entrance and exit animations so we could disable the entrance and exit animations entirely with new FloatingActionButtonAnimator.noAnimation

auto-submit bot pushed a commit that referenced this issue Apr 29, 2024
…ations using `FloatingActionButtonAnimator.noAnimation` (#146126)

fixes [[Proposal] Allow disabling the scaling animation of the FloatingActionButton](#145585)

### Using default `FloatingActionButton` animations

![ScreenRecording2024-04-02at16 19 03-ezgif com-video-to-gif-converter](https://github.com/flutter/flutter/assets/48603081/627ea564-7f60-4eb4-bed9-95c053ae2f56)

### Using `FloatingActionButtonAnimator.noAnimation`

![ScreenRecording2024-04-02at16 17 20-ezgif com-video-to-gif-converter](https://github.com/flutter/flutter/assets/48603081/d0a936ea-9e16-4225-8dc4-40a11ee8a975)
@TahaTesser TahaTesser added the r: fixed Issue is closed as already fixed in a newer version label Apr 29, 2024
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: animation Animation APIs c: new feature Nothing broken; request for a new capability c: proposal A detailed proposal for a change to Flutter f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. r: fixed Issue is closed as already fixed in a newer version team-design Owned by Design Languages team
Projects
Status: Done (PR merged)
4 participants