Created
March 29, 2015 21:24
-
-
Save Paul-Browne/a14e4a93bc86ccc77d07 to your computer and use it in GitHub Desktop.
JS Bin [resize width only] // source http://jsbin.com/valoyi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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