bm-core-ui 2.12.0-beta.14 → 2.12.0-beta.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1346,6 +1346,13 @@ input:not(:checked) + .BMWindowSwitchGutter > .BMWindowSwitchKnob, .BMWindowSwit
1346
1346
  z-index: 9999999;
1347
1347
  }
1348
1348
 
1349
+ /* A class that is temporarily added to the menu container to allow the user
1350
+ to move over menu items without triggering them while moving torwards the submenu;
1351
+ additionally, this causes the `mouseenter` event to trigger when this class is removed */
1352
+ .BMMenuContainer.BMMenuContainerSubmenuActive > * {
1353
+ pointer-events: none !important;
1354
+ }
1355
+
1349
1356
  .BMMenuContainerFullScreen {
1350
1357
  background-color: rgba(0, 0, 0, .33);
1351
1358
  }
@@ -1458,9 +1458,6 @@ BMMenu.prototype = {
1458
1458
  let topPoint;
1459
1459
  let bottomPoint;
1460
1460
 
1461
- // Determines whether the slope needs to be between the min and max slopes or outside their range
1462
- let flipSlopes = false;
1463
-
1464
1461
  const eventTarget = this._containerNode;
1465
1462
  // Immediately block interactions with menu elements
1466
1463
  this._delaysEvents = YES;
@@ -1478,7 +1475,7 @@ BMMenu.prototype = {
1478
1475
  this._delaysEvents = NO;
1479
1476
 
1480
1477
  // Remove the mousemove event handler
1481
- eventTarget.removeEventListener(mouseMoveEvent, handler, {capture: YES});
1478
+ window.removeEventListener(mouseMoveEvent, handler, {capture: YES});
1482
1479
 
1483
1480
  // Allow pointer interaction with the menu nodes
1484
1481
  eventTarget.classList.remove('BMMenuContainerSubmenuActive');
@@ -1511,14 +1508,6 @@ BMMenu.prototype = {
1511
1508
  BMPointMake(submenuFrame.origin.x, submenuFrame.bottom) :
1512
1509
  BMPointMake(submenuFrame.right, submenuFrame.bottom);
1513
1510
 
1514
- if (submenuFrame.origin.x < lastPosition.x) {
1515
- // When the menu appears to the left, the min and max slopes need to be
1516
- // flipped, because the "interior" of the slopes is counted clockwise
1517
- // from the bottom slope to the top one, but on the left side
1518
- // the interior needs to be counted counter-clockwise
1519
- flipSlopes = true;
1520
- }
1521
-
1522
1511
  return;
1523
1512
  }
1524
1513
 
@@ -1563,20 +1552,39 @@ BMMenu.prototype = {
1563
1552
  const topSlope = currentPosition.slopeAngleToPoint(topPoint);
1564
1553
  const bottomSlope = currentPosition.slopeAngleToPoint(bottomPoint);
1565
1554
 
1555
+ // Normalizes the specified angle so that it's within the [0, 2Pi] range
1556
+ function normalizeAngle(angle) {
1557
+ // Coerce angle into [-2Pi, 2Pi]
1558
+ angle %= 2 * Math.PI;
1559
+
1560
+ // Coerce the result into a positive angle
1561
+ return angle < 0 ? angle + 2 * Math.PI : angle;
1562
+ }
1563
+
1566
1564
  // Get the slope angle for the current movement, which indicates the direction
1567
1565
  // in which the pointer moves
1568
- const currentSlope = lastPosition.slopeAngleToPoint(currentPosition);
1566
+ const currentSlope = normalizeAngle(lastPosition.slopeAngleToPoint(currentPosition));
1569
1567
 
1570
- const minSlope = Math.min(topSlope, bottomSlope);
1571
- const maxSlope = Math.max(topSlope, bottomSlope);
1568
+ const minSlope = normalizeAngle(bottomSlope - topSlope);
1569
+ const maxSlope = normalizeAngle(topSlope - bottomSlope);
1572
1570
 
1571
+ // Determine which is the starting and ending slopes and normalize them
1572
+ let startSlope, endSlope;
1573
+ if (minSlope <= maxSlope) {
1574
+ startSlope = normalizeAngle(topSlope);
1575
+ endSlope = normalizeAngle(bottomSlope);
1576
+ }
1577
+ else {
1578
+ startSlope = normalizeAngle(bottomSlope);
1579
+ endSlope = normalizeAngle(topSlope);
1580
+ }
1581
+
1573
1582
  // If the mouse moves away from the submenu, resume events
1574
1583
  // The pointer is considered to be moving towards the menu if the slope angle
1575
1584
  // of the line formed between the current and previous mouse positions
1576
1585
  // is between these two slope angles
1577
- let isOutsideSlopeRange = flipSlopes ?
1578
- currentSlope > minSlope && currentSlope < maxSlope :
1579
- currentSlope < minSlope || currentSlope > maxSlope;
1586
+ // This is done by rotating the end and current slope by the start slope and checking which is larger
1587
+ const isOutsideSlopeRange = normalizeAngle(currentSlope - startSlope) >= normalizeAngle(endSlope - startSlope);
1580
1588
 
1581
1589
  if (isOutsideSlopeRange) {
1582
1590
  resumeEvents();
@@ -1587,7 +1595,7 @@ BMMenu.prototype = {
1587
1595
  lastPosition = currentPosition;
1588
1596
  };
1589
1597
 
1590
- eventTarget.addEventListener(mouseMoveEvent, handler, {capture: YES});
1598
+ window.addEventListener(mouseMoveEvent, handler, {capture: YES});
1591
1599
  },
1592
1600
 
1593
1601
  /**