選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

subscriber.web.js 6.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. // @flow
  2. import { StateListenerRegistry, equals } from '../base/redux';
  3. import { clientResized } from '../base/responsive-ui';
  4. import { setFilmstripVisible } from '../filmstrip/actions';
  5. import { getParticipantsPaneOpen } from '../participants-pane/functions';
  6. import { setOverflowDrawer } from '../toolbox/actions.web';
  7. import { getCurrentLayout, getTileViewGridDimensions, shouldDisplayTileView, LAYOUTS } from '../video-layout';
  8. import { setHorizontalViewDimensions, setTileViewDimensions } from './actions.web';
  9. import {
  10. ASPECT_RATIO_BREAKPOINT,
  11. DISPLAY_DRAWER_THRESHOLD,
  12. SINGLE_COLUMN_BREAKPOINT,
  13. TWO_COLUMN_BREAKPOINT
  14. } from './constants';
  15. /**
  16. * Listens for changes in the number of participants to calculate the dimensions of the tile view grid and the tiles.
  17. */
  18. StateListenerRegistry.register(
  19. /* selector */ state => state['features/base/participants'].length,
  20. /* listener */ (numberOfParticipants, store) => {
  21. const state = store.getState();
  22. if (shouldDisplayTileView(state)) {
  23. const gridDimensions = getTileViewGridDimensions(state);
  24. const oldGridDimensions = state['features/filmstrip'].tileViewDimensions.gridDimensions;
  25. if (!equals(gridDimensions, oldGridDimensions)) {
  26. const { clientHeight, clientWidth } = state['features/base/responsive-ui'];
  27. store.dispatch(
  28. setTileViewDimensions(
  29. gridDimensions,
  30. {
  31. clientHeight,
  32. clientWidth
  33. },
  34. store
  35. )
  36. );
  37. }
  38. }
  39. });
  40. /**
  41. * Listens for changes in the selected layout to calculate the dimensions of the tile view grid and horizontal view.
  42. */
  43. StateListenerRegistry.register(
  44. /* selector */ state => getCurrentLayout(state),
  45. /* listener */ (layout, store) => {
  46. const state = store.getState();
  47. switch (layout) {
  48. case LAYOUTS.TILE_VIEW: {
  49. const { clientHeight, clientWidth } = state['features/base/responsive-ui'];
  50. store.dispatch(
  51. setTileViewDimensions(
  52. getTileViewGridDimensions(state),
  53. {
  54. clientHeight,
  55. clientWidth
  56. },
  57. store
  58. )
  59. );
  60. break;
  61. }
  62. case LAYOUTS.HORIZONTAL_FILMSTRIP_VIEW:
  63. store.dispatch(setHorizontalViewDimensions(state['features/base/responsive-ui'].clientHeight));
  64. break;
  65. }
  66. });
  67. /**
  68. * Listens for changes in the chat state to recompute available width.
  69. */
  70. StateListenerRegistry.register(
  71. /* selector */ state => state['features/chat'].isOpen,
  72. /* listener */ (isChatOpen, store) => {
  73. const { innerWidth, innerHeight } = window;
  74. if (isChatOpen) {
  75. // $FlowFixMe
  76. document.body.classList.add('shift-right');
  77. } else {
  78. // $FlowFixMe
  79. document.body.classList.remove('shift-right');
  80. }
  81. store.dispatch(clientResized(innerWidth, innerHeight));
  82. });
  83. /**
  84. * Listens for changes in the participant pane state to calculate the
  85. * dimensions of the tile view grid and the tiles.
  86. */
  87. StateListenerRegistry.register(
  88. /* selector */ getParticipantsPaneOpen,
  89. /* listener */ (isOpen, store) => {
  90. const { innerWidth, innerHeight } = window;
  91. store.dispatch(clientResized(innerWidth, innerHeight));
  92. });
  93. /**
  94. * Listens for changes in the client width to determine whether the overflow menu(s) should be displayed as drawers.
  95. */
  96. StateListenerRegistry.register(
  97. /* selector */ state => state['features/base/responsive-ui'].clientWidth < DISPLAY_DRAWER_THRESHOLD,
  98. /* listener */ (widthBelowThreshold, store) => {
  99. store.dispatch(setOverflowDrawer(widthBelowThreshold));
  100. });
  101. /**
  102. * Gracefully hide/show the filmstrip when going past threshold.
  103. */
  104. StateListenerRegistry.register(
  105. /* selector */ state => state['features/base/responsive-ui'].clientWidth < ASPECT_RATIO_BREAKPOINT,
  106. /* listener */ (widthBelowThreshold, store) => {
  107. const state = store.getState();
  108. const { disableFilmstripAutohiding } = state['features/base/config'];
  109. if (!disableFilmstripAutohiding) {
  110. store.dispatch(setFilmstripVisible(!widthBelowThreshold));
  111. }
  112. });
  113. /**
  114. * Symbol mapping used for the tile view responsiveness computation.
  115. */
  116. const responsiveColumnMapping = {
  117. multipleColumns: Symbol('multipleColumns'),
  118. singleColumn: Symbol('singleColumn'),
  119. twoColumns: Symbol('twoColumns'),
  120. twoParticipantsSingleColumn: Symbol('twoParticipantsSingleColumn')
  121. };
  122. /**
  123. * Listens for changes in the screen size to recompute
  124. * the dimensions of the tile view grid and the tiles for responsiveness.
  125. */
  126. StateListenerRegistry.register(
  127. /* selector */ state => {
  128. const { clientWidth } = state['features/base/responsive-ui'];
  129. if (clientWidth < TWO_COLUMN_BREAKPOINT && clientWidth >= ASPECT_RATIO_BREAKPOINT) {
  130. // Forcing the recomputation of tiles when screen switches in or out of
  131. // the (TWO_COLUMN_BREAKPOINT, ASPECT_RATIO_BREAKPOINT] interval.
  132. return responsiveColumnMapping.twoColumns;
  133. } else if (clientWidth < ASPECT_RATIO_BREAKPOINT && clientWidth >= SINGLE_COLUMN_BREAKPOINT) {
  134. // Forcing the recomputation of tiles when screen switches in or out of
  135. // the (ASPECT_RATIO_BREAKPOINT, SINGLE_COLUMN_BREAKPOINT] interval.
  136. return responsiveColumnMapping.twoParticipantsSingleColumn;
  137. } else if (clientWidth < SINGLE_COLUMN_BREAKPOINT) {
  138. // Forcing the recomputation of tiles when screen switches below SINGLE_COLUMN_BREAKPOINT.
  139. return responsiveColumnMapping.singleColumn;
  140. }
  141. // Forcing the recomputation of tiles when screen switches above TWO_COLUMN_BREAKPOINT.
  142. return responsiveColumnMapping.multipleColumns;
  143. },
  144. /* listener */ (_, store) => {
  145. const state = store.getState();
  146. if (shouldDisplayTileView(state)) {
  147. const gridDimensions = getTileViewGridDimensions(state);
  148. const { clientHeight, clientWidth } = state['features/base/responsive-ui'];
  149. store.dispatch(
  150. setTileViewDimensions(
  151. gridDimensions,
  152. {
  153. clientHeight,
  154. clientWidth
  155. },
  156. store
  157. )
  158. );
  159. }
  160. });