mirror of
https://github.com/konvajs/konva.git
synced 2025-09-18 18:27:58 +08:00
update Konva.Node.create flow
This commit is contained in:
@@ -4,11 +4,15 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
|
|
||||||
## [Not released][Not released]
|
## [Not released][Not released]
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- RGBA filter =. Thanls to [@codefo](https://github.com/codefo)
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Correct calculation in `getClientRect` method of `Konva.Line` and `Konva.Container`.
|
- Correct calculation in `getClientRect` method of `Konva.Line` and `Konva.Container`.
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Dragging now works much better. If your pointer is out of stage content dragging will still continue.
|
- Dragging now works much better. If your pointer is out of stage content dragging will still continue.
|
||||||
|
- `Konva.Node.create` not works with objects.
|
||||||
|
|
||||||
## [0.9.5][2015-05-28]
|
## [0.9.5][2015-05-28]
|
||||||
|
|
||||||
|
11
src/Node.js
11
src/Node.js
@@ -1699,7 +1699,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create node with JSON string. De-serializtion does not generate custom
|
* create node with JSON string or an Object. De-serializtion does not generate custom
|
||||||
* shape drawing functions, images, or event handlers (this would make the
|
* shape drawing functions, images, or event handlers (this would make the
|
||||||
* serialized object huge). If your app uses custom shapes, images, and
|
* serialized object huge). If your app uses custom shapes, images, and
|
||||||
* event handlers (it probably does), then you need to select the appropriate
|
* event handlers (it probably does), then you need to select the appropriate
|
||||||
@@ -1707,12 +1707,15 @@
|
|||||||
* and setImage() methods
|
* and setImage() methods
|
||||||
* @method
|
* @method
|
||||||
* @memberof Konva.Node
|
* @memberof Konva.Node
|
||||||
* @param {String} json
|
* @param {String|Object} json string or object
|
||||||
* @param {Element} [container] optional container dom element used only if you're
|
* @param {Element} [container] optional container dom element used only if you're
|
||||||
* creating a stage node
|
* creating a stage node
|
||||||
*/
|
*/
|
||||||
Konva.Node.create = function(json, container) {
|
Konva.Node.create = function(data, container) {
|
||||||
return this._createNode(JSON.parse(json), container);
|
if (Konva.Util._isString(data)) {
|
||||||
|
data = JSON.parse(data);
|
||||||
|
}
|
||||||
|
return this._createNode(data, container);
|
||||||
};
|
};
|
||||||
Konva.Node._createNode = function(obj, container) {
|
Konva.Node._createNode = function(obj, container) {
|
||||||
var className = Konva.Node.prototype.getClassName.call(obj),
|
var className = Konva.Node.prototype.getClassName.call(obj),
|
||||||
|
@@ -2167,6 +2167,17 @@ suite('Node', function() {
|
|||||||
assert.equal(stage.toJSON(), json);
|
assert.equal(stage.toJSON(), json);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// ======================================================
|
||||||
|
test('create node using object', function() {
|
||||||
|
var node = new Konva.Circle({
|
||||||
|
id: 'test',
|
||||||
|
radius: 10
|
||||||
|
});
|
||||||
|
var clone = Konva.Node.create(node.toObject());
|
||||||
|
|
||||||
|
assert.deepEqual(node.toObject(), clone.toObject());
|
||||||
|
});
|
||||||
|
|
||||||
// ======================================================
|
// ======================================================
|
||||||
test('serialize stage with custom shape', function() {
|
test('serialize stage with custom shape', function() {
|
||||||
var stage = addStage();
|
var stage = addStage();
|
||||||
|
Reference in New Issue
Block a user