NIFI-147:

- Clean up change for SVG resizing to remove unnecessary window resize listener.
This commit is contained in:
Matt Gilman 2014-12-09 15:33:21 -05:00
parent 61c5cb3773
commit 63e80d3fdc
1 changed files with 14 additions and 15 deletions

View File

@ -198,8 +198,6 @@ nf.Canvas = (function () {
// create the canvas // create the canvas
svg = d3.select('#canvas-container').append('svg') svg = d3.select('#canvas-container').append('svg')
.attr('width', canvasContainer.width())
.attr('height', canvasContainer.height())
.on('contextmenu', function () { .on('contextmenu', function () {
// reset the canvas click flag // reset the canvas click flag
canvasClicked = false; canvasClicked = false;
@ -214,14 +212,6 @@ nf.Canvas = (function () {
d3.event.preventDefault(); 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 // create the definitions element
var defs = svg.append('defs'); var defs = svg.append('defs');
@ -470,13 +460,22 @@ nf.Canvas = (function () {
bottom = footer.height(); bottom = footer.height();
} }
var graph = $('#canvas-container'); // calculate size
var top = parseInt(graph.css('top'), 10); var top = parseInt(canvasContainer.css('top'), 10);
var windowHeight = $(window).height(); var windowHeight = $(window).height();
var graphHeight = (windowHeight - (bottom + top)); var canvasHeight = (windowHeight - (bottom + top));
graph.css('height', graphHeight + 'px');
graph.css('bottom', bottom + 'px');
// canvas/svg
canvasContainer.css({
'height': canvasHeight + 'px',
'bottom': bottom + 'px'
});
svg.attr({
'height': canvasContainer.height(),
'width': canvasContainer.width()
});
// body
$('#canvas-body').css({ $('#canvas-body').css({
'height': windowHeight + 'px', 'height': windowHeight + 'px',
'width': $(window).width() + 'px' 'width': $(window).width() + 'px'