Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

FilmStrip.js 5.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. /* global $, APP, interfaceConfig, config*/
  2. import UIEvents from "../../../service/UI/UIEvents";
  3. import UIUtil from "../util/UIUtil";
  4. const thumbAspectRatio = 1 / 1;
  5. const FilmStrip = {
  6. /**
  7. *
  8. * @param eventEmitter the {EventEmitter} through which {FilmStrip} is to
  9. * emit/fire {UIEvents} (such as {UIEvents.TOGGLED_FILM_STRIP}).
  10. */
  11. init (eventEmitter) {
  12. this.filmStrip = $('#remoteVideos');
  13. this.eventEmitter = eventEmitter;
  14. },
  15. /**
  16. * Toggles the visibility of the film strip.
  17. *
  18. * @param visible optional {Boolean} which specifies the desired visibility
  19. * of the film strip. If not specified, the visibility will be flipped
  20. * (i.e. toggled); otherwise, the visibility will be set to the specified
  21. * value.
  22. */
  23. toggleFilmStrip (visible) {
  24. if (typeof visible === 'boolean'
  25. && this.isFilmStripVisible() == visible) {
  26. return;
  27. }
  28. this.filmStrip.toggleClass("hidden");
  29. // Emit/fire UIEvents.TOGGLED_FILM_STRIP.
  30. var eventEmitter = this.eventEmitter;
  31. if (eventEmitter) {
  32. eventEmitter.emit(
  33. UIEvents.TOGGLED_FILM_STRIP,
  34. this.isFilmStripVisible());
  35. }
  36. },
  37. isFilmStripVisible () {
  38. return !this.filmStrip.hasClass('hidden');
  39. },
  40. setupFilmStripOnly () {
  41. this.filmStrip.css({
  42. padding: "0px 0px 18px 0px",
  43. right: 0
  44. });
  45. },
  46. getFilmStripHeight () {
  47. if (this.isFilmStripVisible()) {
  48. return this.filmStrip.outerHeight();
  49. } else {
  50. return 0;
  51. }
  52. },
  53. getFilmStripWidth () {
  54. return this.filmStrip.innerWidth()
  55. - parseInt(this.filmStrip.css('paddingLeft'), 10)
  56. - parseInt(this.filmStrip.css('paddingRight'), 10);
  57. },
  58. /**
  59. * Calculates the thumbnail size.
  60. * @param videoAreaAvailableWidth the currently available video area width
  61. * that we want to take into account when calculating the film strip width.
  62. */
  63. calculateThumbnailSize (isSideBarVisible) {
  64. let availableHeight = interfaceConfig.FILM_STRIP_MAX_HEIGHT;
  65. let numvids = this.getThumbs(true).length;
  66. let localVideoContainer = $("#localVideoContainer");
  67. /**
  68. * If the videoAreaAvailableWidth is set we use this one to calculate
  69. * the filmStrip width, because we're probably in a state where the
  70. * film strip size hasn't been updated yet, but it will be.
  71. */
  72. let videoAreaAvailableWidth
  73. = UIUtil.getAvailableVideoWidth(isSideBarVisible)
  74. - UIUtil.parseCssInt(this.filmStrip.css('right'), 10)
  75. - UIUtil.parseCssInt(this.filmStrip.css('paddingLeft'), 10)
  76. - UIUtil.parseCssInt(this.filmStrip.css('paddingRight'), 10)
  77. - UIUtil.parseCssInt(this.filmStrip.css('borderLeftWidth'), 10)
  78. - UIUtil.parseCssInt(this.filmStrip.css('borderRightWidth'), 10)
  79. - 5;
  80. let availableWidth = videoAreaAvailableWidth;
  81. // If the number of videos is 0 or undefined we don't need to calculate
  82. // further.
  83. if (numvids)
  84. availableWidth = Math.floor(
  85. (videoAreaAvailableWidth - numvids * (
  86. UIUtil.parseCssInt(
  87. localVideoContainer.css('borderLeftWidth'), 10)
  88. + UIUtil.parseCssInt(
  89. localVideoContainer.css('borderRightWidth'), 10)
  90. + UIUtil.parseCssInt(
  91. localVideoContainer.css('paddingLeft'), 10)
  92. + UIUtil.parseCssInt(
  93. localVideoContainer.css('paddingRight'), 10)
  94. + UIUtil.parseCssInt(
  95. localVideoContainer.css('marginLeft'), 10)
  96. + UIUtil.parseCssInt(
  97. localVideoContainer.css('marginRight'), 10)))
  98. / numvids);
  99. let maxHeight
  100. // If the MAX_HEIGHT property hasn't been specified
  101. // we have the static value.
  102. = Math.min( interfaceConfig.FILM_STRIP_MAX_HEIGHT || 120,
  103. availableHeight);
  104. availableHeight
  105. = Math.min( maxHeight, window.innerHeight - 18);
  106. if (availableHeight < availableWidth) {
  107. availableWidth = availableHeight;
  108. }
  109. else
  110. availableHeight = availableWidth;
  111. return {
  112. thumbWidth: availableWidth,
  113. thumbHeight: availableHeight
  114. };
  115. },
  116. resizeThumbnails (thumbWidth, thumbHeight,
  117. animate = false, forceUpdate = false) {
  118. return new Promise(resolve => {
  119. this.getThumbs(!forceUpdate).animate({
  120. height: thumbHeight,
  121. width: thumbWidth
  122. }, {
  123. queue: false,
  124. duration: animate ? 500 : 0,
  125. complete: resolve
  126. });
  127. this.filmStrip.animate({
  128. // adds 2 px because of small video 1px border
  129. height: thumbHeight + 2
  130. }, {
  131. queue: false,
  132. duration: animate ? 500 : 0
  133. });
  134. if (!animate) {
  135. resolve();
  136. }
  137. });
  138. },
  139. getThumbs (only_visible = false) {
  140. let selector = 'span';
  141. if (only_visible) {
  142. selector += ':visible';
  143. }
  144. // Exclude the local video container if it has been hidden.
  145. if ($("#localVideoContainer").hasClass("hidden"))
  146. return this.filmStrip.children(selector)
  147. .not("#localVideoContainer");
  148. else
  149. return this.filmStrip.children(selector);
  150. }
  151. };
  152. export default FilmStrip;