Created
March 3, 2014 16:05
-
-
Save rmasters/9328216 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
/* | |
----------------------------------------------------------------------------- | |
"THE BEER-WARE LICENSE" (Revision 42): | |
<[email protected]> wrote this file. As long as you retain this notice you | |
can do whatever you want with this stuff. If we meet some day, and you think | |
this stuff is worth it, you can buy me a beer in return. -Michaël Sokol | |
----------------------------------------------------------------------------- | |
*/ | |
var jq = document.createElement('script'); | |
jq.src = "//code.jquery.com/jquery-1.11.0.min.js"; | |
document.getElementsByTagName('head')[0].appendChild(jq); | |
var glasses = 1.0; | |
function drunkify($) { | |
var transformations = [{ | |
name: 'rotate', | |
value: function (e) { | |
return glasses * ((Math.random() * 2) - 1) / (50 / (e.parents().length)); | |
}, | |
unit: 'deg' | |
}, { | |
name: 'scale', | |
value: function (e) { | |
return glasses * (1 + (((Math.random() * 2) - 1) / (1000 / (e.parents().length)))); | |
} | |
}/*, { | |
name: 'skewX', | |
value: function () { | |
return ((Math.random() * 2) - 1) / 2; | |
}, | |
unit: 'deg' | |
}*/]; | |
$('*').css('-webkit-transition', '-webkit-transform 3s'); | |
var easings = ['ease', 'ease-in', 'ease-out', 'ease-in-out', 'linear', | |
'cubic-bezier(0.6, 0.04, 0.98, 0.335)', 'cubic-bezier(0.175, 0.885, 0.32, 1.275)', | |
'cubic-bezier(0.23, 1, 0.32, 1)', 'cubic-bezier(0.785, 0.135, 0.15, 0.86)', | |
'cubic-bezier(0.77, 0, 0.175, 1)' | |
]; | |
var computeEasing = function(e) { | |
return easings[Math.floor((Math.random() * 100) % easings.length)]; | |
}; | |
var computeTransforms = function (e) { | |
return transformations.map(function (t) { | |
return t.name + '(' + t.value(e) + (t.unit ? t.unit : '') + ')'; | |
}).join(' '); | |
}; | |
var computerFilters = function (e) { | |
return 'blur(' + Math.random() + 'px)'; | |
}; | |
window.setInterval(function () { | |
$('*').each(function (i, e) { | |
$(e).css('-webkit-transition-timing-function', computeEasing($(e))); | |
$(e).css('transform', computeTransforms($(e))); | |
$(e).parents().length > 4 && $(e).css('-webkit-filter', computerFilters()); | |
glasses = glasses + 0.0000000000001; | |
}); | |
}, 3000); | |
} | |
setTimeout(function() { | |
drunkify(jQuery); | |
}, 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment