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

Method _isMovingToSubmenu

src/cdk/menu/menu-aim.ts:201–219  ·  view source on GitHub ↗

Whether the user is heading towards the open submenu.

()

Source from the content-addressed store, hash-verified

199
200 /** Whether the user is heading towards the open submenu. */
201 private _isMovingToSubmenu() {
202 const submenuPoints = this._getSubmenuBounds();
203 if (!submenuPoints) {
204 return false;
205 }
206
207 let numMoving = 0;
208 const currPoint = this._points[this._points.length - 1];
209 // start from the second last point and calculate the slope between each point and the last
210 // point.
211 for (let i = this._points.length - 2; i >= 0; i--) {
212 const previous = this._points[i];
213 const slope = getSlope(currPoint, previous);
214 if (isWithinSubmenu(submenuPoints, slope, getYIntercept(currPoint, slope))) {
215 numMoving++;
216 }
217 }
218 return numMoving >= Math.floor(NUM_POINTS / 2);
219 }
220
221 /** Get the bounding DOMRect for the open submenu. */
222 private _getSubmenuBounds(): DOMRect | undefined {

Callers 1

toggleMethod · 0.95

Calls 4

_getSubmenuBoundsMethod · 0.95
isWithinSubmenuFunction · 0.85
getSlopeFunction · 0.70
getYInterceptFunction · 0.70

Tested by

no test coverage detected