您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

Filmstrip.js 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /* global $, APP, interfaceConfig */
  2. import { getVerticalFilmstripVisibleAreaWidth, 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 the vertical filmstip if the filmstrip is visible and 0 otherwise.
  19. *
  20. * @returns {number} - The width of the vertical filmstip if the filmstrip is visible and 0 otherwise.
  21. */
  22. getVerticalFilmstripWidth() {
  23. return isFilmstripVisible(APP.store) ? getVerticalFilmstripVisibleAreaWidth() : 0;
  24. },
  25. /**
  26. * Resizes thumbnails for tile view.
  27. *
  28. * @param {number} width - The new width of the thumbnails.
  29. * @param {number} height - The new height of the thumbnails.
  30. * @param {boolean} forceUpdate
  31. * @returns {void}
  32. */
  33. resizeThumbnailsForTileView(width, height, forceUpdate = false) {
  34. const thumbs = this._getThumbs(!forceUpdate);
  35. const avatarSize = height / 2;
  36. if (thumbs.localThumb) {
  37. thumbs.localThumb.css({
  38. 'padding-top': '',
  39. height: `${height}px`,
  40. 'min-height': `${height}px`,
  41. 'min-width': `${width}px`,
  42. width: `${width}px`
  43. });
  44. }
  45. if (thumbs.remoteThumbs) {
  46. thumbs.remoteThumbs.css({
  47. 'padding-top': '',
  48. height: `${height}px`,
  49. 'min-height': `${height}px`,
  50. 'min-width': `${width}px`,
  51. width: `${width}px`
  52. });
  53. }
  54. $('.avatar-container').css({
  55. height: `${avatarSize}px`,
  56. width: `${avatarSize}px`
  57. });
  58. },
  59. /**
  60. * Resizes thumbnails for horizontal view.
  61. *
  62. * @param {Object} dimensions - The new dimensions of the thumbnails.
  63. * @param {boolean} forceUpdate
  64. * @returns {void}
  65. */
  66. resizeThumbnailsForHorizontalView({ local = {}, remote = {} }, forceUpdate = false) {
  67. const thumbs = this._getThumbs(!forceUpdate);
  68. if (thumbs.localThumb) {
  69. const { height, width } = local;
  70. const avatarSize = height / 2;
  71. thumbs.localThumb.css({
  72. height: `${height}px`,
  73. 'min-height': `${height}px`,
  74. 'min-width': `${width}px`,
  75. width: `${width}px`
  76. });
  77. $('#localVideoContainer > .avatar-container').css({
  78. height: `${avatarSize}px`,
  79. width: `${avatarSize}px`
  80. });
  81. }
  82. if (thumbs.remoteThumbs) {
  83. const { height, width } = remote;
  84. const avatarSize = height / 2;
  85. thumbs.remoteThumbs.css({
  86. height: `${height}px`,
  87. 'min-height': `${height}px`,
  88. 'min-width': `${width}px`,
  89. width: `${width}px`
  90. });
  91. $('#filmstripRemoteVideosContainer > span > .avatar-container').css({
  92. height: `${avatarSize}px`,
  93. width: `${avatarSize}px`
  94. });
  95. }
  96. },
  97. /**
  98. * Resizes thumbnails for vertical view.
  99. *
  100. * @returns {void}
  101. */
  102. resizeThumbnailsForVerticalView() {
  103. const thumbs = this._getThumbs(true);
  104. if (thumbs.localThumb) {
  105. const heightToWidthPercent = 100 / interfaceConfig.LOCAL_THUMBNAIL_RATIO;
  106. thumbs.localThumb.css({
  107. 'padding-top': `${heightToWidthPercent}%`,
  108. width: '',
  109. height: '',
  110. 'min-width': '',
  111. 'min-height': ''
  112. });
  113. $('#localVideoContainer > .avatar-container').css({
  114. height: '50%',
  115. width: `${heightToWidthPercent / 2}%`
  116. });
  117. }
  118. if (thumbs.remoteThumbs) {
  119. const heightToWidthPercent = 100 / interfaceConfig.REMOTE_THUMBNAIL_RATIO;
  120. thumbs.remoteThumbs.css({
  121. 'padding-top': `${heightToWidthPercent}%`,
  122. width: '',
  123. height: '',
  124. 'min-width': '',
  125. 'min-height': ''
  126. });
  127. $('#filmstripRemoteVideosContainer > span > .avatar-container').css({
  128. height: '50%',
  129. width: `${heightToWidthPercent / 2}%`
  130. });
  131. }
  132. },
  133. /**
  134. * Returns thumbnails of the filmstrip
  135. * @param onlyVisible
  136. * @returns {object} thumbnails
  137. */
  138. _getThumbs(onlyVisible = false) {
  139. let selector = 'span';
  140. if (onlyVisible) {
  141. selector += ':visible';
  142. }
  143. const localThumb = $('#localVideoContainer');
  144. const remoteThumbs = $('#filmstripRemoteVideosContainer').children(selector);
  145. // Exclude the local video container if it has been hidden.
  146. if (localThumb.hasClass('hidden')) {
  147. return { remoteThumbs };
  148. }
  149. return { remoteThumbs,
  150. localThumb };
  151. }
  152. };
  153. export default Filmstrip;