You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

actions.web.js 1.5KB

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