From 63e80d3fdc62034d445c1d5725af8c83e221a74a Mon Sep 17 00:00:00 2001 From: Matt Gilman Date: Tue, 9 Dec 2014 15:33:21 -0500 Subject: [PATCH] NIFI-147: - Clean up change for SVG resizing to remove unnecessary window resize listener. --- .../src/main/webapp/js/nf/canvas/nf-canvas.js | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas.js b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas.js index 3b7108898d..e72b5c86f3 100644 --- a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas.js +++ b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas.js @@ -198,8 +198,6 @@ nf.Canvas = (function () { // create the canvas svg = d3.select('#canvas-container').append('svg') - .attr('width', canvasContainer.width()) - .attr('height', canvasContainer.height()) .on('contextmenu', function () { // reset the canvas click flag canvasClicked = false; @@ -214,14 +212,6 @@ nf.Canvas = (function () { d3.event.preventDefault(); }); - // listen for browser resize events to update the svg - $(window).resize(function () { - svg.attr({ - 'width': canvasContainer.width(), - 'height': canvasContainer.height() - }); - }); - // create the definitions element var defs = svg.append('defs'); @@ -470,13 +460,22 @@ nf.Canvas = (function () { bottom = footer.height(); } - var graph = $('#canvas-container'); - var top = parseInt(graph.css('top'), 10); + // calculate size + var top = parseInt(canvasContainer.css('top'), 10); var windowHeight = $(window).height(); - var graphHeight = (windowHeight - (bottom + top)); - graph.css('height', graphHeight + 'px'); - graph.css('bottom', bottom + 'px'); + var canvasHeight = (windowHeight - (bottom + top)); + + // canvas/svg + canvasContainer.css({ + 'height': canvasHeight + 'px', + 'bottom': bottom + 'px' + }); + svg.attr({ + 'height': canvasContainer.height(), + 'width': canvasContainer.width() + }); + // body $('#canvas-body').css({ 'height': windowHeight + 'px', 'width': $(window).width() + 'px'