changed Stage constructor to accept a config object. Now that Stage is a node, every KineticJS object requires the same config object which bubbles up through the parent classes

This commit is contained in:
Eric Rowell
2012-03-22 23:17:52 -07:00
parent 0da8adfb6e
commit 7ced50f694
6 changed files with 489 additions and 122 deletions

26
dist/kinetic-core.js vendored
View File

@@ -296,14 +296,6 @@ Kinetic.Node = function(config) {
}
}
}
// overrides
if(this.centerOffset.x === undefined) {
this.centerOffset.x = 0;
}
if(this.centerOffset.y === undefined) {
this.centerOffset.y = 0;
}
};
/*
* Node methods
@@ -968,13 +960,21 @@ Kinetic.Container.prototype = {
* @param {int} width
* @param {int} height
*/
Kinetic.Stage = function(cont, width, height) {
Kinetic.Stage = function(config) {
/*
* if container is a string, assume it's an id for
* a DOM element
*/
if(typeof config.container === 'string') {
config.container = document.getElementById(config.container);
}
this.className = 'Stage';
this.container = typeof cont === 'string' ? document.getElementById(cont) : cont;
this.container = config.container;
this.content = document.createElement('div');
this.width = width;
this.height = height;
this.width = config.width;
this.height = config.height;
this.scale = {
x: 1,
y: 1
@@ -1012,7 +1012,7 @@ Kinetic.Stage = function(cont, width, height) {
// call super constructors
Kinetic.Container.apply(this, []);
Kinetic.Node.apply(this, []);
Kinetic.Node.apply(this, [config]);
};
/*
* Stage methods

File diff suppressed because one or more lines are too long