Last active
August 29, 2015 14:00
-
-
Save mattattui/644c793578cfb98e9377 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<div id="bellend" class="bellend hidden">STOP THAT</div> | |
<style> | |
.hidden { | |
display:none; | |
} | |
.bellend { | |
background: #000; | |
color: #FFF; | |
height: 100%; | |
left: 0; | |
position: fixed; | |
top: 0; | |
width: 100%; | |
z-index: 2014; | |
font-size: 5rem; | |
text-align: center; | |
padding-top: 15%; | |
} | |
</style> | |
<script type="text/javascript" charset="utf-8"> | |
/* This WAS jquery.wanker by Mig Reyes - http://mig.io/makes/wanker/ | |
* Their copyright, MIT license | |
* | |
* Modified by Matt to work without jQuery | |
*/ | |
document.addEventListener('DOMContentLoaded', function() { | |
var settings = { | |
delay: 2000, | |
duration: 250 | |
}; | |
var message, elapsed, fired, mobile, reset, start, timer; | |
message = document.getElementById('bellend'); | |
mobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent); | |
if (!mobile) { | |
fired = false; | |
start = null; | |
elapsed = null; | |
timer = null; | |
reset = function() { | |
fired = false; | |
return elapsed = null; | |
}; | |
return window.addEventListener('resize', function() { | |
if (fired) { | |
elapsed = Math.abs(new Date() - start); | |
} else { | |
start = new Date(); | |
fired = true; | |
} | |
if (elapsed > settings.delay) { | |
message.classList.remove('hidden'); | |
} | |
if (timer) { | |
clearTimeout(timer); | |
} | |
return timer = setTimeout(function() { | |
message.classList.add('hidden'); | |
return reset(); | |
}, settings.duration); | |
}); | |
} | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment