streamer
Version:
Asynchronously recursive, pure function <3 via lazy streams.
64 lines (63 loc) • 1.82 kB
HTML
<html>
<head>
<title>test</title>
<script type="text/javascript" src="https://raw.github.com/Gozala/teleport/experimental/npm-1.x.x/teleport.js"></script>
<style>
head, body {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
background: black;
color: white;
font-family: Monaco, "Courier New", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", monospace;
}
a {
text-decoration: none;
position: fixed;
bottom: 10%;
right: 20%;
color: white;
}
a:hover {
text-decoration: underline;
}
#x, #y {
font-size: 120%;
position: fixed;
padding: 8px;
}
#x {
border-left: 1px solid white;
}
#y {
border-top: 1px solid white;
}
</style>
</head>
<body>
<script type="text/javascript">
define('main', function(require, exports, module) {
var streamer = require('https!raw.github.com/Gozala/streamer/master/streamer.js')
function mousemove(next, stop) {
document.addEventListener("mousemove", next, false);
}
var axis = streamer.map(mousemove, function(element) {
return [ element.clientX, element.clientY ]
})
axis(function(position) {
var x = document.getElementById('x')
var y = document.getElementById('y')
x.innerHTML = position[0]
y.innerHTML = position[1]
x.style.left = position[0] + 'px'
y.style.top = position[1] + 'px'
})
})
require.main('main')
</script>
<code id="x"></code>
<code id="y"></code>
<a href="http://jeditoolkit.com/streamer/demos/axis.html">http://jeditoolkit.com/streamer/demos/axis.html</a>
</body>
<html>