Sfoglia il codice sorgente

WIP: sync scroll to editor from preview

* impl onScroll event to Preview component
Yuki Takei 8 anni fa
parent
commit
ec1fe79a6a
1 ha cambiato i file con 6 aggiunte e 0 eliminazioni
  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) => {
           ref={(elm) => {
             this.previewElement = elm;
             this.previewElement = elm;
             this.props.inputRef(elm);
             this.props.inputRef(elm);
+          }}
+          onScroll={(event) => {
+            if (this.props.onScroll != null) {
+              this.props.onScroll(event.target.scrollTop);
+            }
           }}>
           }}>
 
 
         <RevisionBody
         <RevisionBody
@@ -39,4 +44,5 @@ Preview.propTypes = {
   isMathJaxEnabled: PropTypes.bool,
   isMathJaxEnabled: PropTypes.bool,
   renderMathJaxOnInit: PropTypes.bool,
   renderMathJaxOnInit: PropTypes.bool,
   previewOptions: PropTypes.instanceOf(PreviewOptions),
   previewOptions: PropTypes.instanceOf(PreviewOptions),
+  onScroll: PropTypes.func,
 };
 };