Skip to content

Instantly share code, notes, and snippets.

@orls
Last active August 29, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save orls/fe9f1f40973835266201 to your computer and use it in GitHub Desktop.
Save orls/fe9f1f40973835266201 to your computer and use it in GitHub Desktop.
Dynamic Nigel Resizer for paintwithnigelfarage.com
/**
* SuperDynamicHeadMode for http://paintwithnigelfarage.com
*
* Paste this script into browser's JS console.
*
* Controls:
* press/hold z to smallify Nigel
* press/hold x to embiggenate Nigel
*/
(function(){
var pointer = $('#mousePointer');
pointer.css('background-size', '100%');
var w = pointer.width(), h = pointer.height(), scale = 1;
function nudge(value){
scale += value;
pointer.width(w * scale);
pointer.height(h * scale);
}
$(window).on('keydown', function(e){
if (e.which == 90) {nudge(-0.05);} //z
if (e.which == 88) {nudge(0.05);} //x
})
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
var newNodes = mutation.addedNodes;
if (!newNodes) { return };
$(newNodes).filter('.farage').each(function(){
$(this).css('background-size', '100%').width(pointer.width()).height(pointer.height());
});
});
});
observer.observe($('body')[0], {attributes: true, childList: true, characterData: true});
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment