Skip to content

Commit 8a1458d

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

File tree

2 files changed

+97
-3
lines changed

2 files changed

+97
-3
lines changed

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

Lines changed: 26 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,31 @@ 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+
if (isNarrowAspectRatio) {
214+
// Horizontal layout
215+
const itemWidth = thumbnailWidth + (2 * margin);
216+
const fullyVisibleCount = Math.floor(width / itemWidth);
217+
const currentVisibleCount = endIndex - startIndex + 1;
218+
219+
if (currentVisibleCount > fullyVisibleCount) {
220+
endIndex = startIndex + fullyVisibleCount - 1;
221+
}
222+
} else {
223+
// Vertical layout
224+
const itemHeight = thumbnailHeight + (2 * margin);
225+
const fullyVisibleCount = Math.floor(height / itemHeight);
226+
const currentVisibleCount = endIndex - startIndex + 1;
227+
228+
if (currentVisibleCount > fullyVisibleCount) {
229+
endIndex = startIndex + fullyVisibleCount - 1;
230+
}
231+
}
232+
208233
if (!this._separateLocalThumbnail && !_disableSelfView) {
209234
// We are off by one in the remote participants array.
210235
startIndex -= 1;

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

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,42 @@ 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+
const fullyVisibleCount = Math.floor(containerSize / itemSize);
898+
899+
// Calculate how many items are currently in the visible range (inclusive)
900+
const currentVisibleCount = stopIndex - startIndex + 1;
901+
902+
// If we have more items visible than can fit fully, we have a partially visible tile at the end
903+
if (currentVisibleCount > fullyVisibleCount) {
904+
// Reduce stopIndex to exclude the partially visible tile
905+
return {
906+
startIndex,
907+
stopIndex: startIndex + fullyVisibleCount - 1
908+
};
909+
}
910+
911+
return {
912+
startIndex,
913+
stopIndex
914+
};
915+
}
916+
881917
/**
882918
* Toggle the toolbar visibility when tabbing into it.
883919
*
@@ -944,8 +980,41 @@ class Filmstrip extends PureComponent <IProps, IState> {
944980
*/
945981
_onListItemsRendered({ visibleStartIndex, visibleStopIndex }: {
946982
visibleStartIndex: number; visibleStopIndex: number; }) {
947-
const { dispatch } = this.props;
948-
const { startIndex, stopIndex } = this._calculateIndices(visibleStartIndex, visibleStopIndex);
983+
const {
984+
dispatch,
985+
_currentLayout,
986+
_filmstripWidth,
987+
_filmstripHeight,
988+
_thumbnailWidth,
989+
_thumbnailHeight,
990+
_isVerticalFilmstrip
991+
} = this.props;
992+
993+
let adjustedStartIndex = visibleStartIndex;
994+
let adjustedStopIndex = visibleStopIndex;
995+
996+
// Exclude partially visible tiles
997+
if (_currentLayout === LAYOUTS.HORIZONTAL_FILMSTRIP_VIEW) {
998+
const itemSize = _thumbnailWidth + TILE_HORIZONTAL_MARGIN;
999+
1000+
({ startIndex: adjustedStartIndex, stopIndex: adjustedStopIndex } = this._excludePartiallyVisibleTiles(
1001+
visibleStartIndex,
1002+
visibleStopIndex,
1003+
_filmstripWidth,
1004+
itemSize
1005+
));
1006+
} else if (_isVerticalFilmstrip) {
1007+
const itemSize = _thumbnailHeight + TILE_VERTICAL_MARGIN;
1008+
1009+
({ startIndex: adjustedStartIndex, stopIndex: adjustedStopIndex } = this._excludePartiallyVisibleTiles(
1010+
visibleStartIndex,
1011+
visibleStopIndex,
1012+
_filmstripHeight,
1013+
itemSize
1014+
));
1015+
}
1016+
1017+
const { startIndex, stopIndex } = this._calculateIndices(adjustedStartIndex, adjustedStopIndex);
9491018

9501019
dispatch(setVisibleRemoteParticipants(startIndex, stopIndex));
9511020
}

0 commit comments

Comments
 (0)