Jump to content

HTMLFrame (Inside Form vbox) Loaded At Runtime - How Do I Calculate The New Contents Canvas Height ?


andyhill

Recommended Posts

HTMLFrame.Height is the physical display frame height, not the contents canvas length (partially visible, partially hidden - scrolled) within.

I need a way to calculate the HTMLFrame virtual canvas contents total height, please advise - thanks in advance.

 

Link to comment
Share on other sites

This is the code I use in the HTMLFrame called daycalFrame on MainForm, where I want the canvas to fill the whole frame, making sure redrawing is done on each resize:

<canvas id="daycal">
<script type="text/javascript">

var canvas = $('#daycal')[0];
var ctx = canvas.getContext("2d");

window.addEventListener('resize', resizeCanvas, true);
function resizeCanvas() {
    canvas.width = MainForm.daycalFrame.getWidth();
    canvas.height = MainForm.daycalFrame.getHeight(); 
    drawStuff();    
}
  
</script>  

 

Link to comment
Share on other sites

Thanks Ron for your reply.

I do not want to change the HTMLFrame size as it is sized automatically via Flex.

What I want to do is get the new canvas height (length) after contents loaded.

--------------------
|                               |
|         Screen          |
|                               |
|-------------------|
|                               |
|                               |
|      Off Screen       |
|     Scrolled Into     |
|          View             |
|                               |
|                               |
|                               |
|-------------------|

I Need to get the total Height (length) of both Screen Display Value and Off Screen Value that can be sent via an ajaxRequest for recording.


 

 

Link to comment
Share on other sites

On 1/27/2022 at 12:27 AM, andyhill said:

HTMLFrame.Height is the physical display frame height, not the contents canvas length (partially visible, partially hidden - scrolled) within.

I need a way to calculate the HTMLFrame virtual canvas contents total height, please advise - thanks in advance.

Hello @andyhill

Sorry, of course not always, but sometimes a minimal test case helps us.

Link to comment
Share on other sites

Quote

I do not want to change the HTMLFrame size as it is sized automatically via Flex.

 

The code I presented does not change the HTMLFrame size, but only the canvas size. It makes the canvas fill the HTMLFrame, as the frame resizes.

The code makes sure your canvas is always filling the frame.

If you want to know the size of the canvas, you can get it from canvas.height and canvas.width, through an ajax call.

Link to comment
Share on other sites

Ron, the canvas will always be bigger than the frame on screen because it's contents are larger than the frame, I want to keep the canvas' correct rendered size even though it is partially out of view - but I want to calculate (send result via ajax) the total canvas height (not change it).

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...