feat(large-video): Switch to tile view on large video double tap

This commit is contained in:
Vlad Piersec 2021-10-05 12:10:50 +03:00 committed by vp8x8
parent fed018eb08
commit f879ecfc70
1 changed files with 58 additions and 2 deletions

View File

@ -7,6 +7,7 @@ import { connect } from '../../base/redux';
import { setColorAlpha } from '../../base/util'; import { setColorAlpha } from '../../base/util';
import { SharedVideo } from '../../shared-video/components/web'; import { SharedVideo } from '../../shared-video/components/web';
import { Captions } from '../../subtitles/'; import { Captions } from '../../subtitles/';
import { setTileView } from '../../video-layout/actions';
declare var interfaceConfig: Object; declare var interfaceConfig: Object;
@ -36,7 +37,12 @@ type Props = {
* Used to determine the value of the autoplay attribute of the underlying * Used to determine the value of the autoplay attribute of the underlying
* video element. * video element.
*/ */
_noAutoPlayVideo: boolean _noAutoPlayVideo: boolean,
/**
* The Redux dispatch function.
*/
dispatch: Function
} }
/** /**
@ -46,6 +52,19 @@ type Props = {
* @extends Component * @extends Component
*/ */
class LargeVideo extends Component<Props> { class LargeVideo extends Component<Props> {
_tappedTimeout: ?TimeoutID
/**
* Constructor of the component.
*
* @inheritdoc
*/
constructor(props) {
super(props);
this._clearTapTimeout = this._clearTapTimeout.bind(this);
this._onDoubleTap = this._onDoubleTap.bind(this);
}
/** /**
* Implements React's {@link Component#render()}. * Implements React's {@link Component#render()}.
@ -71,7 +90,9 @@ class LargeVideo extends Component<Props> {
<Watermarks /> <Watermarks />
<div id = 'dominantSpeaker'> <div
id = 'dominantSpeaker'
onTouchEnd = { this._onDoubleTap }>
<div className = 'dynamic-shadow' /> <div className = 'dynamic-shadow' />
<div id = 'dominantSpeakerAvatarContainer' /> <div id = 'dominantSpeakerAvatarContainer' />
</div> </div>
@ -90,6 +111,7 @@ class LargeVideo extends Component<Props> {
*/} */}
<div <div
id = 'largeVideoWrapper' id = 'largeVideoWrapper'
onTouchEnd = { this._onDoubleTap }
role = 'figure' > role = 'figure' >
<video <video
autoPlay = { !_noAutoPlayVideo } autoPlay = { !_noAutoPlayVideo }
@ -104,6 +126,19 @@ class LargeVideo extends Component<Props> {
); );
} }
_clearTapTimeout: () => void
/**
* Clears the '_tappedTimout'.
*
* @private
* @returns {void}
*/
_clearTapTimeout() {
clearTimeout(this._tappedTimeout);
this._tappedTimeout = undefined;
}
/** /**
* Creates the custom styles object. * Creates the custom styles object.
* *
@ -129,6 +164,27 @@ class LargeVideo extends Component<Props> {
return styles; return styles;
} }
_onDoubleTap: () => void
/**
* Creates the custom styles object.
*
* @param {Object} e - The event.
* @private
* @returns {void}
*/
_onDoubleTap(e) {
e.stopPropagation();
e.preventDefault();
if (this._tappedTimeout) {
this._clearTapTimeout();
this.props.dispatch(setTileView(true));
} else {
this._tappedTimeout = setTimeout(this._clearTapTimeout, 300);
}
}
} }