mirror of
https://github.com/konvajs/konva.git
synced 2025-10-08 00:14:23 +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:
26
dist/kinetic-core.js
vendored
26
dist/kinetic-core.js
vendored
@@ -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
|
||||
|
2
dist/kinetic-core.min.js
vendored
2
dist/kinetic-core.min.js
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user