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

Added animations for show/hide #20

Merged
merged 5 commits into from
Jul 31, 2017
Merged

Added animations for show/hide #20

merged 5 commits into from
Jul 31, 2017

Conversation

dabide
Copy link
Contributor

@dabide dabide commented Apr 6, 2017

Added support for anim-show and anim-hide attributes, and thus show.bind animations.

@CLAassistant
Copy link

CLAassistant commented Apr 6, 2017

CLA assistant check
All committers have signed the CLA.

@zewa666
Copy link
Member

zewa666 commented Apr 6, 2017

@dabide hey there, thanks for the contribution. As far as I can see, the only necessary file to be included in this PR should be src/animator.js and package.json. Could you please remove the other ones. Those will be created automatically during release

@dabide
Copy link
Contributor Author

dabide commented Apr 6, 2017

Better now?

@dabide
Copy link
Contributor Author

dabide commented Apr 6, 2017

However, in light of this, I should probably switch to the CSS animator... :-( julianshapiro/velocity#769

@zewa666
Copy link
Member

zewa666 commented Apr 6, 2017

Yeah thats great ... now I haven't actually worked on the velocity implementation of this plugin, I was active on the CSS animator. Nevertheless I'll try to do a proper review of your changes. If you've some time and will you're welcome to add some unit tests as well ;)

@zewa666 zewa666 self-assigned this Apr 6, 2017
@@ -351,6 +377,8 @@ export class VelocityAnimator {
el.animations = {};
el.animations.enter = this._parseAttributeValue(el.getAttribute('anim-enter')) || this.enterAnimation;
el.animations.leave = this._parseAttributeValue(el.getAttribute('anim-leave')) || this.leaveAnimation;
el.animations.show = this._parseAttributeValue(el.getAttribute('anim-show')) || undefined;
Copy link
Member

Choose a reason for hiding this comment

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

if the animation for leave/show is not defined shouldn't we use defaults like for enter/leave? See line 22/23

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I initially did that, but reconsidered. Then enter/leave effects are opt-in by adding au-animate. If hide/show should have a default animation, I think we would also have to add a check for that attribute. (Or perhaps accept empty anim-leave and anim-show attributes.)

Copy link
Member

Choose a reason for hiding this comment

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

Ok let's keep it the way it is

return this.stop(element, true)._runElementAnimation(element, ':hide', undefined, 'hide').then(() => {
element.classList.add(className);
});
} else {
Copy link
Member

Choose a reason for hiding this comment

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

the else block is not really needed since the if contains a return

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Quite true. :-)

@@ -250,8 +258,14 @@ export class VelocityAnimator {
* @returns Resolved when the animation is done
*/
addClass(element: HTMLElement, className: string): Promise<boolean> {
Copy link
Member

Choose a reason for hiding this comment

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

I see that enter/leave do accept an options attribute, is that not needed for remove/add?

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, it is not used when templating calls enter/leave.

@@ -239,8 +242,13 @@ export class VelocityAnimator {
* @returns Resolved when the animation is done
*/
removeClass(element: HTMLElement, className: string): Promise<boolean> {
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't the function return type be Promise<boolean|VelocityAnimator> ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm no TypeScript expert. However, _runElementAnimation() returns Promise<any>, so then it could just as well be Promise<any> for removeClass(). But wouldn't that violate the Animator interface definition, which has Promise<bool>? Should I perhaps add a .then() that returns a boolean on success?

Copy link
Member

Choose a reason for hiding this comment

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

The then approach is the way to go 👍

Copy link
Member

Choose a reason for hiding this comment

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

Just make sure to add a catch as well in case something goes wrong

@EisenbergEffect
Copy link
Contributor

@zewa666 Where are we at on this?

@zewa666
Copy link
Member

zewa666 commented Jul 30, 2017

Looks good I think we can merge it

@EisenbergEffect
Copy link
Contributor

Can we remove the dependency on templating/resources here? It seems it's only for the sake of a single string.

@zewa666
Copy link
Member

zewa666 commented Jul 31, 2017

Well since the hide-class name might change we should keep it the way it is. I wouldn't be a too big fan of hard-coding it.

@EisenbergEffect
Copy link
Contributor

EisenbergEffect commented Jul 31, 2017

Because of one string we're creating a hard dependency between this library and the other one that doesn't make sense otherwise. Additionally, I'm not sure the internal reference to the module will work correctly with all loader scenarios. If we really want this to be a dependency, then we should move the const into the templating library so that both resources and animation can reference the same thing.

@zewa666
Copy link
Member

zewa666 commented Jul 31, 2017

But since that const is exported, moving it might causes breaking changes for consumers. Both approaches not very satisfying but in light of that I'd rather hardcode the value. I'll go forward and adapt the PR

@zewa666 zewa666 merged commit 16fdcd6 into aurelia:master Jul 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants