Is it possible to run a script when the screen size gets above or below a certain point, but only at that certain point? I have a function that takes two paramters, and i would like those two parameters to change if the screen size is below 769 pixels. So i have used the classic:
$( window ).resize(function() {
if ($(window).width() < 769) {
foobar(foo1, bar1);
}
else {
foobar(foo2, bar2);
}
});
that works, but that runs foobar every time the window is resized. The problem is that i do not want the function to be executed if you resize the browser from e.g 500 to 600 px because that means it executes if you go from portrait to landscape on a smartphone, i only want it to be executed the moment it goes below or above 768 px. Any ideas?