Skip to content

Commit

Permalink
feat(animation): attention seekers (#848)
Browse files Browse the repository at this point in the history
* feat(animation): Adding bounce animation base

* chore(): animation clean up

* feat(animation): Adding flash animation base

* feat(animation): Adding headshake animation base

* feat(animation): Adding jello animation base

* feat(animation): Adding pulse animation base

* chore(animations): general cleanup

* chore(animations): Docs typo
  • Loading branch information
mrjasonweaver authored and emoralesb05 committed Sep 5, 2017
1 parent d53ef53 commit f106ccf
Show file tree
Hide file tree
Showing 8 changed files with 285 additions and 0 deletions.
98 changes: 98 additions & 0 deletions src/app/components/components/animations/animations.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,101 @@ <h3 mdLine>ease?: string</h3>

</md-card-content>
</md-card>


<md-card>
<md-card-title>Attention Seekers Animation</md-card-title>
<md-divider></md-divider>
<md-card-content>
<div>
<h3>Demos:</h3>

<button md-raised-button [@tdBounce]="bounceState" (click)="bounceState = !bounceState" color="accent">
@tdBounce <md-icon>mood</md-icon>
</button>

<button md-raised-button [@tdFlash]="flashState" (click)="flashState = !flashState" color="accent">
@tdFlash <md-icon>mood</md-icon>
</button>

<button md-raised-button [@tdHeadshake]="headshakeState" (click)="headshakeState = !headshakeState" color="accent">
@tdHeadshake <md-icon>mood</md-icon>
</button>

<button md-raised-button [@tdJello]="jelloState" (click)="jelloState = !jelloState" color="accent">
@tdJello <md-icon>mood</md-icon>
</button>

<button md-raised-button [@tdPulse]="pulseState" (click)="pulseState = !pulseState" color="accent">
@tdPulse <md-icon>mood</md-icon>
</button>

<p>Typescript:</p>
<td-highlight lang="typescript">
<![CDATA[
import {
TdBounceAnimation,
TdFlashAnimation,
TdHeadshakeAnimation,
TdJelloAnimation,
TdPulseAnimation,
} from '@covalent/core';
...
animations: [
TdBounceAnimation(), // using implicit anchor name 'tdBounce' in template
TdFlashAnimation(), // using implicit anchor name 'tdFlash' in template
TdHeadshakeAnimation(), // using implicit anchor name 'tdheadshake' in template
TdJelloAnimation(), // using implicit anchor name 'tdjello' in template
TdPulseAnimation(), // using implicit anchor name 'tdpulse' in template
],
...
class MyDemo {
bounceState: boolean = false;
flashState: boolean = false;
headshakeState: boolean = false;
jelloState: boolean = false;
pulseState: boolean = false;
}
]]>
</td-highlight>
<p>HTML:</p>
<td-highlight lang="html">
<![CDATA[
<button md-raised-button [@tdBounce]="bounceState" (click)="bounceState = !bounceState" color="accent">
@tdBounce <md-icon>mood</md-icon>
</button>
<button md-raised-button [@tdFlash]="flashState" (click)="flashState = !flashState" color="accent">
@tdFlash <md-icon>mood</md-icon>
</button>
<button md-raised-button [@tdHeadshake]="headshakeState" (click)="headshakeState = !headshakeState" color="accent">
@tdHeadshake <md-icon>mood</md-icon>
</button>
<button md-raised-button [@tdJello]="jelloState" (click)="jelloState = !jelloState" color="accent">
@tdJello <md-icon>mood</md-icon>
</button>
<button md-raised-button [@tdPulse]="pulseState" (click)="pulseState = !pulseState" color="accent">
@tdPulse <md-icon>mood</md-icon>
</button>
]]>
</td-highlight>
</div>

<md-divider></md-divider>
<div>
<h2>API:</h2>
<md-list>
<md-list-item>
<h3 md-line>anchor?: string</h3>
<p md-line> The anchor name is used to attach the animation to an arbitrary element in the template.</p>
</md-list-item>
<md-divider></md-divider>
<md-list-item>
<h3 md-line>duration?: number</h3>
<p md-line> Duration the animation will run in miliseconds. Defaults to 500 ms. </p>
</md-list-item>
<md-divider></md-divider>
</md-list>
</div>

</md-card-content>
</md-card>
15 changes: 15 additions & 0 deletions src/app/components/components/animations/animations.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import { Component, HostBinding } from '@angular/core';

import { slideInDownAnimation } from '../../../app.animations';
import { TdRotateAnimation } from '../../../../platform/core/common/animations/rotate/rotate.animation';
import { TdBounceAnimation } from '../../../../platform/core/common/animations/bounce/bounce.animation';
import { TdFlashAnimation } from '../../../../platform/core/common/animations/flash/flash.animation';
import { TdHeadshakeAnimation } from '../../../../platform/core/common/animations/headshake/headshake.animation';
import { TdJelloAnimation } from '../../../../platform/core/common/animations/jello/jello.animation';
import { TdPulseAnimation } from '../../../../platform/core/common/animations/pulse/pulse.animation';

@Component({
selector: 'animations-demo',
Expand All @@ -12,6 +17,11 @@ import { TdRotateAnimation } from '../../../../platform/core/common/animations/r
TdRotateAnimation(),
TdRotateAnimation({ anchor: 'tdRotate545', duration: 750, degrees: 545, ease: 'ease-in' }),
TdRotateAnimation({ anchor: 'tdRotateNeg45', duration: 500, degrees: -45 }),
TdBounceAnimation({ anchor: 'tdBounce', duration: 750 }),
TdFlashAnimation({ anchor: 'tdFlash', duration: 750 }),
TdHeadshakeAnimation({ anchor: 'tdHeadshake', duration: 1500 }),
TdJelloAnimation({ anchor: 'tdJello', duration: 1000 }),
TdPulseAnimation({ anchor: 'tdPulse', duration: 750 }),
],
})
export class AnimationsComponent {
Expand All @@ -21,5 +31,10 @@ export class AnimationsComponent {

rotateState1: boolean = false;
rotateState2: boolean = false;
bounceState: boolean = false;
flashState: boolean = false;
headshakeState: boolean = false;
jelloState: boolean = false;
pulseState: boolean = false;

}
36 changes: 36 additions & 0 deletions src/platform/core/common/animations/bounce/bounce.animation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

import { trigger, state, style, keyframes, transition, animate, AnimationTriggerMetadata, AUTO_STYLE } from '@angular/animations';
import { IAnimationOptions } from '../common/interfaces';

/**
* Function TdBounceAnimation
*
* params:
* * anchor: Name of the anchor that will attach to a dom element in the components template that will contain the animation.
* * duration: Duration the animation will run in miliseconds. Defaults to 500 ms.
*
* Returns an [AnimationTriggerMetadata] object with states for a boolean trigger based bounce animation.
*
* usage: [@myAnchorName]="true|false"
*/
export function TdBounceAnimation(bounceOptions: IAnimationOptions = {}): AnimationTriggerMetadata {
return trigger(bounceOptions.anchor || 'tdbounce', [
state('0', style({
transform: 'translate3d(0, 0, 0)',
})),
state('1', style({
transform: 'translate3d(0, 0, 0)',
})),
transition('0 <=> 1', animate((bounceOptions.duration || 500) + 'ms', keyframes([
style({animationTimingFunction: 'cubic-bezier(0.215, 0.610, 0.355, 1.000)', transform: 'translate3d(0, 0, 0)', offset: 0}),
style({animationTimingFunction: 'cubic-bezier(0.215, 0.610, 0.355, 1.000)', transform: 'translate3d(0, 0, 0)', offset: 0.2}),
style({animationTimingFunction: 'cubic-bezier(0.755, 0.050, 0.855, 0.060)', transform: 'translate3d(0, -30px, 0)', offset: 0.4}),
style({animationTimingFunction: 'cubic-bezier(0.755, 0.050, 0.855, 0.060)', transform: 'translate3d(0, -30px, 0)', offset: 0.43}),
style({animationTimingFunction: 'cubic-bezier(0.215, 0.610, 0.355, 1.000)', transform: 'translate3d(0, 0, 0)', offset: 0.53}),
style({animationTimingFunction: 'cubic-bezier(0.755, 0.050, 0.855, 0.060)', transform: 'translate3d(0, -15px, 0)', offset: .7}),
style({animationTimingFunction: 'cubic-bezier(0.215, 0.610, 0.355, 1.000)', transform: 'translate3d(0, 0, 0)', offset: 0.8}),
style({transform: 'translate3d(0, -4px, 0)', offset: .9}),
style({animationTimingFunction: 'cubic-bezier(0.215, 0.610, 0.355, 1.000)', transform: 'translate3d(0, 0, 0)', offset: 1.0}),
]))),
]);
}
32 changes: 32 additions & 0 deletions src/platform/core/common/animations/flash/flash.animation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

import { trigger, state, style, keyframes, transition, animate, AnimationTriggerMetadata, AUTO_STYLE } from '@angular/animations';
import { IAnimationOptions } from '../common/interfaces';

/**
* Function TdFlashAnimation
*
* params:
* * anchor: Name of the anchor that will attach to a dom element in the components template that will contain the animation.
* * duration: Duration the animation will run in miliseconds. Defaults to 500 ms.
*
* Returns an [AnimationTriggerMetadata] object with states for a boolean trigger based flash animation.
*
* usage: [@myAnchorName]="true|false"
*/
export function TdFlashAnimation(flashOptions: IAnimationOptions = {}): AnimationTriggerMetadata {
return trigger(flashOptions.anchor || 'tdflash', [
state('0', style({
opacity: 1,
})),
state('1', style({
opacity: 1,
})),
transition('0 <=> 1', animate((flashOptions.duration || 500) + 'ms', keyframes([
style({opacity: 1, offset: 0}),
style({opacity: 0, offset: 0.25}),
style({opacity: 1, offset: 0.5}),
style({opacity: 0, offset: 0.75}),
style({opacity: 1, offset: 1.0}),
]))),
]);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

import { trigger, state, style, keyframes, transition, animate, AnimationTriggerMetadata, AUTO_STYLE } from '@angular/animations';
import { IAnimationOptions } from '../common/interfaces';

/**
* Function TdHeadshakeAnimation
*
* params:
* * anchor: Name of the anchor that will attach to a dom element in the components template that will contain the animation.
* * duration: Duration the animation will run in miliseconds. Defaults to 500 ms.
*
* Returns an [AnimationTriggerMetadata] object with states for a boolean trigger based headshake animation.
*
* usage: [@myAnchorName]="true|false"
*/
export function TdHeadshakeAnimation(headshakeOptions: IAnimationOptions = {}): AnimationTriggerMetadata {
return trigger(headshakeOptions.anchor || 'tdheadshake', [
state('0', style({
transform: 'translateX(0)',
})),
state('1', style({
transform: 'translateX(0)',
})),
transition('0 <=> 1', animate((headshakeOptions.duration || 500) + 'ms', keyframes([
style({transform: 'translateX(0)', offset: 0}),
style({transform: 'translateX(-6px) rotateY(-9deg)', offset: 0.065}),
style({transform: 'translateX(5px) rotateY(7deg)', offset: 0.185}),
style({transform: 'translateX(-3px) rotateY(-5deg)', offset: 0.315}),
style({transform: 'translateX(2px) rotateY(3deg)', offset: 0.435}),
style({transform: 'translateX(0)', offset: 0.50}),
]))),
]);
}
36 changes: 36 additions & 0 deletions src/platform/core/common/animations/jello/jello.animation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

import { trigger, state, style, keyframes, transition, animate, AnimationTriggerMetadata, AUTO_STYLE } from '@angular/animations';
import { IAnimationOptions } from '../common/interfaces';

/**
* Function TdJelloAnimation
*
* params:
* * anchor: Name of the anchor that will attach to a dom element in the components template that will contain the animation.
* * duration: Duration the animation will run in miliseconds. Defaults to 500 ms.
*
* Returns an [AnimationTriggerMetadata] object with states for a boolean trigger based jello animation.
*
* usage: [@myAnchorName]="true|false"
*/
export function TdJelloAnimation(jelloOptions: IAnimationOptions = {}): AnimationTriggerMetadata {
return trigger(jelloOptions.anchor || 'tdjello', [
state('0', style({
transform: 'none',
})),
state('1', style({
transform: 'none',
})),
transition('0 <=> 1', animate((jelloOptions.duration || 500) + 'ms', keyframes([
style({transform: 'none', offset: 0}),
style({transform: 'none', offset: 0.011}),
style({transform: 'skewX(-12.5deg) skewY(-12.5deg)', offset: 0.222}),
style({transform: 'skewX(6.25deg) skewY(6.25deg)', offset: 0.333}),
style({transform: 'skewX(-3.125deg) skewY(-3.125deg)', offset: 0.444}),
style({transform: 'skewX(1.5625deg) skewY(1.5625deg)', offset: 0.555}),
style({transform: 'skewX(-0.78125deg) skewY(-0.78125deg)', offset: 0.666}),
style({transform: 'skewX(0.390625deg) skewY(0.390625deg)', offset: 0.777}),
style({transform: 'skewX(-0.1953125deg) skewY(-0.1953125deg)', offset: 0.888}),
]))),
]);
}
30 changes: 30 additions & 0 deletions src/platform/core/common/animations/pulse/pulse.animation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

import { trigger, state, style, keyframes, transition, animate, AnimationTriggerMetadata, AUTO_STYLE } from '@angular/animations';
import { IAnimationOptions } from '../common/interfaces';

/**
* Function TdPulseAnimation
*
* params:
* * anchor: Name of the anchor that will attach to a dom element in the components template that will contain the animation.
* * duration: Duration the animation will run in miliseconds. Defaults to 500 ms.
*
* Returns an [AnimationTriggerMetadata] object with states for a boolean trigger based pulse animation.
*
* usage: [@myAnchorName]="true|false"
*/
export function TdPulseAnimation(pulseOptions: IAnimationOptions = {}): AnimationTriggerMetadata {
return trigger(pulseOptions.anchor || 'tdpulse', [
state('0', style({
transform: 'scale3d(1, 1, 1)',
})),
state('1', style({
transform: 'scale3d(1, 1, 1)',
})),
transition('0 <=> 1', animate((pulseOptions.duration || 500) + 'ms', keyframes([
style({transform: 'scale3d(1, 1, 1)', offset: 0}),
style({transform: 'scale3d(1.05, 1.05, 1.05)', offset: 0.5}),
style({transform: 'scale3d(1, 1, 1)', offset: 1.0}),
]))),
]);
}
5 changes: 5 additions & 0 deletions src/platform/core/common/common.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ export { TdToggleDirective, TdFadeDirective };
export { TdRotateAnimation, IRotateAnimation } from './animations/rotate/rotate.animation';
export { TdCollapseAnimation } from './animations/collapse/collapse.animation';
export { TdFadeInOutAnimation } from './animations/fade/fadeInOut.animation';
export { TdBounceAnimation } from './animations/bounce/bounce.animation';
export { TdFlashAnimation } from './animations/flash/flash.animation';
export { TdHeadshakeAnimation } from './animations/headshake/headshake.animation';
export { TdJelloAnimation } from './animations/jello/jello.animation';
export { TdPulseAnimation } from './animations/pulse/pulse.animation';

/**
* BEHAVIORS
Expand Down

0 comments on commit f106ccf

Please sign in to comment.