in src/visualComponent/svgComponent.ts [382:413]
private getIndexByPosition(position: number): number {
if (!this.positions) {
return NaN;
}
const length: number = this.positions.length;
for (let index: number = 0; index < length; index++) {
const condition: boolean =
(index === 0
&& position <= this.positions[index])
|| (index === 0
&& this.positions[index + 1] !== undefined
&& position <= this.positions[index] + (this.positions[index + 1] - this.positions[index]) / 2)
|| (index === length - 1
&& position >= this.positions[index])
|| (index === length - 1
&& this.positions[index - 1] !== undefined
&& position >= this.positions[index] - (this.positions[index] - this.positions[index - 1]) / 2)
|| (this.positions[index - 1] !== undefined
&& this.positions[index] !== undefined
&& this.positions[index + 1] !== undefined
&& (position >= (this.positions[index] - Math.abs(this.positions[index] - this.positions[index - 1]) / 2))
&& (position <= (this.positions[index] + Math.abs(this.positions[index + 1] - this.positions[index]) / 2)));
if (condition) {
return index;
}
}
return NaN;
}