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

Function setValueByClick

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

2086
2087/** Clicks on the MatSlider at the coordinates corresponding to the given value. */
2088async function setValueByClick(
2089 slider: MatSlider,
2090 input: MatSliderThumb,
2091 value: number,
2092 isRtl: boolean = false,
2093) {
2094 const inputElement = input._elementRef.nativeElement;
2095 const val = isRtl ? slider.max - value : value;
2096 const {x, y} = getCoordsForValue(slider, value);
2097
2098 dispatchPointerEvent(inputElement, 'pointerdown', x, y);
2099 input.value = val;
2100 dispatchEvent(input._hostElement, new Event('input'));
2101 input.focus();
2102 dispatchPointerEvent(inputElement, 'pointerup', x, y);
2103 dispatchEvent(input._hostElement, new Event('change'));
2104 await new Promise(r => setTimeout(r, 0));
2105}
2106
2107/** Slides the MatSlider's thumb to the given value. */
2108async 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