Skip to content

Instantly share code, notes, and snippets.

@hemanth
Last active December 15, 2016 03:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hemanth/ce052895f12909f998d7d35fe0897537 to your computer and use it in GitHub Desktop.
Save hemanth/ce052895f12909f998d7d35fe0897537 to your computer and use it in GitHub Desktop.
esnextbin sketch
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>ESNextbin Sketch</title>
<!-- put additional styles and scripts here -->
</head>
<body>
<div
style="margin: 20px;
text-align: center;
background: rebeccapurple;
color: wheat;
width: 348px;
height: 400px;"
>
Move it!
</div>
<span
style="
text-align: center;
display: block;
"></span>
</body>
</html>
// write ES2015 code and import modules from npm
// and then press "Execute" to run your program
const cursorDirection = require('cursor-direction');
const element = document.querySelector('div');
const span = document.querySelector('span');
// Example
element.addEventListener('mouseenter', function (event) {
span.innerHTML = cursorDirection(event, this);
}, false);
element.addEventListener('mouseleave', function (event) {
span.innerHTML = cursorDirection(event, this);
}, false);
{
"name": "cursor-direction-demo",
"version": "1.0.0",
"cursor-direction": "^1.0.0",
"dependencies": {
"cursor-direction": "1.0.0"
}
}
'use strict';
// write ES2015 code and import modules from npm
// and then press "Execute" to run your program
var cursorDirection = require('cursor-direction');
var element = document.querySelector('div');
var span = document.querySelector('span');
// Example
element.addEventListener('mouseenter', function (event) {
span.innerHTML = cursorDirection(event, this);
}, false);
element.addEventListener('mouseleave', function (event) {
span.innerHTML = cursorDirection(event, this);
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment