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

Method getClosestScrollPosByStepIndex

packages/fiori/src/Wizard.ts:963–978  ·  view source on GitHub ↗

* Returns to closest scroll position for the given step index. * @private * @param stepIndex the index of a step

(stepIndex: number)

Source from the content-addressed store, hash-verified

961 * @param stepIndex the index of a step
962 */
963 getClosestScrollPosByStepIndex(stepIndex: number) {
964 if (stepIndex === 0) {
965 return 0;
966 }
967
968 // It's possible to have [enabled - 0, disabled - 1, enabled - 2, disabled - 3] step definition and similar.
969 // Consider selection of the third step at index 2, the wizard should scroll where the previous step ends,
970 // but in this case the 2nd step is disabled, so we have to fallback to the first possible step.
971 for (let closestStepIndex = stepIndex - 1; closestStepIndex >= 0; closestStepIndex--) {
972 if (this.stepScrollOffsets[closestStepIndex] > 0) {
973 return this.stepScrollOffsets[closestStepIndex];
974 }
975 }
976
977 return 0;
978 }
979
980 /**
981 * Returns the closest step index by given scroll position.

Callers 1

scrollToContentItemMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected