I have this working Javascript code which does some resizing on init and resize:
(function (w) {
w.init = function () {
var w = window.innerWidth;
var h = window.innerHeight;
//resize_font;
var fs = parseInt(w / 26);
document.body.style.fontSize = fs + "px";
//resize_cover;
var logo = get_by_id("logo");
var logo_height = logo.clientHeight;
var menu = get_by_id("menu");
var menu_height = menu.clientHeight;
var cover_height = logo_height + menu_height;
var distance_top = (h - cover_height) / 2.5;
var container = get_by_id("container");
container.style.paddingTop = distance_top + "px";
}
w.resize = function () {
var w = window.innerWidth;
var h = window.innerHeight;
//resize_font;
var fs = parseInt(w / 26);
document.body.style.fontSize = fs + "px";
//resize_cover;
var logo = get_by_id("logo");
var logo_height = logo.clientHeight;
var menu = get_by_id("menu");
var menu_height = menu.clientHeight;
var cover_height = logo_height + menu_height;
var distance_top = (h - cover_height) / 2.5;
var container = get_by_id("container");
container.style.paddingTop = distance_top + "px";
}
}
Now I want to refactor the code for resizing font and cover into a function, but I can't get it working. I tried this:
(function (w) {
w.init = function () {
var w = window.innerWidth;
var h = window.innerHeight;
resize_font;
resize_cover;
}
w.resize = function () {
var w = window.innerWidth;
var h = window.innerHeight;
resize_font;
resize_cover;
}
function resize_cover() {
var logo = get_by_id("logo");
var logo_height = logo.clientHeight;
var menu = get_by_id("menu");
var menu_height = menu.clientHeight;
var cover_height = logo_height + menu_height;
var distance_top = (h - cover_height) / 2.5;
var container = get_by_id("container");
container.style.paddingTop = distance_top + "px";
}
function resize_font() {
var fs = parseInt(w / 26);
document.body.style.fontSize = fs + "px";
}
}
The console doesn'T show any errors, but resizing isn't happening. What am I doing wrong?
resize_font;does?