import React from 'react'; import PropTypes from 'prop-types'; import { defineMessages, injectIntl } from 'react-intl'; import injectWbResizeEvent from '/imports/ui/components/presentation/resize-wrapper/component'; import { styles } from './styles.scss'; const intlMessages = defineMessages({ noLocaleSelected: { id: 'app.submenu.closedCaptions.noLocaleSelected', description: 'label for selected language for closed captions', }, }); class ClosedCaptions extends React.PureComponent { constructor(props) { super(props); this.shouldScrollBottom = false; } componentWillUpdate() { const node = this.refCCScrollArea; // 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) { this.refCCScrollArea.scrollTop = this.refCCScrollArea.scrollHeight; } } renderCaptions(caption) { const { fontFamily, fontSize, fontColor } = this.props; const text = caption.captions; const captionStyles = { whiteSpace: 'pre-wrap', wordWrap: 'break-word', fontFamily, fontSize, color: fontColor, }; return ( ); } render() { const { locale, captions, backgroundColor, intl, } = this.props; return (
{ locale || intl.formatMessage(intlMessages.noLocaleSelected) }