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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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 (videoAreaAvailableWidth) {
  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 filmStripWidth = videoAreaAvailableWidth
  51. ? videoAreaAvailableWidth
  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)
  57. : this.getFilmStripWidth();
  58. let availableWidth = Math.floor(
  59. (filmStripWidth - numvids * (
  60. parseInt(localVideoContainer.css('borderLeftWidth'), 10)
  61. + parseInt(localVideoContainer.css('borderRightWidth'), 10)
  62. + parseInt(localVideoContainer.css('paddingLeft'), 10)
  63. + parseInt(localVideoContainer.css('paddingRight'), 10)
  64. + parseInt(localVideoContainer.css('marginLeft'), 10)
  65. + parseInt(localVideoContainer.css('marginRight'), 10)))
  66. / numvids) - numvids*10;
  67. let maxHeight
  68. // If the MAX_HEIGHT property hasn't been specified
  69. // we have the static value.
  70. = Math.min( interfaceConfig.FILM_STRIP_MAX_HEIGHT || 160,
  71. availableHeight);
  72. availableHeight
  73. = Math.min( maxHeight,
  74. availableWidth / thumbAspectRatio,
  75. window.innerHeight - 18);
  76. if (availableHeight < availableWidth / thumbAspectRatio) {
  77. availableWidth = Math.floor(availableHeight * thumbAspectRatio);
  78. }
  79. return {
  80. thumbWidth: availableWidth,
  81. thumbHeight: availableHeight
  82. };
  83. },
  84. resizeThumbnails (thumbWidth, thumbHeight,
  85. animate = false, forceUpdate = false) {
  86. return new Promise(resolve => {
  87. this.getThumbs(!forceUpdate).animate({
  88. height: thumbHeight,
  89. width: thumbWidth
  90. }, {
  91. queue: false,
  92. duration: animate ? 500 : 0,
  93. complete: resolve
  94. });
  95. this.filmStrip.animate({
  96. // adds 2 px because of small video 1px border
  97. height: thumbHeight + 2
  98. }, {
  99. queue: false,
  100. duration: animate ? 500 : 0
  101. });
  102. if (!animate) {
  103. resolve();
  104. }
  105. });
  106. },
  107. getThumbs (only_visible = false) {
  108. let selector = 'span';
  109. if (only_visible) {
  110. selector += ':visible';
  111. }
  112. return this.filmStrip.children(selector);
  113. }
  114. };
  115. export default FilmStrip;