Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

FilmStrip.js 4.8KB

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