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

actions.web.js 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // @flow
  2. import { CHAT_SIZE } from '../chat/constants';
  3. import { SET_HORIZONTAL_VIEW_DIMENSIONS, SET_TILE_VIEW_DIMENSIONS } from './actionTypes';
  4. import { calculateThumbnailSizeForHorizontalView, calculateThumbnailSizeForTileView } from './functions';
  5. /**
  6. * The size of the side margins for each tile as set in CSS.
  7. */
  8. const TILE_VIEW_SIDE_MARGINS = 10 * 2;
  9. /**
  10. * Sets the dimensions of the tile view grid.
  11. *
  12. * @param {Object} dimensions - Whether the filmstrip is visible.
  13. * @param {Object} windowSize - The size of the window.
  14. * @param {boolean} isChatOpen - Whether the chat panel is displayed, in
  15. * order to properly compute the tile view size.
  16. * @returns {{
  17. * type: SET_TILE_VIEW_DIMENSIONS,
  18. * dimensions: Object
  19. * }}
  20. */
  21. export function setTileViewDimensions(dimensions: Object, windowSize: Object, isChatOpen: boolean) {
  22. const { clientWidth, clientHeight } = windowSize;
  23. let widthToUse = clientWidth;
  24. if (isChatOpen) {
  25. widthToUse -= CHAT_SIZE;
  26. }
  27. const thumbnailSize = calculateThumbnailSizeForTileView({
  28. ...dimensions,
  29. clientWidth: widthToUse,
  30. clientHeight
  31. });
  32. const filmstripWidth = dimensions.columns * (TILE_VIEW_SIDE_MARGINS + thumbnailSize.width);
  33. return {
  34. type: SET_TILE_VIEW_DIMENSIONS,
  35. dimensions: {
  36. gridDimensions: dimensions,
  37. thumbnailSize,
  38. filmstripWidth
  39. }
  40. };
  41. }
  42. /**
  43. * Sets the dimensions of the thumbnails in horizontal view.
  44. *
  45. * @param {number} clientHeight - The height of the window.
  46. * @returns {{
  47. * type: SET_HORIZONTAL_VIEW_DIMENSIONS,
  48. * dimensions: Object
  49. * }}
  50. */
  51. export function setHorizontalViewDimensions(clientHeight: number = 0) {
  52. return {
  53. type: SET_HORIZONTAL_VIEW_DIMENSIONS,
  54. dimensions: calculateThumbnailSizeForHorizontalView(clientHeight)
  55. };
  56. }
  57. export * from './actions.native';