How to get size of a panel during resize?











up vote
0
down vote

favorite












I have a multi-panel jQuery layout and want to know the size of the inner-center panel while it is resizing. document.ready function looks like this:



$(document).ready(function () { 

outerLayout = $('body').layout({
spacing_open: 8
, south__spacing_open: 4
, north__minSize: 40
, north__maxSize: 200
, center__onresize: resizeInnerLayout
, resizeWhileDragging: true
, triggerEventsWhileDragging: true
});


Here is the resizeInnerLayout function:



function resizeInnerLayout() {
var width=$('#content-middle').width();
var height = $('#content-middle').height();
console.log("content-middle size = ("+width +"," +height +")");
};


Here is the html:



<div id="content-middle" class="inner-center">
<svg></svg>
</div>


Javascript puts a d3 chart inside the svg. I need to know the size of the div as it resizes when the user slides the divider bar so I can resize the chart accordingly. Currently, the console.log outputs nothing.



I have also tried binding a function to the layoutpaneresize event like this:



$('.inner-center').bind('layoutpaneresize', function(paneName, $pane, paneState, paneOptions) {
console.log("content-middle size = ("+paneState.width +"," +paneState.height +")");
});


But it also outputs nothing. Neither did this:



$('.inner_center').resize(function() {
console.log("content-middle is being resized");
});


This one works, but only if the browser window is resized, not if the splitter inside the window is resized. Even then, it reports the size as you begin to resize but doesn't update as the size continues to change.



window.addEventListener("resize", drawChart);


Any ideas?










share|improve this question
























  • Since apparently nobody knows the answer to this, I added another post in the jquery-layout forum. groups.google.com/forum/#!topic/jquery-ui-layout/NiZ-U3rIT4k
    – user3217883
    Nov 17 at 17:01















up vote
0
down vote

favorite












I have a multi-panel jQuery layout and want to know the size of the inner-center panel while it is resizing. document.ready function looks like this:



$(document).ready(function () { 

outerLayout = $('body').layout({
spacing_open: 8
, south__spacing_open: 4
, north__minSize: 40
, north__maxSize: 200
, center__onresize: resizeInnerLayout
, resizeWhileDragging: true
, triggerEventsWhileDragging: true
});


Here is the resizeInnerLayout function:



function resizeInnerLayout() {
var width=$('#content-middle').width();
var height = $('#content-middle').height();
console.log("content-middle size = ("+width +"," +height +")");
};


Here is the html:



<div id="content-middle" class="inner-center">
<svg></svg>
</div>


Javascript puts a d3 chart inside the svg. I need to know the size of the div as it resizes when the user slides the divider bar so I can resize the chart accordingly. Currently, the console.log outputs nothing.



I have also tried binding a function to the layoutpaneresize event like this:



$('.inner-center').bind('layoutpaneresize', function(paneName, $pane, paneState, paneOptions) {
console.log("content-middle size = ("+paneState.width +"," +paneState.height +")");
});


But it also outputs nothing. Neither did this:



$('.inner_center').resize(function() {
console.log("content-middle is being resized");
});


This one works, but only if the browser window is resized, not if the splitter inside the window is resized. Even then, it reports the size as you begin to resize but doesn't update as the size continues to change.



window.addEventListener("resize", drawChart);


Any ideas?










share|improve this question
























  • Since apparently nobody knows the answer to this, I added another post in the jquery-layout forum. groups.google.com/forum/#!topic/jquery-ui-layout/NiZ-U3rIT4k
    – user3217883
    Nov 17 at 17:01













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have a multi-panel jQuery layout and want to know the size of the inner-center panel while it is resizing. document.ready function looks like this:



$(document).ready(function () { 

outerLayout = $('body').layout({
spacing_open: 8
, south__spacing_open: 4
, north__minSize: 40
, north__maxSize: 200
, center__onresize: resizeInnerLayout
, resizeWhileDragging: true
, triggerEventsWhileDragging: true
});


Here is the resizeInnerLayout function:



function resizeInnerLayout() {
var width=$('#content-middle').width();
var height = $('#content-middle').height();
console.log("content-middle size = ("+width +"," +height +")");
};


Here is the html:



<div id="content-middle" class="inner-center">
<svg></svg>
</div>


Javascript puts a d3 chart inside the svg. I need to know the size of the div as it resizes when the user slides the divider bar so I can resize the chart accordingly. Currently, the console.log outputs nothing.



I have also tried binding a function to the layoutpaneresize event like this:



$('.inner-center').bind('layoutpaneresize', function(paneName, $pane, paneState, paneOptions) {
console.log("content-middle size = ("+paneState.width +"," +paneState.height +")");
});


But it also outputs nothing. Neither did this:



$('.inner_center').resize(function() {
console.log("content-middle is being resized");
});


This one works, but only if the browser window is resized, not if the splitter inside the window is resized. Even then, it reports the size as you begin to resize but doesn't update as the size continues to change.



window.addEventListener("resize", drawChart);


Any ideas?










share|improve this question















I have a multi-panel jQuery layout and want to know the size of the inner-center panel while it is resizing. document.ready function looks like this:



$(document).ready(function () { 

outerLayout = $('body').layout({
spacing_open: 8
, south__spacing_open: 4
, north__minSize: 40
, north__maxSize: 200
, center__onresize: resizeInnerLayout
, resizeWhileDragging: true
, triggerEventsWhileDragging: true
});


Here is the resizeInnerLayout function:



function resizeInnerLayout() {
var width=$('#content-middle').width();
var height = $('#content-middle').height();
console.log("content-middle size = ("+width +"," +height +")");
};


Here is the html:



<div id="content-middle" class="inner-center">
<svg></svg>
</div>


Javascript puts a d3 chart inside the svg. I need to know the size of the div as it resizes when the user slides the divider bar so I can resize the chart accordingly. Currently, the console.log outputs nothing.



I have also tried binding a function to the layoutpaneresize event like this:



$('.inner-center').bind('layoutpaneresize', function(paneName, $pane, paneState, paneOptions) {
console.log("content-middle size = ("+paneState.width +"," +paneState.height +")");
});


But it also outputs nothing. Neither did this:



$('.inner_center').resize(function() {
console.log("content-middle is being resized");
});


This one works, but only if the browser window is resized, not if the splitter inside the window is resized. Even then, it reports the size as you begin to resize but doesn't update as the size continues to change.



window.addEventListener("resize", drawChart);


Any ideas?







javascript jquery jquery-layout






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 11 at 4:19

























asked Nov 9 at 6:04









user3217883

257516




257516












  • Since apparently nobody knows the answer to this, I added another post in the jquery-layout forum. groups.google.com/forum/#!topic/jquery-ui-layout/NiZ-U3rIT4k
    – user3217883
    Nov 17 at 17:01


















  • Since apparently nobody knows the answer to this, I added another post in the jquery-layout forum. groups.google.com/forum/#!topic/jquery-ui-layout/NiZ-U3rIT4k
    – user3217883
    Nov 17 at 17:01
















Since apparently nobody knows the answer to this, I added another post in the jquery-layout forum. groups.google.com/forum/#!topic/jquery-ui-layout/NiZ-U3rIT4k
– user3217883
Nov 17 at 17:01




Since apparently nobody knows the answer to this, I added another post in the jquery-layout forum. groups.google.com/forum/#!topic/jquery-ui-layout/NiZ-U3rIT4k
– user3217883
Nov 17 at 17:01












1 Answer
1






active

oldest

votes

















up vote
0
down vote













You should use jQuery UI's .resizable() interaction.



Syntax



$(element).resizeable({
handles: 'n|s|e|w|nw|ne|sw|se',
minWidth: Int,
minHeight: Int,
maxWidth: Int,
maxHeight: Int,
resize: function(event, ui) {
// Statements
}
});


Example






$("div").resizable({
handles: 'e, se, s',
minWidth: 50,
minHeight: 50,
maxWidth: 200,
maxHeight: 200,
resize: function(event, ui) {
$("pre").text(ui.size.width + 'x' + ui.size.height);
}
});

.ui-resizable-e, .ui-resizable-s {
background-color: black;
}
div {
width:100px;
height:100px;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>

<div>Resize Me</div>
<br>
Result
<pre></pre>








share|improve this answer





















  • This is a very nice answer and example but is there a way to get the width and height of the div without having to click and drag a corner? The chart should resize to fill available space as the splitter is resized.
    – user3217883
    Nov 11 at 4:14











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53220626%2fhow-to-get-size-of-a-panel-during-resize%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













You should use jQuery UI's .resizable() interaction.



Syntax



$(element).resizeable({
handles: 'n|s|e|w|nw|ne|sw|se',
minWidth: Int,
minHeight: Int,
maxWidth: Int,
maxHeight: Int,
resize: function(event, ui) {
// Statements
}
});


Example






$("div").resizable({
handles: 'e, se, s',
minWidth: 50,
minHeight: 50,
maxWidth: 200,
maxHeight: 200,
resize: function(event, ui) {
$("pre").text(ui.size.width + 'x' + ui.size.height);
}
});

.ui-resizable-e, .ui-resizable-s {
background-color: black;
}
div {
width:100px;
height:100px;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>

<div>Resize Me</div>
<br>
Result
<pre></pre>








share|improve this answer





















  • This is a very nice answer and example but is there a way to get the width and height of the div without having to click and drag a corner? The chart should resize to fill available space as the splitter is resized.
    – user3217883
    Nov 11 at 4:14















up vote
0
down vote













You should use jQuery UI's .resizable() interaction.



Syntax



$(element).resizeable({
handles: 'n|s|e|w|nw|ne|sw|se',
minWidth: Int,
minHeight: Int,
maxWidth: Int,
maxHeight: Int,
resize: function(event, ui) {
// Statements
}
});


Example






$("div").resizable({
handles: 'e, se, s',
minWidth: 50,
minHeight: 50,
maxWidth: 200,
maxHeight: 200,
resize: function(event, ui) {
$("pre").text(ui.size.width + 'x' + ui.size.height);
}
});

.ui-resizable-e, .ui-resizable-s {
background-color: black;
}
div {
width:100px;
height:100px;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>

<div>Resize Me</div>
<br>
Result
<pre></pre>








share|improve this answer





















  • This is a very nice answer and example but is there a way to get the width and height of the div without having to click and drag a corner? The chart should resize to fill available space as the splitter is resized.
    – user3217883
    Nov 11 at 4:14













up vote
0
down vote










up vote
0
down vote









You should use jQuery UI's .resizable() interaction.



Syntax



$(element).resizeable({
handles: 'n|s|e|w|nw|ne|sw|se',
minWidth: Int,
minHeight: Int,
maxWidth: Int,
maxHeight: Int,
resize: function(event, ui) {
// Statements
}
});


Example






$("div").resizable({
handles: 'e, se, s',
minWidth: 50,
minHeight: 50,
maxWidth: 200,
maxHeight: 200,
resize: function(event, ui) {
$("pre").text(ui.size.width + 'x' + ui.size.height);
}
});

.ui-resizable-e, .ui-resizable-s {
background-color: black;
}
div {
width:100px;
height:100px;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>

<div>Resize Me</div>
<br>
Result
<pre></pre>








share|improve this answer












You should use jQuery UI's .resizable() interaction.



Syntax



$(element).resizeable({
handles: 'n|s|e|w|nw|ne|sw|se',
minWidth: Int,
minHeight: Int,
maxWidth: Int,
maxHeight: Int,
resize: function(event, ui) {
// Statements
}
});


Example






$("div").resizable({
handles: 'e, se, s',
minWidth: 50,
minHeight: 50,
maxWidth: 200,
maxHeight: 200,
resize: function(event, ui) {
$("pre").text(ui.size.width + 'x' + ui.size.height);
}
});

.ui-resizable-e, .ui-resizable-s {
background-color: black;
}
div {
width:100px;
height:100px;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>

<div>Resize Me</div>
<br>
Result
<pre></pre>








$("div").resizable({
handles: 'e, se, s',
minWidth: 50,
minHeight: 50,
maxWidth: 200,
maxHeight: 200,
resize: function(event, ui) {
$("pre").text(ui.size.width + 'x' + ui.size.height);
}
});

.ui-resizable-e, .ui-resizable-s {
background-color: black;
}
div {
width:100px;
height:100px;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>

<div>Resize Me</div>
<br>
Result
<pre></pre>





$("div").resizable({
handles: 'e, se, s',
minWidth: 50,
minHeight: 50,
maxWidth: 200,
maxHeight: 200,
resize: function(event, ui) {
$("pre").text(ui.size.width + 'x' + ui.size.height);
}
});

.ui-resizable-e, .ui-resizable-s {
background-color: black;
}
div {
width:100px;
height:100px;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>

<div>Resize Me</div>
<br>
Result
<pre></pre>






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 11 at 2:32









Mth

24814




24814












  • This is a very nice answer and example but is there a way to get the width and height of the div without having to click and drag a corner? The chart should resize to fill available space as the splitter is resized.
    – user3217883
    Nov 11 at 4:14


















  • This is a very nice answer and example but is there a way to get the width and height of the div without having to click and drag a corner? The chart should resize to fill available space as the splitter is resized.
    – user3217883
    Nov 11 at 4:14
















This is a very nice answer and example but is there a way to get the width and height of the div without having to click and drag a corner? The chart should resize to fill available space as the splitter is resized.
– user3217883
Nov 11 at 4:14




This is a very nice answer and example but is there a way to get the width and height of the div without having to click and drag a corner? The chart should resize to fill available space as the splitter is resized.
– user3217883
Nov 11 at 4:14


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53220626%2fhow-to-get-size-of-a-panel-during-resize%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Bressuire

Vorschmack

Quarantine