Skip to content

Instantly share code, notes, and snippets.

@patrickkettner
Created June 1, 2017 16:04
Show Gist options
  • Save patrickkettner/27e4338ae362a3430c03a0fa16705458 to your computer and use it in GitHub Desktop.
Save patrickkettner/27e4338ae362a3430c03a0fa16705458 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/cozegok
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style id="jsbin-css">
body {
height: 100vh;
width: 100vw;
background: transparent radial-gradient(at calc(var(--mouse-x, 0) * 100%) calc(var(--mouse-y, 0) * 100%), #ff0, #008000) no-repeat 0 0;
}
</style>
</head>
<body>
<script id="jsbin-javascript">
'use strict';
var root = document.documentElement;
document.addEventListener('mousemove', function (evt) {
var x = evt.clientX / innerWidth;
var y = evt.clientY / innerHeight;
root.style.setProperty('--mouse-x', x);
root.style.setProperty('--mouse-y', y);
})
</script>
<script id="jsbin-source-css" type="text/css">body {
height: 100vh;
width: 100vw;
background: transparent radial-gradient(at calc(var(--mouse-x, 0) * 100%) calc(var(--mouse-y, 0) * 100%), #ff0, #008000) no-repeat 0 0;
}
</script>
<script id="jsbin-source-javascript" type="text/javascript">'use strict';
var root = document.documentElement;
document.addEventListener('mousemove', function (evt) {
var x = evt.clientX / innerWidth;
var y = evt.clientY / innerHeight;
root.style.setProperty('--mouse-x', x);
root.style.setProperty('--mouse-y', y);
})</script></body>
</html>
body {
height: 100vh;
width: 100vw;
background: transparent radial-gradient(at calc(var(--mouse-x, 0) * 100%) calc(var(--mouse-y, 0) * 100%), #ff0, #008000) no-repeat 0 0;
}
'use strict';
var root = document.documentElement;
document.addEventListener('mousemove', function (evt) {
var x = evt.clientX / innerWidth;
var y = evt.clientY / innerHeight;
root.style.setProperty('--mouse-x', x);
root.style.setProperty('--mouse-y', y);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment