Skip to content

Commit

Permalink
Merge pull request #2284 from google/task/easing-selection
Browse files Browse the repository at this point in the history
Feature | Easing Presets
  • Loading branch information
maxyinger committed Jun 5, 2020
2 parents 6174928 + b71b2e0 commit f7d28ec
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
2 changes: 2 additions & 0 deletions assets/src/dashboard/animations/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

export { BEZIER } from '../constants';

export const ANIMATION_TYPES = {
BLINK_ON: 'blinkOn',
BOUNCE: 'bounce',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/**
* Internal dependencies
*/
import { ANIMATION_TYPES, FIELD_TYPES } from '../constants';
import { ANIMATION_TYPES, FIELD_TYPES, BEZIER } from '../constants';

export default {
id: {
Expand All @@ -43,6 +43,12 @@ export default {
values: ['normal', 'reverse', 'alternate', 'alternate-reverse'],
defaultValue: 'normal',
},
easingPreset: {
label: 'Easing Presets',
type: FIELD_TYPES.DROPDOWN,
values: Object.keys(BEZIER),
defaultValue: Object.keys(BEZIER)[0],
},
easing: {
type: FIELD_TYPES.TEXT,
},
Expand Down
5 changes: 4 additions & 1 deletion assets/src/dashboard/animations/parts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/**
* Internal dependencies
*/
import { ANIMATION_TYPES } from '../constants';
import { ANIMATION_TYPES, BEZIER } from '../constants';
import { AnimationBounce } from './bounce';
import { AnimationBlinkOn } from './blinkOn';
import { AnimationFade } from './fade';
Expand Down Expand Up @@ -58,6 +58,9 @@ export function AnimationPart(type, args) {
[ANIMATION_TYPES.ZOOM]: AnimationZoom,
}[type] || throughput;

args.easing = args.easing || BEZIER[args.easingPreset];
args.easingPreset = undefined;

return generator(args);
}

Expand Down
16 changes: 16 additions & 0 deletions assets/src/dashboard/constants/animation.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,26 @@
* limitations under the License.
*/
export const BEZIER = {
linear: 'linear',
inQuad: 'cubic-bezier(0.55, 0.085, 0.68, 0.53)',
outQuad: 'cubic-bezier(0.25, 0.46, 0.45, 0.94)',
inOutQuad: 'cubic-bezier(0.455, 0.03, 0.515, 0.955)',
inCubic: 'cubic-bezier(0.55, 0.055, 0.675, 0.19)',
outCubic: 'cubic-bezier(0.215, 0.61, 0.355, 1)',
inOutCubic: 'cubic-bezier(0.645, 0.045, 0.355, 1)',
inQuart: 'cubic-bezier(0.895, 0.03, 0.685, 0.22)',
outQuart: 'cubic-bezier(0.165, 0.84, 0.44, 1)',
inOutQuart: 'cubic-bezier(0.77, 0, 0.175, 1)',
inQuint: 'cubic-bezier(0.755, 0.05, 0.855, 0.06)',
outQuint: 'cubic-bezier(0.23, 1, 0.32, 1)',
inOutQuint: 'cubic-bezier(0.86, 0, 0.07, 1)',
inSine: 'cubic-bezier(0.47, 0, 0.745, 0.715)',
outSine: 'cubic-bezier(0.39, 0.575, 0.565, 1)',
inOutSine: 'cubic-bezier(0.445, 0.05, 0.55, 0.95)',
inExpo: 'cubic-bezier(0.95, 0.05, 0.795, 0.035)',
outExpo: 'cubic-bezier(0.19, 1, 0.22, 1)',
inOutExpo: 'cubic-bezier(1, 0, 0, 1)',
inCirc: 'cubic-bezier(0.6, 0.04, 0.98, 0.335)',
outCirc: 'cubic-bezier(0.075, 0.82, 0.165, 1)',
inOutCirc: 'cubic-bezier(0.785, 0.135, 0.15, 0.86)',
};

0 comments on commit f7d28ec

Please sign in to comment.