-
Notifications
You must be signed in to change notification settings - Fork 0
/
bubble.min.js
10 lines (10 loc) · 1.67 KB
/
bubble.min.js
1
2
3
4
5
6
7
8
9
10
/*
bubbleClick
Copyright 2011 THEtheChad Elliott
Released under the MIT and GPL licenses.
Original author: Digitpaint 2011 (Advent Calender)
*/
(function(){window.bubble={color:[["rgba(200,0,10,.2)","rgba(200,0,10,.4)"]],pulse:[1],delay:[150],speed:[2],size:[20]};var d=document,h=d.getElementsByTagName("html")[0],i=d.createElement("style"),j=d.createElement("b"),f=Math.random,g=Math.round,k=["","-o-","-ms-","-moz-","-webkit-"],a;for(h.appendChild(i);(a=k.pop())&&!(j.style.backgroundImage=a+"linear-gradient(0,#007,#9f9)",j.style.backgroundImage.indexOf("linear")+1););if(void 0!=a){j.className="bubble";var r=function(b){function o(){h.removeChild(c);
c=null}var l=bubble.color[g(f()*(bubble.color.length-1))],i=bubble.speed[g(f()*(bubble.speed.length-1))],e=bubble.size[g(f()*(bubble.size.length-1))],p=3*e/4,k=p+e/9,q=2*e,c=j.cloneNode(),m=0,n=0;if(b)if(b.pageX||b.pageY)m=b.pageX,n=b.pageY;else if(b.clientX||b.clientY)m=b.clientX+d.body.scrollLeft,n=b.clientY+d.body.scrollTop;c.style.left=m-e+"px";c.style.top=n-e+"px";c.style.height=q+"px";c.style.width=q+"px";c.style.backgroundImage=a+"radial-gradient(circle contain,"+l[0]+" "+p+"px,"+(l[1]||l[0])+
" "+k+"px,transparent "+e+"px)";c.style[a+"animation-duration"]=i+"s";c.addEventListener("webkitAnimationEnd",o);c.addEventListener("animationend",o);h.appendChild(c)};i.innerHTML=".bubble{position:absolute;z-index:1000;"+a+"animation-name:pop;"+a+"animation-timing-function:ease}@"+a+"keyframes pop{0%{"+a+"transform:scale(1)}70%{"+a+"transform:scale(5)}100%{opacity:0}}";h.onclick=function(b){for(var a=bubble.pulse[g(f()*(bubble.pulse.length-1))],d=bubble.delay[g(f()*(bubble.delay.length-1))];a;)setTimeout(function(){r(b)},
d*--a)}}})();