mirror of
https://github.com/konvajs/konva.git
synced 2025-04-05 20:48:28 +08:00
update Konva.Node.create flow
This commit is contained in:
parent
981f245833
commit
026423402d
@ -4,11 +4,15 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## [Not released][Not released]
|
||||
|
||||
### Added
|
||||
- RGBA filter =. Thanls to [@codefo](https://github.com/codefo)
|
||||
|
||||
### Fixed
|
||||
- Correct calculation in `getClientRect` method of `Konva.Line` and `Konva.Container`.
|
||||
|
||||
### Changed
|
||||
- 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]
|
||||
|
||||
|
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
|
||||
* serialized object huge). If your app uses custom shapes, images, and
|
||||
* event handlers (it probably does), then you need to select the appropriate
|
||||
@ -1707,12 +1707,15 @@
|
||||
* and setImage() methods
|
||||
* @method
|
||||
* @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
|
||||
* creating a stage node
|
||||
*/
|
||||
Konva.Node.create = function(json, container) {
|
||||
return this._createNode(JSON.parse(json), container);
|
||||
Konva.Node.create = function(data, container) {
|
||||
if (Konva.Util._isString(data)) {
|
||||
data = JSON.parse(data);
|
||||
}
|
||||
return this._createNode(data, container);
|
||||
};
|
||||
Konva.Node._createNode = function(obj, container) {
|
||||
var className = Konva.Node.prototype.getClassName.call(obj),
|
||||
|
@ -2167,6 +2167,17 @@ suite('Node', function() {
|
||||
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() {
|
||||
var stage = addStage();
|
||||
|
Loading…
Reference in New Issue
Block a user