Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

functions.web.js 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. // The distance from the top and bottom of the screen, as set by CSS, to
  88. // avoid overlapping UI elements.
  89. const topBottomPadding = 200;
  90. // Minimum space to keep between the sides of the tiles and the sides
  91. // of the window.
  92. const sideMargins = 30 * 2;
  93. const verticalMargins = visibleRows * 10;
  94. const viewWidth = clientWidth - sideMargins;
  95. const viewHeight = clientHeight - topBottomPadding - verticalMargins;
  96. const initialWidth = viewWidth / columns;
  97. const aspectRatioHeight = initialWidth / TILE_ASPECT_RATIO;
  98. const height = Math.floor(Math.min(aspectRatioHeight, viewHeight / visibleRows));
  99. const width = Math.floor(TILE_ASPECT_RATIO * height);
  100. return {
  101. height,
  102. width
  103. };
  104. }
  105. /**
  106. * Returns the width of the visible area (doesn't include the left margin/padding) of the the vertical filmstrip.
  107. *
  108. * @returns {number} - The width of the vertical filmstrip.
  109. */
  110. export function getVerticalFilmstripVisibleAreaWidth() {
  111. // Adding 11px for the 2px right margin, 2px borders on the left and right and 5px right padding.
  112. // Also adding 7px for the scrollbar. Note that we are not counting the left margins and paddings because this
  113. // function is used for calculating the available space and they are invisible.
  114. // TODO: Check if we can remove the left margins and paddings from the CSS.
  115. // FIXME: This function is used to calculate the size of the large video, etherpad or shared video. Once everything
  116. // is reactified this calculation will need to move to the corresponding components.
  117. const filmstripMaxWidth = (interfaceConfig.FILM_STRIP_MAX_HEIGHT || 120) + 18;
  118. return Math.min(filmstripMaxWidth, window.innerWidth);
  119. }