You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Filmstrip.js 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /* global $, APP, interfaceConfig */
  2. import { isFilmstripVisible } from '../../../react/features/filmstrip';
  3. const Filmstrip = {
  4. /**
  5. * Returns the height of filmstrip
  6. * @returns {number} height
  7. */
  8. getFilmstripHeight() {
  9. // FIXME Make it more clear the getFilmstripHeight check is used in
  10. // horizontal film strip mode for calculating how tall large video
  11. // display should be.
  12. if (isFilmstripVisible(APP.store) && !interfaceConfig.VERTICAL_FILMSTRIP) {
  13. return $('.filmstrip').outerHeight();
  14. }
  15. return 0;
  16. },
  17. /**
  18. * Returns the width of filmstip
  19. * @returns {number} width
  20. */
  21. getFilmstripWidth() {
  22. const filmstrip = $('#remoteVideos');
  23. return isFilmstripVisible(APP.store)
  24. ? filmstrip.outerWidth()
  25. - parseInt(filmstrip.css('paddingLeft'), 10)
  26. - parseInt(filmstrip.css('paddingRight'), 10)
  27. : 0;
  28. },
  29. /**
  30. * Resizes thumbnails for tile view.
  31. *
  32. * @param {number} width - The new width of the thumbnails.
  33. * @param {number} height - The new height of the thumbnails.
  34. * @param {boolean} forceUpdate
  35. * @returns {void}
  36. */
  37. resizeThumbnailsForTileView(width, height, forceUpdate = false) {
  38. const thumbs = this._getThumbs(!forceUpdate);
  39. const avatarSize = height / 2;
  40. if (thumbs.localThumb) {
  41. thumbs.localThumb.css({
  42. 'padding-top': '',
  43. height: `${height}px`,
  44. 'min-height': `${height}px`,
  45. 'min-width': `${width}px`,
  46. width: `${width}px`
  47. });
  48. }
  49. if (thumbs.remoteThumbs) {
  50. thumbs.remoteThumbs.css({
  51. 'padding-top': '',
  52. height: `${height}px`,
  53. 'min-height': `${height}px`,
  54. 'min-width': `${width}px`,
  55. width: `${width}px`
  56. });
  57. }
  58. $('.avatar-container').css({
  59. height: `${avatarSize}px`,
  60. width: `${avatarSize}px`
  61. });
  62. },
  63. /**
  64. * Resizes thumbnails for horizontal view.
  65. *
  66. * @param {Object} dimensions - The new dimensions of the thumbnails.
  67. * @param {boolean} forceUpdate
  68. * @returns {void}
  69. */
  70. resizeThumbnailsForHorizontalView({ local = {}, remote = {} }, forceUpdate = false) {
  71. const thumbs = this._getThumbs(!forceUpdate);
  72. if (thumbs.localThumb) {
  73. const { height, width } = local;
  74. const avatarSize = height / 2;
  75. thumbs.localThumb.css({
  76. height: `${height}px`,
  77. 'min-height': `${height}px`,
  78. 'min-width': `${width}px`,
  79. width: `${width}px`
  80. });
  81. $('#localVideoContainer > .avatar-container').css({
  82. height: `${avatarSize}px`,
  83. width: `${avatarSize}px`
  84. });
  85. }
  86. if (thumbs.remoteThumbs) {
  87. const { height, width } = remote;
  88. const avatarSize = height / 2;
  89. thumbs.remoteThumbs.css({
  90. height: `${height}px`,
  91. 'min-height': `${height}px`,
  92. 'min-width': `${width}px`,
  93. width: `${width}px`
  94. });
  95. $('#filmstripRemoteVideosContainer > span > .avatar-container').css({
  96. height: `${avatarSize}px`,
  97. width: `${avatarSize}px`
  98. });
  99. }
  100. },
  101. /**
  102. * Resizes thumbnails for vertical view.
  103. *
  104. * @returns {void}
  105. */
  106. resizeThumbnailsForVerticalView() {
  107. const thumbs = this._getThumbs(true);
  108. if (thumbs.localThumb) {
  109. const heightToWidthPercent = 100 / interfaceConfig.LOCAL_THUMBNAIL_RATIO;
  110. thumbs.localThumb.css({
  111. 'padding-top': `${heightToWidthPercent}%`,
  112. width: '',
  113. height: '',
  114. 'min-width': '',
  115. 'min-height': ''
  116. });
  117. $('#localVideoContainer > .avatar-container').css({
  118. height: '50%',
  119. width: `${heightToWidthPercent / 2}%`
  120. });
  121. }
  122. if (thumbs.remoteThumbs) {
  123. const heightToWidthPercent = 100 / interfaceConfig.REMOTE_THUMBNAIL_RATIO;
  124. thumbs.remoteThumbs.css({
  125. 'padding-top': `${heightToWidthPercent}%`,
  126. width: '',
  127. height: '',
  128. 'min-width': '',
  129. 'min-height': ''
  130. });
  131. $('#filmstripRemoteVideosContainer > span > .avatar-container').css({
  132. height: '50%',
  133. width: `${heightToWidthPercent / 2}%`
  134. });
  135. }
  136. },
  137. /**
  138. * Returns thumbnails of the filmstrip
  139. * @param onlyVisible
  140. * @returns {object} thumbnails
  141. */
  142. _getThumbs(onlyVisible = false) {
  143. let selector = 'span';
  144. if (onlyVisible) {
  145. selector += ':visible';
  146. }
  147. const localThumb = $('#localVideoContainer');
  148. const remoteThumbs = $('#filmstripRemoteVideosContainer').children(selector);
  149. // Exclude the local video container if it has been hidden.
  150. if (localThumb.hasClass('hidden')) {
  151. return { remoteThumbs };
  152. }
  153. return { remoteThumbs,
  154. localThumb };
  155. }
  156. };
  157. export default Filmstrip;