import React from 'react'; import PropTypes from 'prop-types'; import styles from './styles.scss'; import { findDOMNode } from 'react-dom'; export default class ClosedCaptions extends React.Component { constructor(props) { super(props); this.shouldScrollBottom = false; } renderCaptions(caption) { const text = caption.captions; const captionStyles = { whiteSpace: 'pre-wrap', wordWrap: 'break-word', fontFamily: this.props.fontFamily, fontSize: this.props.fontSize, color: this.props.fontColor, }; return ( ); } componentWillUpdate() { const node = findDOMNode(this.ccScrollArea); // number 4 is for the border // offset height includes the border, but scrollheight doesn't this.shouldScrollBottom = node.scrollTop + node.offsetHeight - 4 === node.scrollHeight; } componentDidUpdate() { if (this.shouldScrollBottom) { const node = findDOMNode(this.ccScrollArea); node.scrollTop = node.scrollHeight; } } render() { const { locale, captions, backgroundColor, } = this.props; return (
{locale || 'Locale is not selected'}