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.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /* global $, APP, interfaceConfig, config*/
  2. import UIUtil from "../util/UIUtil";
  3. const thumbAspectRatio = 1 / 1;
  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. let availableHeight = interfaceConfig.FILM_STRIP_MAX_HEIGHT;
  39. let numvids = this.getThumbs(true).length;
  40. let localVideoContainer = $("#localVideoContainer");
  41. /**
  42. * If the videoAreaAvailableWidth is set we use this one to calculate
  43. * the filmStrip width, because we're probably in a state where the
  44. * film strip size hasn't been updated yet, but it will be.
  45. */
  46. let videoAreaAvailableWidth
  47. = UIUtil.getAvailableVideoWidth(isSideBarVisible)
  48. - parseInt(this.filmStrip.css('right'), 10)
  49. - parseInt(this.filmStrip.css('paddingLeft'), 10)
  50. - parseInt(this.filmStrip.css('paddingRight'), 10)
  51. - parseInt(this.filmStrip.css('borderLeftWidth'), 10)
  52. - parseInt(this.filmStrip.css('borderRightWidth'), 10) - 5;
  53. let availableWidth = Math.floor(
  54. (videoAreaAvailableWidth - numvids * (
  55. parseInt(localVideoContainer.css('borderLeftWidth'), 10)
  56. + parseInt(localVideoContainer.css('borderRightWidth'), 10)
  57. + parseInt(localVideoContainer.css('paddingLeft'), 10)
  58. + parseInt(localVideoContainer.css('paddingRight'), 10)
  59. + parseInt(localVideoContainer.css('marginLeft'), 10)
  60. + parseInt(localVideoContainer.css('marginRight'), 10)))
  61. / numvids);
  62. let maxHeight
  63. // If the MAX_HEIGHT property hasn't been specified
  64. // we have the static value.
  65. = Math.min( interfaceConfig.FILM_STRIP_MAX_HEIGHT || 160,
  66. availableHeight);
  67. availableHeight
  68. = Math.min( maxHeight, window.innerHeight - 18);
  69. if (availableHeight < availableWidth) {
  70. availableWidth = availableHeight;
  71. }
  72. else
  73. availableHeight = availableWidth;
  74. return {
  75. thumbWidth: availableWidth,
  76. thumbHeight: availableHeight
  77. };
  78. },
  79. resizeThumbnails (thumbWidth, thumbHeight,
  80. animate = false, forceUpdate = false) {
  81. return new Promise(resolve => {
  82. this.getThumbs(!forceUpdate).animate({
  83. height: thumbHeight,
  84. width: thumbWidth
  85. }, {
  86. queue: false,
  87. duration: animate ? 500 : 0,
  88. complete: resolve
  89. });
  90. this.filmStrip.animate({
  91. // adds 2 px because of small video 1px border
  92. height: thumbHeight + 2
  93. }, {
  94. queue: false,
  95. duration: animate ? 500 : 0
  96. });
  97. if (!animate) {
  98. resolve();
  99. }
  100. });
  101. },
  102. getThumbs (only_visible = false) {
  103. let selector = 'span';
  104. if (only_visible) {
  105. selector += ':visible';
  106. }
  107. return this.filmStrip.children(selector);
  108. }
  109. };
  110. export default FilmStrip;