Platform.ready() for excellence

This commit is contained in:
Adam Bradley
2015-06-26 10:49:03 -05:00
parent ef82b00f45
commit 69e7d7c69f
7 changed files with 68 additions and 84 deletions

View File

@ -29,8 +29,6 @@ export function rafPromise() {
return new Promise(resolve => raf(resolve));
}
export const isSVG = val => window.SVGElement && (val instanceof window.SVGElement);
export let CSS = {};
(function() {
// transform
@ -116,7 +114,7 @@ function cssPromise(el:Element, eventNames, animationName) {
export function ready() {
return new Promise(resolve => {
if (document.readyState === 'complete' || document.readyState === 'interactive') {
setTimeout(resolve);
resolve();
} else {
@ -135,7 +133,7 @@ export function ready() {
export function windowLoad() {
return new Promise(resolve => {
if (document.readyState === 'complete') {
setTimeout(resolve);
resolve();
} else {
function completed() {
@ -147,25 +145,3 @@ export function windowLoad() {
}
});
}
export function hasAttribute(el: Element, attributeName) {
return el.hasAttribute(attributeName);
}
export function addClass(el: Element, ...classNames) {
for (let c of classNames) {
el.classList.add(c);
}
}
export function getChildIndex(el: Element) {
let child;
let parent = el.parentNode;
for(let i = 0, j = parent.children.length; i < j; i++) {
child = parent.children[i];
if(child === el) {
return i;
}
}
return -1;
}

View File

@ -1,24 +0,0 @@
/**
* TODO: Wait until the new ElementRef stuff lands in Angular2.
import {RenderedElement} from 'ionic/util/render/element';
export class DomRenderedElement extends RenderedElement {
constructor(domElement: Element) {
super(domElement)
}
removeClass(className) {
this.element.classList.remove(classList);
}
addClass(...classNames) {
for(let c of classNames) {
this.element.classList.add(c);
}
}
removeClass(...classNames) {
for(let c of classes) {
this.element.classList.remove(c);
}
}
}
*/

View File

@ -1,15 +0,0 @@
/**
* TODO: Wait until the new ElementRef stuff lands in Angular2
export class RenderedElement {
constructor(element) {
this.element = element;
}
_notImplemented(fnName) {
console.error("RenderedElement." + fnName + "addClass is not implemented. Use a concrete class like DomRenderedElement instead.");
}
addClass(...classNames) { this._notImplemented('addClass'); }
removeClass(className) { this._notImplemented('removeClass'); }
removeClasses(...classNames) { this._notImplemented('removeClasses'); }
}
*/