From c7816642d75beaf9cf6899008048759e96794193 Mon Sep 17 00:00:00 2001 From: Eric Rowell Date: Mon, 20 May 2013 22:12:43 -0700 Subject: [PATCH] fixes #414 --- src/Container.js | 4 ++-- src/Layer.js | 5 ++--- tests/js/unit/layerTests.js | 28 +++++++++++++++++++++++++++- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/Container.js b/src/Container.js index 1db92a49..9cf7f5e6 100644 --- a/src/Container.js +++ b/src/Container.js @@ -33,9 +33,9 @@ child.index = children.length; child.parent = this; children.push(child); - this.fire('add', { + this._fire('add', { child: child - }, true); + }); // chainable return this; diff --git a/src/Layer.js b/src/Layer.js index 2ac64316..afd49ac8 100644 --- a/src/Layer.js +++ b/src/Layer.js @@ -6,12 +6,11 @@ _initLayer: function(config) { this.nodeType = 'Layer'; this.createAttrs(); - // call super constructor - Kinetic.Container.call(this, config); - this.canvas = new Kinetic.SceneCanvas(); this.canvas.getElement().style.position = 'absolute'; this.hitCanvas = new Kinetic.HitCanvas(); + // call super constructor + Kinetic.Container.call(this, config); }, /** * get visible intersection object that contains shape and pixel data. This is the preferred diff --git a/tests/js/unit/layerTests.js b/tests/js/unit/layerTests.js index c5c6f076..51a9a972 100644 --- a/tests/js/unit/layerTests.js +++ b/tests/js/unit/layerTests.js @@ -29,7 +29,7 @@ Test.Modules.LAYER = { test(style.backgroundColor === 'transparent', 'canvas backgroundColor style should be transparent'); }, - 'layer getIntersections()': function(containerId) { + 'layer getIntersection()': function(containerId) { var stage = new Kinetic.Stage({ container: containerId, width: 578, @@ -67,6 +67,32 @@ Test.Modules.LAYER = { test(layer.getIntersection(100, 100) === null, 'shape should be null'); + }, + 'set layer visibility': function(containerId) { + var stage = new Kinetic.Stage({ + container: containerId, + width: 578, + height: 200 + }); + var layer = new Kinetic.Layer({ + visible: false + }); + var rect = new Kinetic.Rect({ + x: 200, + width: 100, + height: 50, + fill: 'green', + stroke: 'black', + strokeWidth: 4, + scale: [3, 1], + draggable: true, + strokeScaleEnabled: false + }); + + rect.colorKey = '000000'; + + layer.add(rect); + stage.add(layer); }, 'redraw hit graph': function(containerId) { var stage = new Kinetic.Stage({