Просмотр исходного кода

WIP: sync scroll to editor from preview

* impl onScroll event to Preview component
Yuki Takei 8 лет назад
Родитель
Сommit
ec1fe79a6a
1 измененных файлов с 6 добавлено и 0 удалено
  1. 6 0
      resource/js/components/PageEditor/Preview.js

+ 6 - 0
resource/js/components/PageEditor/Preview.js

@@ -22,6 +22,11 @@ export default class Preview extends React.Component {
           ref={(elm) => {
             this.previewElement = elm;
             this.props.inputRef(elm);
+          }}
+          onScroll={(event) => {
+            if (this.props.onScroll != null) {
+              this.props.onScroll(event.target.scrollTop);
+            }
           }}>
 
         <RevisionBody
@@ -39,4 +44,5 @@ Preview.propTypes = {
   isMathJaxEnabled: PropTypes.bool,
   renderMathJaxOnInit: PropTypes.bool,
   previewOptions: PropTypes.instanceOf(PreviewOptions),
+  onScroll: PropTypes.func,
 };