MCPcopy Create free account
hub / github.com/UI5/webcomponents / _findLastVisibleItem

Method _findLastVisibleItem

packages/main/src/TabContainer.ts:1265–1287  ·  view source on GitHub ↗
(itemsDomRefs: Array<TabInStrip | TabSeparatorInStrip>, containerWidth: number, selectedItemWidth: number, startIndex = 0)

Source from the content-addressed store, hash-verified

1263 }
1264
1265 _findLastVisibleItem(itemsDomRefs: Array<TabInStrip | TabSeparatorInStrip>, containerWidth: number, selectedItemWidth: number, startIndex = 0) {
1266 let lastVisibleIndex = startIndex - 1;
1267 let index = startIndex;
1268
1269 for (; index < itemsDomRefs.length; index++) {
1270 const itemWidth = this._getItemWidth(itemsDomRefs[index]);
1271
1272 if (containerWidth < selectedItemWidth + itemWidth) {
1273 break;
1274 }
1275
1276 selectedItemWidth += itemWidth;
1277 lastVisibleIndex = index;
1278 }
1279
1280 // if prev item is separator - hide it
1281 const prevItem = itemsDomRefs[index - 1];
1282 if (prevItem && prevItem.realTabReference.isSeparator) {
1283 lastVisibleIndex -= 1;
1284 }
1285
1286 return lastVisibleIndex;
1287 }
1288
1289 get isModeStartAndEnd() {
1290 return this.overflowMode === OverflowMode.StartAndEnd;

Callers 2

_updateEndOverflowMethod · 0.95

Calls 1

_getItemWidthMethod · 0.95

Tested by

no test coverage detected