- {this.state.loadeditems.map((elem) => (
-
- ))}
- {/*todo css for no items to show*/}
- {this.state.loadeditems.length === 0 ? 'no items to show!' : null}
- {this.props.children}
-
- );
- }
-
- componentWillUnmount(): void {
- this.setState({});
- // unbind scroll listener when unmounting component
- document.removeEventListener('scroll', this.trackScrolling);
- }
-
- /**
- * load previews to the container
- * @param nr number of previews to load
- */
- loadPreviewBlock(nr: number): void {
- console.log('loadpreviewblock called ...');
- let ret = [];
- for (let i = 0; i < nr; i++) {
- // only add if not end
- if (this.props.data.length > this.loadindex + i) {
- ret.push(this.props.data[this.loadindex + i]);
- }
- }
-
- this.setState({
- loadeditems: [...this.state.loadeditems, ...ret]
- });
-
- this.loadindex += nr;
- }
-
- /**
- * scroll event handler -> load new previews if on bottom
- */
- trackScrolling = (): void => {
- // comparison if current scroll position is on bottom --> 200 is bottom offset to trigger load
- if (window.innerHeight + document.documentElement.scrollTop + 200 >= document.documentElement.offsetHeight) {
- this.loadPreviewBlock(8);
- }
- };
-}
+const VideoContainer = (props: Props): JSX.Element => {
+ return (
+