* Called upon `onScroll`. * Selects the closest step, based on the user scroll position. * @param scrollPos the current scroll position * @private
(scrollPos: number)
| 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`. |
nothing calls this directly
no test coverage detected