Whether the user is heading towards the open submenu.
()
| 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 { |
no test coverage detected