Drunk blurry vision JavaScript fun snippet, v0.1

new version available, see dedicated page

i got this idea in my head for a while.
every time i got opened some image in opera, i drag it and play it it for a while, because i just love that effect.
and finally i was to lazy to do what i was supposed to do, so here is first version:

Drunk blurry vision JavaScript fun snippet, v0.1 (bookmark this link)

Original code:


b=document.body;
h=b.parentNode;
n=b.cloneNode(true);
h.appendChild(n);
h.style.overflow='hidden';
s=n.style;
s.width='100%';
s.position='absolute';
s.top=0;
s.opacity=.5;
setInterval(function(){
t=s.top;
l=s.left;
nt=t.substring(0,t.length-2)*1+Math.ceil(Math.random()*3)-2;
nl=l.substring(0,l.length-2)*1+Math.ceil(Math.random()*3)-2;
nt=(nt>5)?4:nt;
nt=(nt<-5)?-4:nt; nl=(nl>5)?4:nl;
nl=(nl<-5)?-4:nl; s.top=nt+'px'; s.left=nl+'px'; },10); void(0);

Ideas to to future
  • make it to react on mouse move
  • remove effect on click or on ESC
  • start effect on click (anywhere)
  • basic 3D page effect: initialize on click, remember this as zero point, on mouse move calculate distance from zero point and according to that display effect

Leave a Reply