Fix mapXDispatch and allow plugin to access onWheel (credit: lkzhao) (#578)

* Fix mapXDispatch && allow plugin to access onWheel see https://github.com/zeit/hyperterm/pull/563
This commit is contained in:
James Hall 2016-08-06 10:17:09 +01:00 committed by GitHub
parent cc112b6683
commit 9b42c5ff52
2 changed files with 26 additions and 2 deletions

View file

@ -65,7 +65,10 @@ export default class Term extends Component {
iframeWindow.addEventListener('wheel', this.onWheel);
}
onWheel () {
onWheel (e) {
if (this.props.onWheel) {
this.props.onWheel(e);
}
this.term.prefs_.set('scrollbar-visible', true);
clearTimeout(this.scrollbarsHideTimer);
if (!this.scrollMouseEnter) {

View file

@ -266,7 +266,28 @@ export function connect (stateFn, dispatchFn, c, d = {}) {
});
return ret;
},
dispatchFn,
function (dispatch) {
let ret = dispatchFn(dispatch);
connectors[name].dispatch.forEach((fn) => {
let ret_;
try {
ret_ = fn(dispatch, ret);
} catch (err) {
console.error(err.stack);
notify('Plugin error', `${fn._pluginName}: Error occurred in \`map${name}Dispatch\`. Check Developer Tools for details.`);
return;
}
if (!ret_ || 'object' !== typeof ret_) {
notify('Plugin error', `${fn._pluginName}: Invalid return value of \`map${name}Dispatch\` (object expected).`);
return;
}
ret = ret_;
});
return ret;
},
c,
d
)(decorate(Class, name));