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

Function setValueByClick

src/material/slider/slider.spec.ts:2122–2139  ·  view source on GitHub ↗

Clicks on the MatSlider at the coordinates corresponding to the given value.

(
  slider: MatSlider,
  input: MatSliderThumb,
  value: number,
  isRtl: boolean = false,
)

Source from the content-addressed store, hash-verified

2120
2121/** Clicks on the MatSlider at the coordinates corresponding to the given value. */
2122async function setValueByClick(
2123 slider: MatSlider,
2124 input: MatSliderThumb,
2125 value: number,
2126 isRtl: boolean = false,
2127) {
2128 const inputElement = input._elementRef.nativeElement;
2129 const val = isRtl ? slider.max - value : value;
2130 const {x, y} = getCoordsForValue(slider, value);
2131
2132 dispatchPointerEvent(inputElement, 'pointerdown', x, y);
2133 input.value = val;
2134 dispatchEvent(input._hostElement, new Event('input'));
2135 input.focus();
2136 dispatchPointerEvent(inputElement, 'pointerup', x, y);
2137 dispatchEvent(input._hostElement, new Event('change'));
2138 await new Promise(r => setTimeout(r, 0));
2139}
2140
2141/** Slides the MatSlider's thumb to the given value. */
2142async function slideToValue(slider: MatSlider, input: MatSliderThumb, value: number) {

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