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

functions.web.js 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. // @flow
  2. import {
  3. getParticipantCountWithFake,
  4. getPinnedParticipant
  5. } from '../base/participants';
  6. import { toState } from '../base/redux';
  7. import { TILE_ASPECT_RATIO } from './constants';
  8. declare var interfaceConfig: Object;
  9. /**
  10. * Returns true if the filmstrip on mobile is visible, false otherwise.
  11. *
  12. * NOTE: Filmstrip on web behaves differently to mobile, much simpler, but so
  13. * function lies here only for the sake of consistency and to avoid flow errors
  14. * on import.
  15. *
  16. * @param {Object | Function} stateful - The Object or Function that can be
  17. * resolved to a Redux state object with the toState function.
  18. * @returns {boolean}
  19. */
  20. export function isFilmstripVisible(stateful: Object | Function) {
  21. return toState(stateful)['features/filmstrip'].visible;
  22. }
  23. /**
  24. * Determines whether the remote video thumbnails should be displayed/visible in
  25. * the filmstrip.
  26. *
  27. * @param {Object} state - The full redux state.
  28. * @returns {boolean} - If remote video thumbnails should be displayed/visible
  29. * in the filmstrip, then {@code true}; otherwise, {@code false}.
  30. */
  31. export function shouldRemoteVideosBeVisible(state: Object) {
  32. if (state['features/invite'].calleeInfoVisible) {
  33. return false;
  34. }
  35. // Include fake participants to derive how many thumbnails are dispalyed,
  36. // as it is assumed all participants, including fake, will be displayed
  37. // in the filmstrip.
  38. const participantCount = getParticipantCountWithFake(state);
  39. let pinnedParticipant;
  40. return Boolean(
  41. participantCount > 2
  42. // Always show the filmstrip when there is another participant to
  43. // show and the filmstrip is hovered, or local video is pinned, or
  44. // the toolbar is displayed.
  45. || (participantCount > 1
  46. && (state['features/filmstrip'].hovered
  47. || state['features/toolbox'].visible
  48. || ((pinnedParticipant = getPinnedParticipant(state))
  49. && pinnedParticipant.local)))
  50. || state['features/base/config'].disable1On1Mode);
  51. }
  52. /**
  53. * Calculates the size for thumbnails when in horizontal view layout.
  54. *
  55. * @param {number} clientHeight - The height of the app window.
  56. * @returns {{local: {height, width}, remote: {height, width}}}
  57. */
  58. export function calculateThumbnailSizeForHorizontalView(clientHeight: number = 0) {
  59. const topBottomMargin = 15;
  60. const availableHeight = Math.min(clientHeight, (interfaceConfig.FILM_STRIP_MAX_HEIGHT || 120) + topBottomMargin);
  61. const height = availableHeight - topBottomMargin;
  62. return {
  63. local: {
  64. height,
  65. width: Math.floor(interfaceConfig.LOCAL_THUMBNAIL_RATIO * height)
  66. },
  67. remote: {
  68. height,
  69. width: Math.floor(interfaceConfig.REMOTE_THUMBNAIL_RATIO * height)
  70. }
  71. };
  72. }
  73. /**
  74. * Calculates the size for thumbnails when in tile view layout.
  75. *
  76. * @param {Object} dimensions - The desired dimensions of the tile view grid.
  77. * @returns {{height, width}}
  78. */
  79. export function calculateThumbnailSizeForTileView({
  80. columns,
  81. visibleRows,
  82. clientWidth,
  83. clientHeight
  84. }: Object) {
  85. // The distance from the top and bottom of the screen, as set by CSS, to
  86. // avoid overlapping UI elements.
  87. const topBottomPadding = 200;
  88. // Minimum space to keep between the sides of the tiles and the sides
  89. // of the window.
  90. const sideMargins = 30 * 2;
  91. const verticalMargins = visibleRows * 10;
  92. const viewWidth = clientWidth - sideMargins;
  93. const viewHeight = clientHeight - topBottomPadding - verticalMargins;
  94. const initialWidth = viewWidth / columns;
  95. const aspectRatioHeight = initialWidth / TILE_ASPECT_RATIO;
  96. const height = Math.floor(Math.min(aspectRatioHeight, viewHeight / visibleRows));
  97. const width = Math.floor(TILE_ASPECT_RATIO * height);
  98. return {
  99. height,
  100. width
  101. };
  102. }
  103. /**
  104. * Returns the width of the visible area (doesn't include the left margin/padding) of the the vertical filmstrip.
  105. *
  106. * @returns {number} - The width of the vertical filmstrip.
  107. */
  108. export function getVerticalFilmstripVisibleAreaWidth() {
  109. // Adding 11px for the 2px right margin, 2px borders on the left and right and 5px right padding.
  110. // Also adding 7px for the scrollbar. Note that we are not counting the left margins and paddings because this
  111. // function is used for calculating the available space and they are invisible.
  112. // TODO: Check if we can remove the left margins and paddings from the CSS.
  113. // FIXME: This function is used to calculate the size of the large video, etherpad or shared video. Once everything
  114. // is reactified this calculation will need to move to the corresponding components.
  115. const filmstripMaxWidth = (interfaceConfig.FILM_STRIP_MAX_HEIGHT || 120) + 18;
  116. return Math.min(filmstripMaxWidth, window.innerWidth);
  117. }