* Returns the closest step index by given scroll position. * @private * @param scrollPos the scroll position
(scrollPos: number)
| 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. |
no test coverage detected