mirror of
https://github.com/konvajs/konva.git
synced 2025-10-15 12:34:52 +08:00
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:
@@ -49,14 +49,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
|
||||
|
18
src/Stage.js
18
src/Stage.js
@@ -11,13 +11,21 @@
|
||||
* @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
|
||||
@@ -55,7 +63,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
|
||||
|
Reference in New Issue
Block a user