Don't call behavior.off unless behaviors were actually added

This commit is contained in:
Bryan Housel
2016-11-01 21:42:37 -04:00
parent 92ea045d79
commit 1043402b88

View File

@@ -43,6 +43,7 @@ export function uiFieldRestrictions(field, context) {
var dispatch = d3.dispatch('change'),
breathe = behaviorBreathe(context),
hover = behaviorHover(context),
initialized = false,
vertexID,
fromNodeID;
@@ -100,6 +101,7 @@ export function uiFieldRestrictions(field, context) {
var surface = wrap.selectAll('.surface');
if (!enter.empty()) {
initialized = true;
surface
.call(breathe)
.call(hover);
@@ -222,6 +224,8 @@ export function uiFieldRestrictions(field, context) {
restrictions.off = function(selection) {
if (!initialized) return;
selection.selectAll('.surface')
.call(hover.off)
.call(breathe.off)