Skip to content

Instantly share code, notes, and snippets.

@nola
nola / scroll-timer.js
Created October 8, 2015 15:06
get page scroll position based on timer. Not scroll event.
var didScroll = false;
$(window).scroll(function() {
didScroll = true;
});
setInterval(function() {
var winheight = $(window).scrollTop();
var winheightdiff = $(window).height() - 65;
@nola
nola / clickTag.js
Last active October 5, 2015 20:04
DFP html5 clicktag file
window.onload = function() {
if (!!Enabler.isInitialized()) {
enablerInitHandler();
} else {
Enabler.addEventListener(studio.events.StudioEvent.INIT, enablerInitHandler);
}
}
function enablerInitHandler() {
document.getElementById('canvas').addEventListener('click', clickThrough, false);
$('form').validate({ // initialize the plugin
rules: {
email: {
required: true,
email: true
}
},
submitHandler: function (form) {
//alert('valid form submitted'); // for demo
@nola
nola / svg.js
Created September 21, 2015 20:16
if (!Modernizr.svg) {
var imgs = document.getElementsByTagName('img');
var svgExtension = /.*\.svg$/
var l = imgs.length;
for(var i = 0; i < l; i++) {
if(imgs[i].src.match(svgExtension)) {
imgs[i].src = imgs[i].src.slice(0, -3) + 'png';
//console.log(imgs[i].src);
}
}
@nola
nola / orientation.js
Last active September 17, 2015 20:37
window.addEventListener('orientationchange', doOnOrientationChange);
function doOnOrientationChange(){
if (window.orientation == -90 || window.orientation == 90) {
//alert('landscape');
} else if (window.orientation == 0) {
//alert('portrait');
}
// detect if mobile browser. regex -> http://detectmobilebrowsers.com
var isMobile = (function(a){return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01
@nola
nola / gist:9cbf2046da3d4f0b9928
Last active August 29, 2015 14:27 — forked from johnpolacek/gist:3827270
Prevent FOUC
<!-- Prevent FOUC (flash of unstyled content) - http://johnpolacek.com/2012/10/03/help-prevent-fouc/ -->
<style type="text/css">
.no-fouc {display: none;}
</style>
<script type="text/javascript">
document.documentElement.className = 'no-fouc';
// add to document ready: $('.no-fouc').removeClass('no-fouc');
</script>
@nola
nola / console.js
Created June 19, 2014 14:32
no console errors
// PREVENT 'CONSOLE' ERRORS IN BROWSERS THAT LACK A CONSOLE.
(function (window){if(!(window.console&&window.console.log)){var noop=function(){};var methods=["assert","clear","count","debug","dir","dirxml","error","exception","group","groupCollapsed","groupEnd","info","log","markTimeline","profile","profileEnd","markTimeline","table","time","timeEnd","timeStamp","trace","warn"];var length=methods.length;var console=window.console={};while(length--)console[methods[length]]=noop}})(window);
@nola
nola / 360particlewhip.js
Last active August 29, 2015 13:57
360 particle whip
var particle = $(".green-bar");
function randNum( bit ){
//TweenMax.fromTo(bit, 0.3+(Math.random()*0.5), {y:Math.floor(Math.random()*245) + 1, x:-500, rotationY:0, scale:(0.3+(Math.random()*0.8)), skewX:45, opacity:(0.01+(Math.random()*0.2))}, {rotationY:Math.floor(Math.random()*90), x:1000, ease:Linear.easeNone, transformOrigin:"50% 50%", onComplete:randNum, onCompleteParams:[bit] }, 0);
//TweenMax.fromTo(bit, 0.3+(Math.random()*2), {y:Math.floor(Math.random()*245) + 1, x:-500, rotationX:0, scale:(0.5+(Math.random()*1)), skewX:0, opacity:(0.01+(Math.random()*0.1))}, {rotationX:Math.floor(Math.random()*360), x:1000, skewX:20, ease:Linear.easeNone, transformOrigin:"50% 50%", onComplete:randNum, onCompleteParams:[bit] }, 0);
//TweenMax.to(bit, 0.01+(Math.random()*3), {y:(-1*(100)+(Math.random()*200)), opacity:(0.09+(Math.random()*0.1)), scale:(0.5+(Math.random()*1)), rotationY:360, rotationX:(0+(Math.random()*10)), ease:Linear.easeNone, transformOrigin:"50% 50% -1600", onComplete:ra
@nola
nola / particleEngine.html
Last active August 29, 2015 13:57
Particle Engine - needs tweenmax and javascript
<div
id="socket"
class="hero"
data-speed="3"
data-scale-range="0.2"
data-from-x="0"
data-to-x="940"
data-from-y="200"
data-to-y="-300"
data-from-z="-100"