Skip to content

Instantly share code, notes, and snippets.

@Hypnosphi
Last active April 23, 2017 02:01
Show Gist options
  • Save Hypnosphi/f60599465a3b507726babfbdecf2bd46 to your computer and use it in GitHub Desktop.
Save Hypnosphi/f60599465a3b507726babfbdecf2bd46 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 id="app"></div>
</body>
</html>
// write ES2015 code and import modules from npm
// and then press "Execute" to run your program
import React from 'react'
import {render} from 'react-dom'
let prevE = null
const logger = id => e => {
console.log(`${id}: ${e.nativeEvent.movementX}`)
prevE = e
}
const Example = () => (
<div onMouseMove={logger('parent')}>
<div
onMouseMove={logger('child')}
style={{
height: 500,
width: '100%',
backgroundColor: '#ffe'
}}
/>
</div>
)
render(<Example/>, document.querySelector('#app'))
{
"name": "esnextbin-sketch",
"version": "0.0.0",
"dependencies": {
"react": "15.4.2",
"react-dom": "15.4.2"
}
}
'use strict';
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _reactDom = require('react-dom');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// write ES2015 code and import modules from npm
// and then press "Execute" to run your program
var prevE = null;
var logger = function logger(id) {
return function (e) {
console.log(id + ': ' + e.nativeEvent.movementX);
prevE = e;
};
};
var Example = function Example() {
return _react2.default.createElement(
'div',
{ onMouseMove: logger('parent') },
_react2.default.createElement('div', {
onMouseMove: logger('child'),
style: {
height: 500,
width: '100%',
backgroundColor: '#ffe'
}
})
);
};
(0, _reactDom.render)(_react2.default.createElement(Example, null), document.querySelector('#app'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment