Skip to content

Instantly share code, notes, and snippets.

@Paul-Browne
Created March 29, 2015 21:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Paul-Browne/a14e4a93bc86ccc77d07 to your computer and use it in GitHub Desktop.
Save Paul-Browne/a14e4a93bc86ccc77d07 to your computer and use it in GitHub Desktop.
JS Bin [resize width only] // source http://jsbin.com/valoyi
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="[resize width only]">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>JS Bin</title>
</head>
<body>
<p id="foo"></p>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<p>hello world</p>
<script id="jsbin-javascript">
function resizeWidthOnly(a,f) {
var w = [window.innerWidth];
onresize = function() {
var z = window.innerWidth,
y = w.length;
w.push(z);
if(w[y]!==w[y-1]){
clearTimeout(f);
f = setTimeout(a, 150);
}
};
return a;
}
resizeWidthOnly(function() {
var a = document.getElementById("foo");
a.innerHTML += "fired!<br>";
});
/* to call once onready use...
})();
*/
</script>
<script id="jsbin-source-javascript" type="text/javascript">
function resizeWidthOnly(a,f) {
var w = [window.innerWidth];
onresize = function() {
var z = window.innerWidth,
y = w.length;
w.push(z);
if(w[y]!==w[y-1]){
clearTimeout(f);
f = setTimeout(a, 150);
}
};
return a;
}
resizeWidthOnly(function() {
var a = document.getElementById("foo");
a.innerHTML += "fired!<br>";
});
/* to call once onready use...
})();
*/</script></body>
</html>
function resizeWidthOnly(a,f) {
var w = [window.innerWidth];
onresize = function() {
var z = window.innerWidth,
y = w.length;
w.push(z);
if(w[y]!==w[y-1]){
clearTimeout(f);
f = setTimeout(a, 150);
}
};
return a;
}
resizeWidthOnly(function() {
var a = document.getElementById("foo");
a.innerHTML += "fired!<br>";
});
/* to call once onready use...
})();
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment