jiti-meet/modules/UI/videolayout/Filmstrip.js

179 lines
5.3 KiB
JavaScript
Raw Normal View History

/* global $, APP, interfaceConfig */
import { getVerticalFilmstripVisibleAreaWidth, isFilmstripVisible } from '../../../react/features/filmstrip';
const Filmstrip = {
2016-11-03 13:12:45 +00:00
/**
* Returns the height of filmstrip
* @returns {number} height
*/
getFilmstripHeight() {
// FIXME Make it more clear the getFilmstripHeight check is used in
// horizontal film strip mode for calculating how tall large video
// display should be.
if (isFilmstripVisible(APP.store) && !interfaceConfig.VERTICAL_FILMSTRIP) {
return $('.filmstrip').outerHeight();
}
return 0;
},
/**
* Returns the width of the vertical filmstip if the filmstrip is visible and 0 otherwise.
*
* @returns {number} - The width of the vertical filmstip if the filmstrip is visible and 0 otherwise.
*/
getVerticalFilmstripWidth() {
return isFilmstripVisible(APP.store) ? getVerticalFilmstripVisibleAreaWidth() : 0;
2016-09-15 02:20:54 +00:00
},
2016-11-07 23:00:50 +00:00
/**
* Resizes thumbnails for tile view.
2016-11-07 23:00:50 +00:00
*
* @param {number} width - The new width of the thumbnails.
* @param {number} height - The new height of the thumbnails.
* @param {boolean} forceUpdate
* @returns {void}
2016-11-07 23:00:50 +00:00
*/
resizeThumbnailsForTileView(width, height, forceUpdate = false) {
const thumbs = this._getThumbs(!forceUpdate);
const avatarSize = height / 2;
if (thumbs.localThumb) {
thumbs.localThumb.css({
'padding-top': '',
height: `${height}px`,
'min-height': `${height}px`,
'min-width': `${width}px`,
width: `${width}px`
});
2016-09-15 02:20:54 +00:00
}
if (thumbs.remoteThumbs) {
thumbs.remoteThumbs.css({
'padding-top': '',
height: `${height}px`,
'min-height': `${height}px`,
'min-width': `${width}px`,
width: `${width}px`
2016-11-04 16:13:57 +00:00
});
}
$('.avatar-container').css({
height: `${avatarSize}px`,
width: `${avatarSize}px`
});
},
/**
* Resizes thumbnails for horizontal view.
*
* @param {Object} dimensions - The new dimensions of the thumbnails.
* @param {boolean} forceUpdate
* @returns {void}
*/
resizeThumbnailsForHorizontalView({ local = {}, remote = {} }, forceUpdate = false) {
const thumbs = this._getThumbs(!forceUpdate);
if (thumbs.localThumb) {
const { height, width } = local;
const avatarSize = height / 2;
thumbs.localThumb.css({
height: `${height}px`,
'min-height': `${height}px`,
'min-width': `${width}px`,
width: `${width}px`
});
$('#localVideoContainer > .avatar-container').css({
height: `${avatarSize}px`,
width: `${avatarSize}px`
});
}
if (thumbs.remoteThumbs) {
const { height, width } = remote;
const avatarSize = height / 2;
thumbs.remoteThumbs.css({
height: `${height}px`,
'min-height': `${height}px`,
'min-width': `${width}px`,
width: `${width}px`
});
$('#filmstripRemoteVideosContainer > span > .avatar-container').css({
height: `${avatarSize}px`,
width: `${avatarSize}px`
});
}
},
2016-11-03 13:12:45 +00:00
/**
* Resizes thumbnails for vertical view.
*
* @returns {void}
2016-11-03 13:12:45 +00:00
*/
resizeThumbnailsForVerticalView() {
const thumbs = this._getThumbs(true);
if (thumbs.localThumb) {
const heightToWidthPercent = 100 / interfaceConfig.LOCAL_THUMBNAIL_RATIO;
thumbs.localThumb.css({
'padding-top': `${heightToWidthPercent}%`,
width: '',
height: '',
'min-width': '',
'min-height': ''
});
$('#localVideoContainer > .avatar-container').css({
height: '50%',
width: `${heightToWidthPercent / 2}%`
});
}
if (thumbs.remoteThumbs) {
const heightToWidthPercent = 100 / interfaceConfig.REMOTE_THUMBNAIL_RATIO;
thumbs.remoteThumbs.css({
'padding-top': `${heightToWidthPercent}%`,
width: '',
height: '',
'min-width': '',
'min-height': ''
});
$('#filmstripRemoteVideosContainer > span > .avatar-container').css({
height: '50%',
width: `${heightToWidthPercent / 2}%`
});
}
},
2016-11-03 13:12:45 +00:00
/**
* Returns thumbnails of the filmstrip
* @param onlyVisible
2016-11-03 13:12:45 +00:00
* @returns {object} thumbnails
*/
_getThumbs(onlyVisible = false) {
let selector = 'span';
if (onlyVisible) {
selector += ':visible';
}
const localThumb = $('#localVideoContainer');
const remoteThumbs = $('#filmstripRemoteVideosContainer').children(selector);
2016-09-15 02:20:54 +00:00
2016-05-01 18:35:18 +00:00
// Exclude the local video container if it has been hidden.
if (localThumb.hasClass('hidden')) {
2016-09-15 02:20:54 +00:00
return { remoteThumbs };
}
return { remoteThumbs,
localThumb };
2016-09-28 21:31:40 +00:00
}
};
export default Filmstrip;