MCPcopy
hub / github.com/angular/components / getCoordsForValue

Function getCoordsForValue

src/material/slider/slider.spec.ts:2124–2133  ·  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

2122
2123/** Returns the x and y coordinates for the given slider value. */
2124function getCoordsForValue(slider: MatSlider, value: number): Point {
2125 const {min, max} = slider;
2126 const percent = (value - min) / (max - min);
2127
2128 const {top, left, width, height} = slider._elementRef.nativeElement.getBoundingClientRect();
2129 const x = width * percent + left;
2130 const y = top + height / 2;
2131
2132 return {x, y};
2133}

Callers 2

setValueByClickFunction · 0.70
slideToValueFunction · 0.70

Calls 1

getBoundingClientRectMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…