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

Function slideToValue

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

2140
2141/** Slides the MatSlider's thumb to the given value. */
2142async function slideToValue(slider: MatSlider, input: MatSliderThumb, value: number) {
2143 const sliderElement = slider._elementRef.nativeElement;
2144 const {x: startX, y: startY} = getCoordsForValue(slider, input.value);
2145 const {x: endX, y: endY} = getCoordsForValue(slider, value);
2146
2147 dispatchPointerEvent(sliderElement, 'pointerdown', startX, startY);
2148 input.focus();
2149 dispatchPointerEvent(sliderElement, 'pointermove', endX, endY);
2150 input._hostElement.value = `${value}`;
2151 dispatchEvent(input._hostElement, new Event('input'));
2152 dispatchPointerEvent(sliderElement, 'pointerup', endX, endY);
2153 dispatchEvent(input._hostElement, new Event('change'));
2154 await new Promise(r => setTimeout(r, 0));
2155}
2156
2157/** Returns the x and y coordinates for the given slider value. */
2158function 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