I have a basic JS function that I use to get page height data, viewport, page, certain groups, etc. and return them to bubble. You can see that it is cobbled together with bits of JS and JQuery I’ve scavenged from various forum posts but it works:
function getAllHeights() {
var vpHeight = Math.max(document.documentElement.clientHeight,
window.innerHeight || 0);
var pgHeight = Math.max($(document).height(), $(window).height());
var grpmHeight = $('#grpmessage').height();
var grpbHeight = $('#grpbottom').height();
bubble_fn_vph(vpHeight);
bubble_fn_pgh(pgHeight);
bubble_fn_grpmh(grpmHeight);
bubble_fn_grpbh(grpbHeight)}
I want to calculate what another group’s (id=‘grptop’) height should be so all contents fit on the screen with no scrolling. Assume all calculations work for what I want. So if calcTop():
function calcTop() {
var vpHeight = Math.max(document.documentElement.clientHeight,
window.innerHeight || 0);
var grpmHeight = $('#grpmessage').height();
var grpbHeight = $('#grpbottom').height();
var grptHeight = vpHeight - grpmHeight - grpbHeight;
bubble_fn_grpth(grptHeight)}
I’m grabbing the same heights again in this function that I already did in getAllHeights(). Can getAllHeights() be constructed so it could also be called within calcTop() to return the three values I need to do this calculation?
I know that I can achieve the desired result within bubble given that I have the values in bubble now. I’m just trying to learn how to do this in JS.