Last active
August 29, 2015 14:18
-
-
Save orls/fe9f1f40973835266201 to your computer and use it in GitHub Desktop.
Dynamic Nigel Resizer for paintwithnigelfarage.com
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
/** | |
* 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