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

Function slideToValue

src/material/slider/slider.spec.ts:2108–2121  ·  view source on GitHub ↗

Slides the MatSlider's thumb to the given value.

(slider: MatSlider, input: MatSliderThumb, value: number)

Source from the content-addressed store, hash-verified

2106
2107/** Slides the MatSlider's thumb to the given value. */
2108async function slideToValue(slider: MatSlider, input: MatSliderThumb, value: number) {
2109 const sliderElement = slider._elementRef.nativeElement;
2110 const {x: startX, y: startY} = getCoordsForValue(slider, input.value);
2111 const {x: endX, y: endY} = getCoordsForValue(slider, value);
2112
2113 dispatchPointerEvent(sliderElement, 'pointerdown', startX, startY);
2114 input.focus();
2115 dispatchPointerEvent(sliderElement, 'pointermove', endX, endY);
2116 input._hostElement.value = `${value}`;
2117 dispatchEvent(input._hostElement, new Event('input'));
2118 dispatchPointerEvent(sliderElement, 'pointerup', endX, endY);
2119 dispatchEvent(input._hostElement, new Event('change'));
2120 await new Promise(r => setTimeout(r, 0));
2121}
2122
2123/** Returns the x and y coordinates for the given slider value. */
2124function getCoordsForValue(slider: MatSlider, value: number): Point {

Callers 1

slider.spec.tsFile · 0.70

Calls 4

dispatchPointerEventFunction · 0.85
getCoordsForValueFunction · 0.70
focusMethod · 0.65
dispatchEventFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…