possible to pass elementRef to Animation

This commit is contained in:
Adam Bradley
2015-06-27 12:36:38 -05:00
parent 504ab46eb3
commit 6bb2035e55
2 changed files with 46 additions and 29 deletions

View File

@ -25,7 +25,7 @@ let AnimationRegistry = {};
export class Animation {
constructor(el) {
constructor(ele) {
this._el = [];
this._chld = [];
this._ani = [];
@ -39,27 +39,44 @@ export class Animation {
this._plays = [];
this._finishes = [];
this.elements(el);
this.elements(ele);
}
elements(el) {
if (el) {
if (typeof el === 'string') {
el = document.querySelectorAll(el);
elements(ele) {
if (ele) {
if (typeof ele === 'string') {
// string query selector
ele = document.querySelectorAll(ele);
}
if (el.length) {
for (let i = 0; i < el.length; i++) {
this._el.push(el[i]);
if (ele.length) {
// array of elements
for (let i = 0; i < ele.length; i++) {
this.addElement(ele[i]);
}
} else if (el.nodeType) {
this._el.push(el);
} else {
// single element
this.addElement(ele);
}
}
return this;
}
addElement(ele) {
// ensure only HTML Element nodes
if (ele) {
if (ele.nativeElement) {
// angular ElementRef
ele = ele.nativeElement;
}
if (ele.nodeType === 1) {
this._el.push(ele);
}
}
}
parent(parentAnimation) {
this._parent = parentAnimation;
return this;