on document ready

master
谢桂纲 8 years ago
parent 70981cd205
commit 865eb0ddb7

@ -5,3 +5,17 @@ function componentToHex(c) {
var hex = c.toString(16);
return hex.length == 1 ? "0" + hex : hex;
}
var $ = (fn: any) => {
// Sanity check
if (typeof fn !== 'function') return;
// If document is already loaded, run method
if (document.readyState === 'complete') {
return fn();
} else {
// Otherwise, wait until document is loaded
document.addEventListener('DOMContentLoaded', fn, false);
}
};

@ -18,6 +18,11 @@ class Graphics {
constructor(div: string) {
this.svg = document.createElement("svg");
this.container = document.getElementById(div);
console.log(div);
console.log(this.svg);
console.log(this.container);
this.container.appendChild(this.svg);
}

@ -1,5 +1,10 @@
/// <reference path="svg.ts"/>
var svg = new Graphics("test-svg");
$(function () {
var svg = new Graphics("test-svg")
.size(1000, 1000)
.drawRectangle(new Rectangle(10, 20, 200, 300));
});
svg.size(1000,1000).drawRectangle(new Rectangle(10,20,200,300));

Loading…
Cancel
Save