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

Method changeSelectionByScroll

packages/fiori/src/Wizard.ts:638–653  ·  view source on GitHub ↗

* Called upon `onScroll`. * Selects the closest step, based on the user scroll position. * @param scrollPos the current scroll position * @private

(scrollPos: number)

Source from the content-addressed store, hash-verified

636 * @private
637 */
638 changeSelectionByScroll(scrollPos: number) {
639 const newlySelectedIndex = this.getClosestStepIndexByScrollPos(scrollPos);
640 const stepToSelect = this.slottedSteps[newlySelectedIndex];
641
642 // Skip if already selected - stop.
643 if (this.selectedStepIndex === newlySelectedIndex) {
644 return;
645 }
646
647 // If the calculated index is in range,
648 // change selection and fire "step-change".
649 if (!stepToSelect.disabled && newlySelectedIndex >= 0 && newlySelectedIndex <= this.stepsCount - 1) {
650 this.switchSelectionFromOldToNewStep(this.selectedStep, stepToSelect, newlySelectedIndex, true);
651 this.selectionRequestedByScroll = true;
652 }
653 }
654
655 /**
656 * Called upon `onSelectionChangeRequested`.

Callers

nothing calls this directly

Tested by

no test coverage detected