MCPcopy Create free account
hub / github.com/angular/components / getCoordsForValue

Function getCoordsForValue

src/material/slider/slider.spec.ts:2158–2167  ·  view source on GitHub ↗

Returns the x and y coordinates for the given slider value.

(slider: MatSlider, value: number)

Source from the content-addressed store, hash-verified

2156
2157/** Returns the x and y coordinates for the given slider value. */
2158function getCoordsForValue(slider: MatSlider, value: number): Point {
2159 const {min, max} = slider;
2160 const percent = (value - min) / (max - min);
2161
2162 const {top, left, width, height} = slider._elementRef.nativeElement.getBoundingClientRect();
2163 const x = width * percent + left;
2164 const y = top + height / 2;
2165
2166 return {x, y};
2167}

Callers 2

setValueByClickFunction · 0.70
slideToValueFunction · 0.70

Calls 1

getBoundingClientRectMethod · 0.80

Tested by

no test coverage detected