Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

121 lines (121 sloc) 2.971 kb
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Faking it with a double sun, really?</title>
<meta type="description" content="Undoing the lame 'double sun' in Star Wars: A new hope. Just drag and drop it.">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<style>
* {
margin: 0;
padding: 0;
}
body {
margin: 2em;
font-size: 15px;
background: #333;
color: #0c0;
font-family: helvetica, arial, sans-serif;
}
video {
box-shadow: 4px 4px 10px rgba(0,0,0,0.8);
}
a{color:#0c0}
footer, section, header, aside, figure {
display: block;
}
section {
position: relative;
width: 640px;
margin:0 auto;
overflow: hidden;
}
section.mask #mask, section.mask #sun {
visibility: visible;
}
section #mask, section #sun {
visibility: hidden;
}
#mask {
position: absolute;
top: 0;
left: 0;
z-index: 9;
}
#sun {
position: absolute;
top: 92px;
left: 525px;
z-index: 10;
}
footer {
margin: 2em 0;
text-align: center;
font-size: 10px;
}
h1{
font-size: 32px;
margin: 0 0 10px 0;
text-align: center;
}
</style>
</head>
<body>
<header><h1>Faking it with a double sun, really?</h1></header>
<section>
<video width="640" controls height="272">
<source src="newhopesun.mp4" type="video/mp4">
<source src="newhopesun.webm" type="video/webm">
</video>
</section>
<footer>
<p>Written by
<a href="http://christianheilmann.com/">Chris Heilmann</a>
(<a href="http://twitter.com/codepo8">@codepo8</a>)
</p>
</footer>
<script>
var s = document.querySelector( 'section' ),
mousedown = false,
visible = false,
v = document.querySelector( 'video' ),
footer = document.querySelector( 'footer' ),
mask = document.createElement( 'img' );
mask.src = 'mask2.png';
mask.id = 'mask';
var sun = document.createElement( 'img' );
sun.src = 'sun.png';
sun.id = 'sun';
var x = s.offsetLeft;
var y = s.offsetTop;
s.appendChild( sun );
s.appendChild( mask );
s.addEventListener( 'mousedown', function( ev ) {
ev.preventDefault();
mousedown = true;
},false);
s.addEventListener( 'mouseup', function( ev ) {
ev.preventDefault();
mousedown = false;
},false);
s.addEventListener( 'mousemove', function( ev ) {
ev.preventDefault();
if ( mousedown && visible ) {
sun.style.zIndex = ev.clientX - x < 300 ? 8 : 10;
sun.style.left = ev.clientX - 10 - x + 'px';
sun.style.top = ev.clientY - 10 - y + 'px';
}
}, false );
v.addEventListener( 'timeupdate', function( ev ) {
var time = v.currentTime;
if( time >= 3.2 && time <= 56 ) {
visible = true;
s.className = 'mask';
} else {
visible = false;
s.className = '';
}
} ,false );
</script>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.