/
example.js
65 lines (59 loc) · 1.44 KB
/
example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
'use strict';
var _extends =
Object.assign ||
function(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
function _objectWithoutProperties(obj, keys) {
var target = {};
for (var i in obj) {
if (keys.indexOf(i) >= 0) continue;
if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
target[i] = obj[i];
}
return target;
}
function MyComponent(_ref) {
var width = _ref.width,
height = _ref.height,
getRef = _ref.getRef,
children = _ref.children,
props = _objectWithoutProperties(_ref, [
'width',
'height',
'getRef',
'children',
]);
return React.createElement(
'div',
_extends({className: 'example', ref: getRef}, props),
"Hover me! I don't rely on any DOM manipulation, transition event or anything, I use a real resize event!",
React.createElement('br', null),
width,
'x',
height,
children
);
}
function App() {
return React.createElement(ReactResizeAware, {
component: MyComponent,
useBoundingClientRect: true,
style: {position: 'relative'},
onResize: function onResize(sizes) {
return console.log(sizes);
},
});
}
ReactDOM.render(
React.createElement(App, null),
document.querySelector('#root')
);