Skip to content

Commit

Permalink
lighter DOM when off-screen
Browse files Browse the repository at this point in the history
  • Loading branch information
Laurian committed Aug 13, 2019
1 parent be93c08 commit 63924f2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
"mousetrap": "1.5.2",
"prop-types": "^15.6.2",
"react-keyboard-shortcuts": "^1.1.3",
"react-simple-tooltip": "^2.3.3"
"react-simple-tooltip": "^2.3.3",
"react-visibility-sensor": "^5.1.1"
},
"peerDependencies": {
"react": "^16.6.0",
Expand Down
8 changes: 7 additions & 1 deletion packages/components/timed-text-editor/WrapperBlock.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { EditorBlock, Modifier, EditorState, SelectionState } from 'draft-js';
import VisibilitySensor from 'react-visibility-sensor';

import SpeakerLabel from './SpeakerLabel';
// import { shortTimecode, secondsToTimecode } from '../../Util/timecode-converter/';
Expand Down Expand Up @@ -109,7 +110,12 @@ class WrapperBlock extends React.Component {
{this.props.blockProps.showTimecodes ? timecodeElement : ''}
</div>
<div className={ style.text }>
<EditorBlock { ...this.props } />
<VisibilitySensor partialVisibility={true}>
{({ isVisible }) => isVisible ?
<EditorBlock { ...this.props } />
: <div contentEditable={ false }>{ this.props.block.text }</div>
}
</VisibilitySensor>
</div>
</div>
);
Expand Down

0 comments on commit 63924f2

Please sign in to comment.