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

Method getClosestStepIndexByScrollPos

packages/fiori/src/Wizard.ts:985–1001  ·  view source on GitHub ↗

* Returns the closest step index by given scroll position. * @private * @param scrollPos the scroll position

(scrollPos: number)

Source from the content-addressed store, hash-verified

983 * @param scrollPos the scroll position
984 */
985 getClosestStepIndexByScrollPos(scrollPos: number) {
986 for (let closestStepIndex = 0; closestStepIndex <= this.stepScrollOffsets.length - 1; closestStepIndex++) {
987 const stepScrollOffset = this.stepScrollOffsets[closestStepIndex];
988 const step = this.getStepWrapperByIdx(closestStepIndex);
989 const switchStepBoundary = step.offsetTop + (step.offsetHeight * this.effectiveStepSwitchThreshold);
990
991 if (stepScrollOffset > 0 && scrollPos < stepScrollOffset) {
992 if (scrollPos > switchStepBoundary) {
993 return closestStepIndex + 1;
994 }
995
996 return closestStepIndex;
997 }
998 }
999
1000 return this.selectedStepIndex;
1001 }
1002
1003 /**
1004 * Switches the selection from the old step to the newly selected step.

Callers 1

Calls 1

getStepWrapperByIdxMethod · 0.95

Tested by

no test coverage detected