Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

actions.web.js 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 the entire tile view area.
  7. */
  8. const TILE_VIEW_SIDE_MARGINS = 20;
  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. * @param {boolean} isToolboxVisible - Whether the toolbox is visible, in order
  17. * to adjust the available size.
  18. * @returns {{
  19. * type: SET_TILE_VIEW_DIMENSIONS,
  20. * dimensions: Object
  21. * }}
  22. */
  23. export function setTileViewDimensions(dimensions: Object, windowSize: Object, isChatOpen: boolean) {
  24. const { clientWidth, clientHeight } = windowSize;
  25. const heightToUse = clientHeight;
  26. let widthToUse = clientWidth;
  27. if (isChatOpen) {
  28. widthToUse -= CHAT_SIZE;
  29. }
  30. const thumbnailSize = calculateThumbnailSizeForTileView({
  31. ...dimensions,
  32. clientWidth: widthToUse,
  33. clientHeight: heightToUse
  34. });
  35. const filmstripWidth = dimensions.columns * (TILE_VIEW_SIDE_MARGINS + thumbnailSize.width);
  36. return {
  37. type: SET_TILE_VIEW_DIMENSIONS,
  38. dimensions: {
  39. gridDimensions: dimensions,
  40. thumbnailSize,
  41. filmstripWidth
  42. }
  43. };
  44. }
  45. /**
  46. * Sets the dimensions of the thumbnails in horizontal view.
  47. *
  48. * @param {number} clientHeight - The height of the window.
  49. * @returns {{
  50. * type: SET_HORIZONTAL_VIEW_DIMENSIONS,
  51. * dimensions: Object
  52. * }}
  53. */
  54. export function setHorizontalViewDimensions(clientHeight: number = 0) {
  55. return {
  56. type: SET_HORIZONTAL_VIEW_DIMENSIONS,
  57. dimensions: calculateThumbnailSizeForHorizontalView(clientHeight)
  58. };
  59. }
  60. export * from './actions.native';