From 77c995ab5ee29fd6d3dc00805880fe65d072adcd Mon Sep 17 00:00:00 2001 From: liabru Date: Wed, 19 Mar 2014 22:39:18 +0000 Subject: [PATCH] constraints now support visibility --- src/constraint/Constraint.js | 10 +++++++--- src/render/Render.js | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/constraint/Constraint.js b/src/constraint/Constraint.js index 29930b8..d3854ff 100644 --- a/src/constraint/Constraint.js +++ b/src/constraint/Constraint.js @@ -42,9 +42,13 @@ var Constraint = {}; constraint.length = constraint.length || length || _minLength; // render - constraint.render = constraint.render || {}; - constraint.render.lineWidth = constraint.render.lineWidth || 2; - constraint.render.strokeStyle = constraint.render.strokeStyle || '#666'; + var render = { + visible: true, + lineWidth: 2, + strokeStyle: '#666' + }; + + constraint.render = Common.extend(render, constraint.render); // option defaults constraint.stiffness = constraint.stiffness || 1; diff --git a/src/render/Render.js b/src/render/Render.js index 59be0b2..f30d8bc 100644 --- a/src/render/Render.js +++ b/src/render/Render.js @@ -188,7 +188,7 @@ var Render = {}; bodyB = constraint.bodyB, c = context; - if (!constraint.pointA || !constraint.pointB) + if (!constraint.render.visible || !constraint.pointA || !constraint.pointB) return; if (bodyA) {