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

Function hover

src/cdk/menu/menu.spec.ts:191–216  ·  view source on GitHub ↗

* Fakes mouse hover events from some source point to some target point. Along the way, emits * mouse move events and mouse enter events when the element under the mouse changes. * * It assumes that moves will occur left to right and down. * @param from the starting point

(from: Point, to: Point, inMenu: HTMLElement, duration: number)

Source from the content-addressed store, hash-verified

189 * @return the number of elements the mouse entered into.
190 */
191 async function hover(from: Point, to: Point, inMenu: HTMLElement, duration: number) {
192 const getNextPoint = getNextPointIterator(from, to);
193
194 let currentPoint: Point | null = from;
195 let currElement = getElementAt(currentPoint);
196
197 const timeout = duration / Math.abs(to.x - from.x);
198
199 let numEnters = 0;
200 while (currentPoint) {
201 mousemove(inMenu, currentPoint);
202 const nextElement = getElementAt(currentPoint);
203 if (nextElement !== currElement && nextElement instanceof HTMLButtonElement) {
204 numEnters++;
205 mouseout(currElement);
206 mouseenter(nextElement, currentPoint);
207 currElement = nextElement;
208 fixture.detectChanges();
209 }
210 currentPoint = getNextPoint();
211 if (timeout > 0) {
212 await wait(timeout);
213 }
214 }
215 return numEnters;
216 }
217
218 /**
219 * Get a function which determines the next point to generate when moving from one point to

Callers 1

menu.spec.tsFile · 0.85

Calls 6

getNextPointIteratorFunction · 0.85
getElementAtFunction · 0.85
mousemoveFunction · 0.85
mouseenterFunction · 0.85
mouseoutFunction · 0.70
waitFunction · 0.70

Tested by

no test coverage detected