Deep cloning. Cloning also clones children. Also added unit test to confirm that it's working as expected.

This commit is contained in:
David Johansson
2012-09-02 23:44:00 +02:00
parent 8883e80bfe
commit 580e52689c
4 changed files with 145 additions and 4 deletions

18
dist/kinetic-core.js vendored
View File

@@ -3,7 +3,7 @@
* http://www.kineticjs.com/
* Copyright 2012, Eric Rowell
* Licensed under the MIT or GPL Version 2 licenses.
* Date: Aug 26 2012
* Date: Sep 02 2012
*
* Copyright (C) 2011 - 2012 by Eric Rowell
*
@@ -2605,6 +2605,22 @@ Kinetic.Container.prototype = {
return false;
},
/**
* clone node
* @name clone
* @methodOf Kinetic.Node.prototype
* @param {Object} attrs override attrs
*/
clone: function(obj) {
// call super method
var node = Kinetic.Node.prototype.clone.call(this, obj)
// perform deep clone on containers
for(var key in this.children) {
node.add(this.children[key].clone());
}
return node;
},
/**
* get shapes that intersect a point
* @name getIntersections

File diff suppressed because one or more lines are too long