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.

FilmStrip.js 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /* global $, APP, interfaceConfig, config*/
  2. import UIUtil from "../util/UIUtil";
  3. const thumbAspectRatio = 16.0 / 9.0;
  4. const FilmStrip = {
  5. init () {
  6. this.filmStrip = $('#remoteVideos');
  7. },
  8. toggleFilmStrip () {
  9. this.filmStrip.toggleClass("hidden");
  10. },
  11. isFilmStripVisible () {
  12. return !this.filmStrip.hasClass('hidden');
  13. },
  14. setupFilmStripOnly () {
  15. this.filmStrip.css({
  16. padding: "0px 0px 18px 0px",
  17. right: 0
  18. });
  19. },
  20. getFilmStripHeight () {
  21. if (this.isFilmStripVisible()) {
  22. return this.filmStrip.outerHeight();
  23. } else {
  24. return 0;
  25. }
  26. },
  27. getFilmStripWidth () {
  28. return this.filmStrip.innerWidth()
  29. - parseInt(this.filmStrip.css('paddingLeft'), 10)
  30. - parseInt(this.filmStrip.css('paddingRight'), 10);
  31. },
  32. /**
  33. * Calculates the thumbnail size.
  34. * @param videoAreaAvailableWidth the currently available video area width
  35. * that we want to take into account when calculating the film strip width.
  36. */
  37. calculateThumbnailSize (isSideBarVisible) {
  38. // Calculate the available height, which is the inner window height
  39. // minus 39px for the header minus 2px for the delimiter lines on the
  40. // top and bottom of the large video, minus the 36px space inside the
  41. // remoteVideos container used for highlighting shadow.
  42. let availableHeight = 100;
  43. let numvids = this.getThumbs(true).length;
  44. let localVideoContainer = $("#localVideoContainer");
  45. /**
  46. * If the videoAreaAvailableWidth is set we use this one to calculate
  47. * the filmStrip width, because we're probably in a state where the
  48. * film strip size hasn't been updated yet, but it will be.
  49. */
  50. let videoAreaAvailableWidth
  51. = UIUtil.getAvailableVideoWidth(isSideBarVisible)
  52. - parseInt(this.filmStrip.css('right'), 10)
  53. - parseInt(this.filmStrip.css('paddingLeft'), 10)
  54. - parseInt(this.filmStrip.css('paddingRight'), 10)
  55. - parseInt(this.filmStrip.css('borderLeftWidth'), 10)
  56. - parseInt(this.filmStrip.css('borderRightWidth'), 10) - 5;
  57. let availableWidth = Math.floor(
  58. (videoAreaAvailableWidth - numvids * (
  59. parseInt(localVideoContainer.css('borderLeftWidth'), 10)
  60. + parseInt(localVideoContainer.css('borderRightWidth'), 10)
  61. + parseInt(localVideoContainer.css('paddingLeft'), 10)
  62. + parseInt(localVideoContainer.css('paddingRight'), 10)
  63. + parseInt(localVideoContainer.css('marginLeft'), 10)
  64. + parseInt(localVideoContainer.css('marginRight'), 10)))
  65. / numvids);
  66. let maxHeight
  67. // If the MAX_HEIGHT property hasn't been specified
  68. // we have the static value.
  69. = Math.min( interfaceConfig.FILM_STRIP_MAX_HEIGHT || 160,
  70. availableHeight);
  71. availableHeight
  72. = Math.min( maxHeight,
  73. availableWidth / thumbAspectRatio,
  74. window.innerHeight - 18);
  75. if (availableHeight < availableWidth / thumbAspectRatio) {
  76. availableWidth = Math.floor(availableHeight * thumbAspectRatio);
  77. }
  78. return {
  79. thumbWidth: availableWidth,
  80. thumbHeight: availableHeight
  81. };
  82. },
  83. resizeThumbnails (thumbWidth, thumbHeight,
  84. animate = false, forceUpdate = false) {
  85. return new Promise(resolve => {
  86. this.getThumbs(!forceUpdate).animate({
  87. height: thumbHeight,
  88. width: thumbWidth
  89. }, {
  90. queue: false,
  91. duration: animate ? 500 : 0,
  92. complete: resolve
  93. });
  94. this.filmStrip.animate({
  95. // adds 2 px because of small video 1px border
  96. height: thumbHeight + 2
  97. }, {
  98. queue: false,
  99. duration: animate ? 500 : 0
  100. });
  101. if (!animate) {
  102. resolve();
  103. }
  104. });
  105. },
  106. getThumbs (only_visible = false) {
  107. let selector = 'span';
  108. if (only_visible) {
  109. selector += ':visible';
  110. }
  111. return this.filmStrip.children(selector);
  112. }
  113. };
  114. export default FilmStrip;