grape-web
Advanced tools
Comparing version 0.37.0 to 0.38.0
@@ -20,3 +20,3 @@ 'use strict'; | ||
// - enable children to be emitter | ||
// - enable debounce, throttle | ||
// - enable throttle | ||
// - use onClick etc instead of events | ||
@@ -27,28 +27,24 @@ | ||
_createClass(GlobalEvent, null, [{ | ||
key: 'propTypes', | ||
value: { | ||
emitter: _react.PropTypes.object, | ||
event: _react.PropTypes.string.isRequired, | ||
debounce: _react.PropTypes.number, | ||
handler: _react.PropTypes.func, | ||
children: _react.PropTypes.element | ||
}, | ||
enumerable: true | ||
}, { | ||
key: 'defaultProps', | ||
value: { | ||
emitter: window, | ||
event: undefined, | ||
handler: undefined, | ||
debounce: 0 | ||
}, | ||
enumerable: true | ||
}]); | ||
function GlobalEvent() { | ||
var _this = this; | ||
function GlobalEvent(props) { | ||
_classCallCheck(this, GlobalEvent); | ||
_get(Object.getPrototypeOf(GlobalEvent.prototype), 'constructor', this).call(this, props); | ||
this.handler = this.handler.bind(this); | ||
_get(Object.getPrototypeOf(GlobalEvent.prototype), 'constructor', this).apply(this, arguments); | ||
this.handler = function (e) { | ||
var _props = _this.props; | ||
var debounce = _props.debounce; | ||
var handler = _props.handler; | ||
if (debounce === undefined) { | ||
handler(e); | ||
return; | ||
} | ||
clearTimeout(_this.timeoutId); | ||
_this.timeoutId = setTimeout(function () { | ||
handler(e); | ||
}, debounce); | ||
}; | ||
} | ||
@@ -67,14 +63,2 @@ | ||
}, { | ||
key: 'handler', | ||
value: function handler(e) { | ||
var _this = this; | ||
if (this.props.debounce) { | ||
clearTimeout(this.timeoutId); | ||
this.timeoutId = setTimeout(function () { | ||
_this.props.handler(e); | ||
}); | ||
} else this.props.handler(e); | ||
} | ||
}, { | ||
key: 'render', | ||
@@ -84,2 +68,18 @@ value: function render() { | ||
} | ||
}], [{ | ||
key: 'propTypes', | ||
value: { | ||
emitter: _react.PropTypes.object, | ||
event: _react.PropTypes.string.isRequired, | ||
debounce: _react.PropTypes.number, | ||
handler: _react.PropTypes.func, | ||
children: _react.PropTypes.element | ||
}, | ||
enumerable: true | ||
}, { | ||
key: 'defaultProps', | ||
value: { | ||
emitter: window | ||
}, | ||
enumerable: true | ||
}]); | ||
@@ -86,0 +86,0 @@ |
{ | ||
"name": "grape-web", | ||
"version": "0.37.0", | ||
"version": "0.38.0", | ||
"dependencies": { | ||
@@ -5,0 +5,0 @@ "jss-isolate": "^1.0.0", |
128543
115
1408