Created
August 23, 2017 07:42
-
-
Save WeiChiaChang/f7c866ed7fe2c73913b017e7eb88ba0e 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
(function(window){ | |
"use strict"; | |
// type 'thankyou' on your keyboard | |
var key = [84,72,65,78,75,89,79,85]; | |
var ck = 0; | |
var max = key.length; | |
var airguitar = function() { | |
var shock = document.createElement('div'); | |
var img = new Image; | |
img.src = data; | |
img.style.width = '600px'; | |
img.style.height = '300px'; | |
img.style.transition = '1s all'; | |
img.style.position = 'fixed'; | |
img.style.left = 'calc(50% - 300px)'; | |
img.style.bottom = '-300px'; | |
img.style.zIndex = 999999; | |
document.body.appendChild(img); | |
window.setTimeout(function(){ | |
img.style.bottom = '-30px'; | |
},50); | |
window.setTimeout(function(){ | |
img.style.bottom = '-300px'; | |
}, 4300); | |
window.setTimeout(function(){ | |
img.parentNode.removeChild(img); | |
// shock.parentNode.removeChild(shock); | |
}, 5400); | |
}; | |
var record = function(e) { | |
if ( e.which === key[ck] ) { | |
ck++; | |
} else { | |
ck = 0; | |
} | |
if ( ck >= max ) { | |
airguitar(); | |
ck = 0; | |
} | |
}; | |
var init = function(data) { | |
document.addEventListener('keyup', record); | |
}; | |
var data = 'https://i.imgur.com/TKFXITZ.gif'; | |
init(data); | |
})(window); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment