Skip to content

Commit

Permalink
chore(all): prepare release 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
EisenbergEffect committed Feb 27, 2017
1 parent a0e4681 commit a35e507
Show file tree
Hide file tree
Showing 11 changed files with 138 additions and 80 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aurelia-animator-velocity",
"version": "1.0.1",
"version": "1.1.0",
"description": "An implementation of the abstract Animator interface from templating which enables velocity-based animations.",
"keywords": [
"aurelia",
Expand Down
27 changes: 17 additions & 10 deletions dist/amd/aurelia-animator-velocity.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,20 @@ define(['exports', 'velocity-animate', 'aurelia-templating', 'aurelia-pal', 'vel
}

VelocityAnimator.prototype.animate = function animate(element, nameOrProps, options, silent) {
if (!element) return Promise.reject(new Error('first argument (element) must be defined'));
if (!nameOrProps) return Promise.reject(new Error('second argument (animation name or properties) must be defined'));
if (options && (!(options instanceof Object) || Array.isArray(options))) return Promise.reject(new Error('third argument (options) must be an Object'));

this.isAnimating = true;

var _this = this;
var overrides = {
var optionOverrides = {
complete: function complete(el) {
_this.isAnimating = false;
if (!silent) dispatch(el, 'animateDone');
if (options && options.complete) options.complete.apply(this, arguments);
}
};
if (!element) return Promise.reject(new Error('invalid first argument'));

if (typeof element === 'string') element = this.container.querySelectorAll(element);

Expand All @@ -59,13 +63,12 @@ define(['exports', 'velocity-animate', 'aurelia-templating', 'aurelia-pal', 'vel

if (typeof nameOrProps === 'string') {
nameOrProps = this.resolveEffectAlias(nameOrProps);
if (!this.effects[nameOrProps]) return Promise.reject(new Error('effect with name `' + nameOrProps + '` was not found'));
}

var opts = Object.assign({}, this.options, options, overrides);
var p = (0, _velocityAnimate2.default)(element, nameOrProps, opts);

if (!p) return Promise.reject(new Error('invalid element used for animator.animate'));
return p;
var velocityOptions = Object.assign({}, this.options, options, optionOverrides);
var velocityPromise = (0, _velocityAnimate2.default)(element, nameOrProps, velocityOptions);
return velocityPromise ? velocityPromise : Promise.reject(new Error('velocity animation failed due to invalid arguments'));
};

VelocityAnimator.prototype.stop = function stop(element, clearQueue) {
Expand Down Expand Up @@ -221,7 +224,7 @@ define(['exports', 'velocity-animate', 'aurelia-templating', 'aurelia-pal', 'vel
break;

default:
throw new Error(name + ' animation is not supported.');
if (!this.effects[this.resolveEffectAlias(name)]) throw new Error(name + ' animation is not supported.');
}

var opts = Object.assign({}, this.options, attrOpts, options, overrides);
Expand Down Expand Up @@ -280,12 +283,16 @@ define(['exports', 'velocity-animate', 'aurelia-templating', 'aurelia-pal', 'vel
}

text = text.replace('{', '').replace('}', '');
var pairs = text.split(',');
var pairs = text.split(/[,]+(?![^\[]+\])/);
var obj = {};

for (var i = 0; i < pairs.length; ++i) {
var keyAndValue = pairs[i].split(':');
obj[keyAndValue[0].trim()] = keyAndValue[1].trim();
var value = keyAndValue[1].trim();

if (value[0] === '[' && value[value.length - 1] === ']' && value.indexOf(',') > -1) value = value.replace('[', '').replace(']', '').split(',');

obj[keyAndValue[0].trim()] = value;
}

return obj;
Expand Down
5 changes: 3 additions & 2 deletions dist/aurelia-animator-velocity.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ export declare class VelocityAnimator {
* @param element Element or array of elements to animate
* @param nameOrProps Element properties to animate
* @param options Animation options
* @return resolved when animation is complete
* @param silent Disable animation events
* @return resolves to Array (element was an HTMLElement) or NodeList (element was a string or NodeList) when complete
*/
animate(element: any, nameOrProps: any, options?: any, silent?: boolean): Promise<VelocityAnimator>;
animate(element: any, nameOrProps: any, options?: Object, silent?: boolean): Promise<any>;

/**
* Stop an animation
Expand Down
59 changes: 35 additions & 24 deletions dist/aurelia-animator-velocity.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ export class VelocityAnimator {
/**
* Default options for velocity
*/
options:any = {
options: any = {
duration: 400,
easing: 'linear'
};

isAnimating:boolean = false;
isAnimating: boolean = false;

enterAnimation:any = {properties: ':enter', options: {easing: 'ease-in', duration: 200}};
leaveAnimation:any = {properties: ':leave', options: {easing: 'ease-in', duration: 200}};
enterAnimation: any = { properties: ':enter', options: { easing: 'ease-in', duration: 200 }};
leaveAnimation: any = { properties: ':leave', options: { easing: 'ease-in', duration: 200 }};

/**
* Array of easing names that can be used with this animator
Expand All @@ -29,15 +29,15 @@ export class VelocityAnimator {
/**
* Effects mapped by name
*/
effects:any = {
effects: any = {
':enter': 'fadeIn',
':leave': 'fadeOut'
};

/**
* Creates an instance of VelocityAnimator.
*/
constructor(container:any) {
constructor(container: any) {
this.container = container || DOM;
this.easings = Object.assign(velocity.Easings, this.easings);
this.effects = Object.assign(velocity.Redirects, this.effects);
Expand All @@ -51,40 +51,46 @@ export class VelocityAnimator {
* @param element Element or array of elements to animate
* @param nameOrProps Element properties to animate
* @param options Animation options
* @return resolved when animation is complete
* @param silent Disable animation events
* @return resolves to Array (element was an HTMLElement) or NodeList (element was a string or NodeList) when complete
*/
animate(element:any, nameOrProps:any, options?:any, silent?:boolean): Promise<VelocityAnimator> {
animate(element: any, nameOrProps: any, options?: Object, silent?: boolean): Promise<any> {
// validate input
if (!element) return Promise.reject(new Error('first argument (element) must be defined'));
if (!nameOrProps) return Promise.reject(new Error('second argument (animation name or properties) must be defined'));
if (options && (!(options instanceof Object) || Array.isArray(options))) return Promise.reject(new Error('third argument (options) must be an Object'));

// mark as animating
this.isAnimating = true;
let _this = this;
let overrides = {

// default values
const _this = this;
const optionOverrides = {
complete: function(el) {
_this.isAnimating = false;
if (!silent) dispatch(el, 'animateDone');
if (options && options.complete) options.complete.apply(this, arguments);
}
};
if (!element) return Promise.reject(new Error('invalid first argument'));

//resolve selectors
// if element was a string, search for the elements in the container
if (typeof element === 'string') element = this.container.querySelectorAll(element);

//if nothing was found or no element was passed resolve the promise immediatly
// if there are no elements to animate, resolve immediately
if (!element || element.length === 0) return Promise.resolve(element);

if (!silent) dispatch(element, 'animateBegin');

// if nameOrProps was a string, then find the effect with that name
if (typeof nameOrProps === 'string') {
nameOrProps = this.resolveEffectAlias(nameOrProps);
//if(!nameOrProps) Promise.reject(new Error(`effect alias ${nameOrProps} not found`));
if (!this.effects[nameOrProps]) return Promise.reject(new Error(`effect with name \`${nameOrProps}\` was not found`));
}

//try to run the animation
let opts = Object.assign({}, this.options, options, overrides);
let p = velocity(element, nameOrProps, opts);

//reject the promise if Velocity didn't return a Promise due to invalid arguments
if (!p) return Promise.reject(new Error('invalid element used for animator.animate'));
return p;
// try to run the animation
const velocityOptions = Object.assign({}, this.options, options, optionOverrides);
const velocityPromise = velocity(element, nameOrProps, velocityOptions);
return (velocityPromise) ? velocityPromise : Promise.reject(new Error('velocity animation failed due to invalid arguments'));
}

/**
Expand Down Expand Up @@ -322,7 +328,7 @@ export class VelocityAnimator {
break;

default:
throw new Error(`${name} animation is not supported.`);
if (!this.effects[this.resolveEffectAlias(name)]) throw new Error(`${name} animation is not supported.`);
}

let opts = Object.assign({}, this.options, attrOpts, options, overrides);
Expand Down Expand Up @@ -397,12 +403,17 @@ function parseJSObject(text) {
}

text = text.replace('{', '').replace('}', '');
let pairs = text.split(',');
let pairs = text.split(/[,]+(?![^\[]+\])/);
let obj = {};

for (let i = 0; i < pairs.length; ++i) {
let keyAndValue = pairs[i].split(':');
obj[keyAndValue[0].trim()] = keyAndValue[1].trim();
let value = keyAndValue[1].trim();

// if value is an array, then convert it into an array object from string
if (value[0] === '[' && value[value.length - 1] === ']' && value.indexOf(',') > -1) value = value.replace('[', '').replace(']', '').split(',');

obj[keyAndValue[0].trim()] = value;
}

return obj;
Expand Down
27 changes: 17 additions & 10 deletions dist/commonjs/aurelia-animator-velocity.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,20 @@ var VelocityAnimator = exports.VelocityAnimator = function () {
}

VelocityAnimator.prototype.animate = function animate(element, nameOrProps, options, silent) {
if (!element) return Promise.reject(new Error('first argument (element) must be defined'));
if (!nameOrProps) return Promise.reject(new Error('second argument (animation name or properties) must be defined'));
if (options && (!(options instanceof Object) || Array.isArray(options))) return Promise.reject(new Error('third argument (options) must be an Object'));

this.isAnimating = true;

var _this = this;
var overrides = {
var optionOverrides = {
complete: function complete(el) {
_this.isAnimating = false;
if (!silent) dispatch(el, 'animateDone');
if (options && options.complete) options.complete.apply(this, arguments);
}
};
if (!element) return Promise.reject(new Error('invalid first argument'));

if (typeof element === 'string') element = this.container.querySelectorAll(element);

Expand All @@ -62,13 +66,12 @@ var VelocityAnimator = exports.VelocityAnimator = function () {

if (typeof nameOrProps === 'string') {
nameOrProps = this.resolveEffectAlias(nameOrProps);
if (!this.effects[nameOrProps]) return Promise.reject(new Error('effect with name `' + nameOrProps + '` was not found'));
}

var opts = Object.assign({}, this.options, options, overrides);
var p = (0, _velocityAnimate2.default)(element, nameOrProps, opts);

if (!p) return Promise.reject(new Error('invalid element used for animator.animate'));
return p;
var velocityOptions = Object.assign({}, this.options, options, optionOverrides);
var velocityPromise = (0, _velocityAnimate2.default)(element, nameOrProps, velocityOptions);
return velocityPromise ? velocityPromise : Promise.reject(new Error('velocity animation failed due to invalid arguments'));
};

VelocityAnimator.prototype.stop = function stop(element, clearQueue) {
Expand Down Expand Up @@ -224,7 +227,7 @@ var VelocityAnimator = exports.VelocityAnimator = function () {
break;

default:
throw new Error(name + ' animation is not supported.');
if (!this.effects[this.resolveEffectAlias(name)]) throw new Error(name + ' animation is not supported.');
}

var opts = Object.assign({}, this.options, attrOpts, options, overrides);
Expand Down Expand Up @@ -283,12 +286,16 @@ function parseJSObject(text) {
}

text = text.replace('{', '').replace('}', '');
var pairs = text.split(',');
var pairs = text.split(/[,]+(?![^\[]+\])/);
var obj = {};

for (var i = 0; i < pairs.length; ++i) {
var keyAndValue = pairs[i].split(':');
obj[keyAndValue[0].trim()] = keyAndValue[1].trim();
var value = keyAndValue[1].trim();

if (value[0] === '[' && value[value.length - 1] === ']' && value.indexOf(',') > -1) value = value.replace('[', '').replace(']', '').split(',');

obj[keyAndValue[0].trim()] = value;
}

return obj;
Expand Down
29 changes: 18 additions & 11 deletions dist/es2015/aurelia-animator-velocity.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,20 @@ export let VelocityAnimator = class VelocityAnimator {
}

animate(element, nameOrProps, options, silent) {
if (!element) return Promise.reject(new Error('first argument (element) must be defined'));
if (!nameOrProps) return Promise.reject(new Error('second argument (animation name or properties) must be defined'));
if (options && (!(options instanceof Object) || Array.isArray(options))) return Promise.reject(new Error('third argument (options) must be an Object'));

this.isAnimating = true;
let _this = this;
let overrides = {

const _this = this;
const optionOverrides = {
complete: function (el) {
_this.isAnimating = false;
if (!silent) dispatch(el, 'animateDone');
if (options && options.complete) options.complete.apply(this, arguments);
}
};
if (!element) return Promise.reject(new Error('invalid first argument'));

if (typeof element === 'string') element = this.container.querySelectorAll(element);

Expand All @@ -44,13 +48,12 @@ export let VelocityAnimator = class VelocityAnimator {

if (typeof nameOrProps === 'string') {
nameOrProps = this.resolveEffectAlias(nameOrProps);
if (!this.effects[nameOrProps]) return Promise.reject(new Error(`effect with name \`${ nameOrProps }\` was not found`));
}

let opts = Object.assign({}, this.options, options, overrides);
let p = velocity(element, nameOrProps, opts);

if (!p) return Promise.reject(new Error('invalid element used for animator.animate'));
return p;
const velocityOptions = Object.assign({}, this.options, options, optionOverrides);
const velocityPromise = velocity(element, nameOrProps, velocityOptions);
return velocityPromise ? velocityPromise : Promise.reject(new Error('velocity animation failed due to invalid arguments'));
}

stop(element, clearQueue) {
Expand Down Expand Up @@ -194,7 +197,7 @@ export let VelocityAnimator = class VelocityAnimator {
break;

default:
throw new Error(`${ name } animation is not supported.`);
if (!this.effects[this.resolveEffectAlias(name)]) throw new Error(`${ name } animation is not supported.`);
}

let opts = Object.assign({}, this.options, attrOpts, options, overrides);
Expand Down Expand Up @@ -251,12 +254,16 @@ function parseJSObject(text) {
}

text = text.replace('{', '').replace('}', '');
let pairs = text.split(',');
let pairs = text.split(/[,]+(?![^\[]+\])/);
let obj = {};

for (let i = 0; i < pairs.length; ++i) {
let keyAndValue = pairs[i].split(':');
obj[keyAndValue[0].trim()] = keyAndValue[1].trim();
let value = keyAndValue[1].trim();

if (value[0] === '[' && value[value.length - 1] === ']' && value.indexOf(',') > -1) value = value.replace('[', '').replace(']', '').split(',');

obj[keyAndValue[0].trim()] = value;
}

return obj;
Expand Down
Loading

0 comments on commit a35e507

Please sign in to comment.