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

Animation documentation is lacking #9863

Closed
phkuo opened this issue Jul 18, 2019 · 18 comments
Closed

Animation documentation is lacking #9863

phkuo opened this issue Jul 18, 2019 · 18 comments
Assignees
Labels
Area: Documentation Resolution: Soft Close Soft closing inactive issues over a certain period Type: Documentation

Comments

@phkuo
Copy link
Contributor

phkuo commented Jul 18, 2019

The new animation documentation is located here:
https://developer.microsoft.com/en-us/fabric#/styles/web/motion

However there are a few problems with it.

@ecraig12345 @Jahnp

@joehillerman
Copy link

I am currently trying to add animations to a component when it mounts, unmounts and updates; but I have no clue where to even start with OUFR. I might end up consuming a third party react library for all my animation needs.

@joschect
Copy link
Contributor

@phkuo this is a good request. We'll get on improving the documentation.

@dzearing or @Jahnp Do you know who knows most about animations and who could help out with this?

@phkuo
Copy link
Contributor Author

phkuo commented Jul 22, 2019

This is what I've ascertained so far about using animations:

  1. The animations are either available as a string variable representing a CSS class, or as an IStyle for use with CSS-in-JS. In either case, you apply the class/IStyle at the moment you want the animation to start. For example, you can hardcode a slideIn animation on an element, and it will always animate with that slideIn when it first renders or re-renders. If you want to do a fadeOut, you'd wait until you get the event to remove the element, then apply the fadeout class/IStyle.
  2. The animations are constructed using the durations and timing functions, which are also provided as variables. In both CSS and CSS-in-JS, you can simply overwrite these to customize their values. What's less obvious is if you want to, for example, "wait for the fadeOut animation to end, then remove the element". You have to look up the duration variable used for the selected animation and use that to wait on the animation, but last time I tried that the timing still didn't work out (possibly because the timing function did weird things to it?), so for my wait time I tripled the duration. Anyways, the point is, there's no good way to figure out what the duration of an animation is in order to trigger an event to happen after it.

@dzearing dzearing assigned aneeshack4 and unassigned joschect Jul 23, 2019
@dzearing
Copy link
Member

Recommend that before we start documenting css-in-js imports of animations, we do the right thing here. I think suggesting to import animations from @uifabric/styling might paint things into a corner. Instead it would be ideal to have the theme provide animations, so that we can evolve them over time and users can opt in, and potentially override, in the theme.

There are a couple of proposals I have:

Option 1. We split animations our from fabric core css and add a consumption guide.

Possibly, we could have a "stylesheet urls" section in the theme to auto-add stylesheets as required.

Pros:

  • Splitting means smaller bundle size
  • Easy to consume (use class names)
  • Framework agnostic

Cons:

  • No type safety
  • No control (can't specify a "motion scale" token in theme)
  • No animations when you forget to include the css.
  • Doesn't "come with" theme

Option 2. Animations accessible through theme via class names.

This requires that any element which wants to use animations accesses them via contextual theme.

We should provide multiple solutions to access the theme:

  1. a styled like helper to access the contextual theme.
styled.div(p => [
  p.theme.animations.fadeIn40
]);
  1. a hoc to inject theme into a component (withTheme)
export const MyComponent = withTheme(MyComponentBase);
...render() {
   return <div className={ this.props.theme.animations.fadeIn40 } />;
}
  1. a hook to get theme
const MyComponent = () => {
  const theme = useTheme();

  return <div className={theme.animations.fadeIn40} />;
};

Pros:

  • The theme drives the animation classnames, which means they're user overridable, and can change as the design system changes.
  • Type safety
  • Possible to derive programmatically based on theme values (less/more motion)

Cons:

  • Framework specific (could possibly work with option 1 as well.)

@phkuo
Copy link
Contributor Author

phkuo commented Jul 23, 2019

I would love to see 2 someday, but not until we have a firm idea of how animations are used, how they are composed, and what animations look like in different themes. I think we should start with 1 for now until we have more concrete experience with animations. (Additionally, we haven't even updated animations since Fluent.)

@ecraig12345
Copy link
Member

We have some FluentMotion constants, but no indication of how to use them. @Jahnp could you or someone else from the design side help provide guidance on this? I think getting our existing motion constants documented on the website's Motion page should be the top priority (it's also the easiest).

@horsfallnathan
Copy link

Could someone show a sample code of how a simple animation is implemented in React using UI Fabric Motion. I just can't find an example out there.

@phkuo
Copy link
Contributor Author

phkuo commented Oct 11, 2019

@horsfallnathan
Using CSS-in-JS, inside Component.styles.ts:

import {
  AnimationStyles,
  AnimationVariables // you can use this to customize things like duration or delay
} from 'office-ui-fabric-react/lib/Styling';

export const getStyles = (props: IFooStyleProps): IFooStyles => {
  return {
    root: {
      ...AnimationStyles.slideUpOut10
    }
  };
}

@aneeshack4
Copy link
Contributor

aneeshack4 commented Oct 12, 2019

Have you looked at AnimationExample.tsx?

EDIT: Now located here

@horsfallnathan
Copy link

@horsfallnathan Have you looked at AnimationExample.tsx?

This helps thanks.

@sven5
Copy link

sven5 commented Jan 10, 2020

I'd like to use UI Fabric with Blazor. Currently, it seems that animation isn't possible with Fabric Core/plain css, is it?
I guess that at least, I must set the animation css class on page load through js.

Thanks

@parruc
Copy link

parruc commented Feb 9, 2021

Previous links to AnimationExample.tsx were broken due to change from github fabric repository to fluentui branch.
Here it is the new one:

AnimationExanple.tsx

@ecraig12345
Copy link
Member

@parruc That version is pretty outdated too (though I don't think it's changed much since then). This is the current version:
https://github.com/microsoft/fluentui/blob/master/packages/react-docsite-components/src/components/Animation/AnimationExample/AnimationExample.tsx

@Giuseppetm
Copy link

So basically there is no documentation for these animations and we have to rely on a single example..

@khmakoto khmakoto assigned smhigley and unassigned aneeshack4 May 18, 2021
@msft-fluent-ui-bot
Copy link
Collaborator

Because this issue has not had activity for over 150 days, we're automatically closing it for house-keeping purposes.

Still require assistance? Please, create a new issue with up-to date details.

@msft-fluent-ui-bot msft-fluent-ui-bot added the Resolution: Soft Close Soft closing inactive issues over a certain period label Feb 4, 2022
@marcgabe15
Copy link

Can this be resurfaced? The animation documentation is still lacking

@khmakoto
Copy link
Member

khmakoto commented Mar 3, 2022

Reopening the issue.

@khmakoto khmakoto reopened this Mar 3, 2022
@msft-fluent-ui-bot
Copy link
Collaborator

Because this issue has not had activity for over 150 days, we're automatically closing it for house-keeping purposes.

Still require assistance? Please, create a new issue with up-to date details.

@microsoft microsoft locked as resolved and limited conversation to collaborators Aug 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Area: Documentation Resolution: Soft Close Soft closing inactive issues over a certain period Type: Documentation
Projects
None yet
Development

No branches or pull requests