Skip to content

Commit ef98686

Browse files
committed
fix(filmstrip) Excludes partially visible tiles from visible participants calculation
1 parent bde8dca commit ef98686

File tree

2 files changed

+82
-3
lines changed

2 files changed

+82
-3
lines changed

react/features/filmstrip/components/native/Filmstrip.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ class Filmstrip extends PureComponent<IProps> {
190190
* @returns {void}
191191
*/
192192
_onViewableItemsChanged({ viewableItems = [] }: { viewableItems: ViewToken[]; }) {
193-
const { _disableSelfView } = this.props;
193+
const { _aspectRatio, _clientWidth, _clientHeight, _disableSelfView } = this.props;
194194

195195
if (!this._separateLocalThumbnail && !_disableSelfView && viewableItems[0]?.index === 0) {
196196
// Skip the local thumbnail.
@@ -205,6 +205,25 @@ class Filmstrip extends PureComponent<IProps> {
205205
let startIndex = Number(viewableItems[0].index);
206206
let endIndex = Number(viewableItems[viewableItems.length - 1].index);
207207

208+
// Exclude partially visible tiles
209+
const isNarrowAspectRatio = _aspectRatio === ASPECT_RATIO_NARROW;
210+
const { height: thumbnailHeight, width: thumbnailWidth, margin } = styles.thumbnail;
211+
const { height, width } = this._getDimensions();
212+
213+
// Calculate item size and container size based on layout orientation
214+
const itemSize = isNarrowAspectRatio
215+
? thumbnailWidth + (2 * margin) // Horizontal layout
216+
: thumbnailHeight + (2 * margin); // Vertical layout
217+
const containerSize = isNarrowAspectRatio ? width : height;
218+
219+
// Ensure at least 1 if there are any visible items
220+
const fullyVisibleCount = Math.max(1, Math.floor(containerSize / itemSize));
221+
const currentVisibleCount = endIndex - startIndex + 1;
222+
223+
if (currentVisibleCount > fullyVisibleCount) {
224+
endIndex = startIndex + fullyVisibleCount - 1;
225+
}
226+
208227
if (!this._separateLocalThumbnail && !_disableSelfView) {
209228
// We are off by one in the remote participants array.
210229
startIndex -= 1;

react/features/filmstrip/components/web/Filmstrip.tsx

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,43 @@ class Filmstrip extends PureComponent <IProps, IState> {
878878
};
879879
}
880880

881+
/**
882+
* Adjusts indices to exclude partially visible tiles from the list.
883+
*
884+
* @param {number} startIndex - The start index from react-window.
885+
* @param {number} stopIndex - The stop index from react-window.
886+
* @param {number} containerSize - The width or height of the filmstrip container.
887+
* @param {number} itemSize - The width or height of each item including margin.
888+
* @returns {Object}
889+
*/
890+
_excludePartiallyVisibleTiles(
891+
startIndex: number,
892+
stopIndex: number,
893+
containerSize: number,
894+
itemSize: number
895+
) {
896+
// Calculate how many items can fit fully in the container
897+
// Ensure at least 1 if there are any visible items
898+
const fullyVisibleCount = Math.max(1, Math.floor(containerSize / itemSize));
899+
900+
// Calculate how many items are currently in the visible range (inclusive)
901+
const currentVisibleCount = stopIndex - startIndex + 1;
902+
903+
// If we have more items visible than can fit fully, we have a partially visible tile at the end
904+
if (currentVisibleCount > fullyVisibleCount) {
905+
// Reduce stopIndex to exclude the partially visible tile
906+
return {
907+
startIndex,
908+
stopIndex: startIndex + fullyVisibleCount - 1
909+
};
910+
}
911+
912+
return {
913+
startIndex,
914+
stopIndex
915+
};
916+
}
917+
881918
/**
882919
* Toggle the toolbar visibility when tabbing into it.
883920
*
@@ -944,8 +981,31 @@ class Filmstrip extends PureComponent <IProps, IState> {
944981
*/
945982
_onListItemsRendered({ visibleStartIndex, visibleStopIndex }: {
946983
visibleStartIndex: number; visibleStopIndex: number; }) {
947-
const { dispatch } = this.props;
948-
const { startIndex, stopIndex } = this._calculateIndices(visibleStartIndex, visibleStopIndex);
984+
const {
985+
dispatch,
986+
_currentLayout,
987+
_filmstripWidth,
988+
_filmstripHeight,
989+
_thumbnailWidth,
990+
_thumbnailHeight,
991+
_isVerticalFilmstrip
992+
} = this.props;
993+
994+
// Exclude partially visible tiles
995+
const isHorizontal = _currentLayout === LAYOUTS.HORIZONTAL_FILMSTRIP_VIEW;
996+
const itemSize = isHorizontal
997+
? _thumbnailWidth + TILE_HORIZONTAL_MARGIN
998+
: _thumbnailHeight + TILE_VERTICAL_MARGIN;
999+
const containerSize = isHorizontal ? _filmstripWidth : _filmstripHeight;
1000+
1001+
const { startIndex: adjustedStartIndex, stopIndex: adjustedStopIndex } = this._excludePartiallyVisibleTiles(
1002+
visibleStartIndex,
1003+
visibleStopIndex,
1004+
containerSize,
1005+
itemSize
1006+
);
1007+
1008+
const { startIndex, stopIndex } = this._calculateIndices(adjustedStartIndex, adjustedStopIndex);
9491009

9501010
dispatch(setVisibleRemoteParticipants(startIndex, stopIndex));
9511011
}

0 commit comments

Comments
 (0)