Skip to content

Fix Performance issue for long videos. #217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"react-fast-compare": "^2.0.4",
"react-keyboard-shortcuts": "^1.1.3",
"react-simple-tooltip": "^2.6.1",
"react-visibility-sensor": "^5.1.1",
"sbd": "^1.0.15",
"smpte-timecode": "^1.2.3"
},
Expand Down
44 changes: 29 additions & 15 deletions packages/components/timed-text-editor/WrapperBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
convertFromRaw,
convertToRaw
} from 'draft-js';

import VisibilitySensor from 'react-visibility-sensor';
import SpeakerLabel from './SpeakerLabel';
// import { shortTimecode, secondsToTimecode } from '../../Util/timecode-converter/';

Expand Down Expand Up @@ -50,7 +50,8 @@ class WrapperBlock extends React.Component {

this.setState({
speaker: speaker,
start: start
start: start,
getElement: document.querySelector(".notranslate")
});
}
// reducing unnecessary re-renders
Expand Down Expand Up @@ -165,7 +166,16 @@ class WrapperBlock extends React.Component {
}
};

visibilityChanged = (isVisible) => {
console.log("ISVISIBLE", isVisible);
}

render() {

let containmentDOMRect = this.state.getElement
? this.state.getElement
: null;

let startTimecode = this.state.start;
if (this.props.blockProps.timecodeOffset) {
startTimecode += this.props.blockProps.timecodeOffset;
Expand All @@ -186,19 +196,23 @@ class WrapperBlock extends React.Component {
);

return (
<div className={ style.WrapperBlock }>
<div
className={ [ style.markers, style.unselectable ].join(' ') }
contentEditable={ false }
>
{this.props.blockProps.showSpeakers ? speakerElement : ''}

{this.props.blockProps.showTimecodes ? timecodeElement : ''}
</div>
<div className={ style.text }>
<EditorBlock { ...this.props } />
</div>
</div>
<VisibilitySensor partialVisibility={true} onChange={this.visibilityChanged} containment={containmentDOMRect} scrollCheck>
{({isVisible}) => isVisible ?
<div className={ style.WrapperBlock }>
<div
className={ [ style.markers, style.unselectable ].join(' ') }
contentEditable={ false }
>
{this.props.blockProps.showSpeakers ? speakerElement : ''}

{this.props.blockProps.showTimecodes ? timecodeElement : ''}
</div>
<div className={ style.text }>
<EditorBlock { ...this.props } />
</div>
</div> : <div className={ style.WrapperBlock + " " + style.loadingBlockPlaceholder }>loading...</div>
}
</VisibilitySensor>
);
}
}
Expand Down
13 changes: 13 additions & 0 deletions packages/components/timed-text-editor/WrapperBlock.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ to get text out of component with timecodes and speaker names in the interim */
user-select: none;
}



/* Desktop size */
@media (min-width: 768px) {

Expand Down Expand Up @@ -79,6 +81,17 @@ to get text out of component with timecodes and speaker names in the interim */
margin-right: 0.5em;
}

.loadingBlockPlaceholder{
display: flex;
width: 100%;
/* min-height: 50px; */
font-weight: bold;
justify-content: center;
margin: 10px 0px;
align-items: center;
justify-items: center;
background-color: #f7f7f7;
}

/* Mobile devices */
@media (max-width: 768px) {
Expand Down