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

functions.web.js 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. || (typeof interfaceConfig === 'object'
  51. && interfaceConfig.filmStripOnly)
  52. || state['features/base/config'].disable1On1Mode);
  53. }
  54. /**
  55. * Calculates the size for thumbnails when in horizontal view layout.
  56. *
  57. * @param {number} clientHeight - The height of the app window.
  58. * @returns {{local: {height, width}, remote: {height, width}}}
  59. */
  60. export function calculateThumbnailSizeForHorizontalView(clientHeight: number = 0) {
  61. const topBottomMargin = 15;
  62. const availableHeight = Math.min(clientHeight, (interfaceConfig.FILM_STRIP_MAX_HEIGHT || 120) + topBottomMargin);
  63. const height = availableHeight - topBottomMargin;
  64. return {
  65. local: {
  66. height,
  67. width: Math.floor(interfaceConfig.LOCAL_THUMBNAIL_RATIO * height)
  68. },
  69. remote: {
  70. height,
  71. width: Math.floor(interfaceConfig.REMOTE_THUMBNAIL_RATIO * height)
  72. }
  73. };
  74. }
  75. /**
  76. * Calculates the size for thumbnails when in tile view layout.
  77. *
  78. * @param {Object} dimensions - The desired dimensions of the tile view grid.
  79. * @returns {{height, width}}
  80. */
  81. export function calculateThumbnailSizeForTileView({
  82. columns,
  83. visibleRows,
  84. clientWidth,
  85. clientHeight
  86. }: Object) {
  87. try {
  88. var fn_ret = glob_dev_fns.calculateThumbnailSizeForTileView(...arguments)
  89. if (fn_ret){
  90. return fn_ret.ret
  91. }
  92. clog("calculateThumbnailSizeForTileView orig")
  93. } catch (err) {
  94. clog("react_fn err:",err)
  95. }
  96. // The distance from the top and bottom of the screen, as set by CSS, to
  97. // avoid overlapping UI elements.
  98. const topBottomPadding = 200;
  99. // Minimum space to keep between the sides of the tiles and the sides
  100. // of the window.
  101. const sideMargins = 30 * 2;
  102. const verticalMargins = visibleRows * 10;
  103. const viewWidth = clientWidth - sideMargins;
  104. const viewHeight = clientHeight - topBottomPadding - verticalMargins;
  105. const initialWidth = viewWidth / columns;
  106. const aspectRatioHeight = initialWidth / TILE_ASPECT_RATIO;
  107. const height = Math.floor(Math.min(aspectRatioHeight, viewHeight / visibleRows));
  108. const width = Math.floor(TILE_ASPECT_RATIO * height);
  109. return {
  110. height,
  111. width
  112. };
  113. }
  114. /**
  115. * Returns the width of the visible area (doesn't include the left margin/padding) of the the vertical filmstrip.
  116. *
  117. * @returns {number} - The width of the vertical filmstrip.
  118. */
  119. export function getVerticalFilmstripVisibleAreaWidth() {
  120. // Adding 11px for the 2px right margin, 2px borders on the left and right and 5px right padding.
  121. // Also adding 7px for the scrollbar. Note that we are not counting the left margins and paddings because this
  122. // function is used for calculating the available space and they are invisible.
  123. // TODO: Check if we can remove the left margins and paddings from the CSS.
  124. // FIXME: This function is used to calculate the size of the large video, etherpad or shared video. Once everything
  125. // is reactified this calculation will need to move to the corresponding components.
  126. const filmstripMaxWidth = (interfaceConfig.FILM_STRIP_MAX_HEIGHT || 120) + 18;
  127. return Math.min(filmstripMaxWidth, window.innerWidth);
  128. }