Skip to content
This repository was archived by the owner on Dec 19, 2024. It is now read-only.

Removing Deprecated Neon-Animation Dependency#160

Open
homerjonathan wants to merge 3 commits into
PolymerElements:masterfrom
homerjonathan:master
Open

Removing Deprecated Neon-Animation Dependency#160
homerjonathan wants to merge 3 commits into
PolymerElements:masterfrom
homerjonathan:master

Conversation

@homerjonathan

Copy link
Copy Markdown

Another removal of Neon-Animation Dependency.

Copying much of the code design from paper-tooltip this one was much easier. I have had a look and cannot see any timer configurations so I think that this should not be much of a break fix for most users.

I have also solved an issue when the animation selected is not known.

    _isSetAnimationValid: function () {
      // If CSS Class does not have animation-name considered not be an animation
      var style = window.getComputedStyle(this);
      return (style.getPropertyValue("animation-name") === "none")
    }

This seems the least processor intensive way to find out if the animation exists. If animation does not exist it is simply ignored. Whereas if you call an animation that does not exist the event on animation end is not fired leaving the dialog unable to open or close.

@homerjonathan

Copy link
Copy Markdown
Author

Any updates on this PR?

I have started to work on iron-dropdown and want to know if I am going in the right direction.

@valdrinkoshi valdrinkoshi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hi @homerjonathan, thanks for the contribution.
This looks like a breaking change as it would not support any custom animations some users might rely on for their paper-dialogs.
As per our Contributing guidelines, could you file an issue where we can discuss the issue & design potential solutions?

@valdrinkoshi valdrinkoshi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is great stuff!
I think we'll need to add some unit tests for stuff like:

  • should not animate by default
  • should remove the animation classes when done animating
  • should handle only its own animations

Comment thread paper-dialog.html
Set the `entry-animation` and/or `exit-animation` attributes to add an animation when the dialog
is opened or closed. See the documentation in
[PolymerElements/neon-animation](https://github.com/PolymerElements/neon-animation) for more info.
is opened or closed. Included in the component are fade-in-animation (and out), scale-up-animation.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: can you list the animation explicitly here?

Included in the component are:
- fade-in-animation
- fade-out-animation
- scale-up-animation
- scale-down-animation

Comment thread paper-dialog.html
animation-name: keyFrameFadeInOpacity;
animation-iteration-count: 1;
animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
animation-duration: var(--paper-dialog-duration-in, 500ms);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd avoid exposing new css custom properties/mixins for now, as the user can decide to redefine all of this by doing:

<style>
  .fade-in-animation {
   /* my overrides */
   animation-duration: 1s;
  }
  <paper-dialog entry-animation="fade-in-animation">

Comment thread paper-dialog.html
animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
animation-duration: var(--paper-dialog-duration-in, 500ms);
animation-fill-mode: forwards;
@apply --paper-dialog-animation;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd remove this for now (same reasoning as above)

Comment thread paper-dialog.html
animation-name: keyFrameFadeOutOpacity;
animation-iteration-count: 1;
animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
animation-duration: var(--paper-dialog-duration-out, 1500ms);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd remove this for now (same reasoning as above), also the default value should be 500ms as for the other ones.

Comment thread paper-dialog.html
animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
animation-duration: var(--paper-dialog-duration-out, 1500ms);
animation-fill-mode: forwards;
@apply --paper-dialog-animation;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd remove this for now (same reasoning as above)

Comment thread paper-dialog.html
this.listen(this, 'animationend', '_onAnimationEnd');
},

_removeListeners: function () {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can remove

Comment thread paper-dialog.html
}
},

_onAnimationEnd: function () {

@valdrinkoshi valdrinkoshi Mar 8, 2018

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

animationend event bubbles, so this method will be invoked if paper-dialog contains animating content (e.g. a spinner). To repro, try nesting 2 paper-dialogs, and observe that this method gets called twice when opening the inner dialog.

We need to handle the case here. Also, we need to always remove the classes before calling finishRenderOpened/Closed:

_onAnimationEnd: function (event) {
  if (event.target !== this) {
    return;
  }
  // Removes animation classes.
  this.cancelAnimation();
  if (!this.opened) {
    this._finishRenderClosed();
  } else {
    this._finishRenderOpened();
  }
},

Comment thread paper-dialog.html
},

_onAnimationEnd: function () {
// If no longer showing add class hidden to completely hide dialog

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

IronOverlayBehavior already takes care of setting display: none to the overlay in _finishRenderClosed, so we don't have to worry about this here 👌

Comment thread paper-dialog.html
_isSetAnimationValid: function () {
// If CSS Class does not have animation-name considered not be an animation
var style = window.getComputedStyle(this);
return (style.getPropertyValue("animation-name") === "none")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: ' instead of " here :)

Comment thread paper-dialog.html

_isSetAnimationValid: function () {
// If CSS Class does not have animation-name considered not be an animation
var style = window.getComputedStyle(this);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It would be worth to check for animation-duration in here too, e.g. if it is 0 then we don't have to wait for animationend. WDYT?

Comment thread bower.json
"homepage": "https://github.com/PolymerElements/paper-dialog",
"ignore": [],
"dependencies": {
"neon-animation": "PolymerElements/neon-animation#1 - 2",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

(missed this) we should remove it from the 1.x variant too (line 42)

@homerjonathan

Copy link
Copy Markdown
Author

All changes seem reasonable. However I am in the UK.....we are now in sleep mode! ;-)

@valdrinkoshi

Copy link
Copy Markdown
Member

SG, thanks for looking into this again @homerjonathan :)

Ps: I played with the styles a bit, they could be reduced to half by sharing setup, e.g.

:host {
  animation-duration: 500ms;
  animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

:host(.fade-in-animation) {
  animation-name: fadeInAnimation;
}

@keyframes fadeInAnimation {
  from {
    opacity: 0;
  }
}

:host(.fade-out-animation) {
  animation-name: fadeOutAnimation;
}

@keyframes fadeOutAnimation {
  to {
    opacity: 0;
  }
}

:host(.scale-up-animation) {
  animation-name: scaleUpAnimation;
}

@keyframes scaleUpAnimation {
  from {
    transform: scale(0.0);
  }
}

:host(.scale-down-animation) {
  animation-name: scaleDownAnimation;
}

@keyframes scaleDownAnimation {
  to {
    transform: scale(0.0);
  }
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants