JSFiddle - React, Tailwind, and code Playground
JavaScript
//this function will return true if the window is too small
var isTooSmall = function(w, h){
console.log(w + " " + h); //just to check width and height
var min_w = 200; //set these to what you wish
var min_h = 200;
if(w < min_w || h < min_h){
return true;
}
else return false;
};
//this function will allow us to bind listeners given an object and its event.
//Check the linked stackoverflow answer for more explanation
var addEvent = function(object, type, callback) {
if (object == null || typeof(object) == 'undefined') return;
if (object.addEventListener) {
object.addEventListener(type, callback, false);
} else if (object.attachEvent) {
object.attachEvent("on" + type, callback);
} else {
object["on"+type] = callback;
}
};
//resize listener
addEvent(window, "resize", function(event) {
console.log(isTooSmall(window.innerWidth, window.innerHeight));
});
//onload listener
window.onload = function () {
console.log(isTooSmall(window.innerWidth, window.innerHeight));
}