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?
javascript jquery jquery-layout
add a comment |
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?
javascript jquery jquery-layout
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
add a comment |
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?
javascript jquery jquery-layout
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
javascript jquery jquery-layout
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
add a comment |
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
add a comment |
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>
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
add a comment |
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>
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
add a comment |
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>
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
add a comment |
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>
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>
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
add a comment |
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
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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