javascript - Detect point of screen size changes -


i want detect point when screen width changes below 1120, , fire piece of code, when screen size passes point. not want run code when there change from, example, 1000 999. 1121 1120.

to ensure code doesn't run every time browser resized, when changes above or below 1200px resolution, can use boolean(true/false) flag run code when value needs change, in case under1200 variable.

no libraries required if you're using code.

var under1200=false;      if(window.innerwidth<1200){      	under1200=true;      }      window.onresize = function(event) {      	if(under1200 == false && window.innerwidth<=1200){      		console.log("size under 1200");      		under1200=true;      		      		//your code less 1200px here      	}      	if(under1200 == true && window.innerwidth>1200){      		console.log("size on 1200");      		under1200=false;      		      		//your code +1200px here      	}      }


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -