Skip to content

Commit 99fc196

Browse files
committed
Merge pull request JedWatson#44 from amine7536/master
adding onScroll event
2 parents 738ea62 + c699858 commit 99fc196

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Codemirror.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const CodeMirror = React.createClass({
66
propTypes: {
77
onChange: React.PropTypes.func,
88
onFocusChange: React.PropTypes.func,
9+
onScroll: React.PropTypes.func,
910
options: React.PropTypes.object,
1011
path: React.PropTypes.string,
1112
value: React.PropTypes.string,
@@ -27,6 +28,7 @@ const CodeMirror = React.createClass({
2728
this.codeMirror.on('change', this.codemirrorValueChanged);
2829
this.codeMirror.on('focus', this.focusChanged.bind(this, true));
2930
this.codeMirror.on('blur', this.focusChanged.bind(this, false));
31+
this.codeMirror.on('scroll', this.scrollChanged);
3032
this.codeMirror.setValue(this.props.defaultValue || this.props.value || '');
3133
},
3234
componentWillUnmount () {
@@ -61,6 +63,9 @@ const CodeMirror = React.createClass({
6163
});
6264
this.props.onFocusChange && this.props.onFocusChange(focused);
6365
},
66+
scrollChanged(cm) {
67+
this.props.onScroll && this.props.onScroll(cm.getScrollInfo());
68+
},
6469
codemirrorValueChanged (doc, change) {
6570
if (this.props.onChange && change.origin != 'setValue') {
6671
this.props.onChange(doc.getValue());

0 commit comments

Comments
 (0)