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

[Drawer] Open/close animation easing and timing (#6059) #6066

Merged
merged 4 commits into from
Feb 7, 2017

Conversation

ArcanisCz
Copy link
Contributor

Changed easing and duration according to spec, and solved premature modal dialog closing during animation duration.
Fixes #6059

@@ -93,6 +98,8 @@ export default class Drawer extends Component {
children,
className,
docked,
enterTransitionDuration,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didnt want to duplicate theese durations here (from Slider), but it turned out, Modal needs this durations to properly show/hide himself

Changed easing and duration according to spec, and solved premature modal dialog closing during animation duration
@@ -15,6 +15,19 @@ export const easing = {
sharp: 'cubic-bezier(0.4, 0.0, 0.6, 1)',
};

// Follow https://material.io/guidelines/motion/duration-easing.html#duration-easing-common-durations
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created some constants for transition durations, but on second thought, i think theese should be subject of customization/theme somehow - even documentation gives different durations for different devices (pc, tablet, mobile, watches)

Copy link
Member

@oliviertassinari oliviertassinari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool PR! Thanks for working on that.
I think that we miss some test. But otherwise, it's almost good to be merged 👍 .

<Modal
{...containerProps}
show={open}
backdropTransitionDuration={open ? enterTransitionDuration : leaveTransitionDuration}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would reverse the order to allow high customization power.

+        backdropTransitionDuration={open ? enterTransitionDuration : leaveTransitionDuration}
+        {...containerProps}
+        show={open}

@@ -82,14 +85,17 @@ export default class Slide extends Component {
handleEntering = (element) => {
const { transitions } = this.context.theme;
element.style.transition = transitions.create('transform',
`${this.props.transitionDuration}ms`);
`${this.props.enterTransitionDuration}ms`, undefined, easing.easeOut);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is undefined for 0ms?
I'm wondering if we should change the API. That makes me think of https://twitter.com/brian_d_vaughn/status/828507525469253632.

Copy link
Contributor Author

@ArcanisCz ArcanisCz Feb 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, i am thinking of something this:

//all defaults are as now, all, 0ms, ...
transitions.create({
      properties: 'transform', // String/Array 
      duration: transitions.durations.enteringScreen, // Number - nobody will use anything else than ms anyway
      delay: ... //as above
      easing: transitions.easing.easeOut, // String, probably some check if it is from standard functions?
    });

Where that easing/duration constants would be best to obtain from context theme rather that from static import, since i suspect it would be appealing to change timings according to user agent (mobile/pc, ...)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, i am thinking of something this:

That's what I have in mind too 👍 . But that's out of the scope of this PR.

element.style.transform = 'translate3d(0, 0, 0)';
if (this.props.onEntering) {
this.props.onEntering(element);
}
};

handleExiting = (element) => {
const { transitions } = this.context.theme;
element.style.transition = transitions.create('transform',
`${this.props.leaveTransitionDuration}ms`, undefined, easing.sharp);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same, 0ms would probably be more explicit.

@oliviertassinari oliviertassinari added next PR: needs revision The pull request can't be merged. More details is available on the code review or fails in the CI and removed PR: Needs Review labels Feb 6, 2017
@ArcanisCz
Copy link
Contributor Author

ArcanisCz commented Feb 6, 2017

added tests.

Will try to devise some API for that animation later, for this PR i left it as '0ms' since there are other usages to refactor. Will check that new API with you before refactor for sure 👍

});

it('should be passed to to Modal\'s backdropTransitionDuration when open=true', () => {
const wrapper = shallow(<Drawer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We rather use that line break pattern.

const wrapper = shallow(
  <Drawer
    open
  />
);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, was confused by eslint comma-dangle rule there, seemed to be a bit weird.

enterTransitionDuration={enterDuration}
leaveTransitionDuration={leaveDuration}
/>);
assert.strictEqual(wrapper.find(Modal).prop('backdropTransitionDuration'), enterDuration);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any though on .prop('backdropTransitionDuration')vs.props().backdropTransitionDuration?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no preference, maybe later one is a bit more friendly towards editor's intellisense? Anyway, changed as requested

@oliviertassinari oliviertassinari added PR: Review Accepted and removed PR: Needs Review PR: needs revision The pull request can't be merged. More details is available on the code review or fails in the CI labels Feb 7, 2017
@oliviertassinari oliviertassinari merged commit 7e547a8 into mui:next Feb 7, 2017
@ArcanisCz ArcanisCz deleted the nextFeature/Drawer branch February 10, 2017 22:21
@zannager zannager added the component: drawer This is the name of the generic UI component, not the React module! label Mar 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: drawer This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants