bm-core-ui 2.12.0-beta.5 → 2.12.0-beta.7
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.
- package/build/@types/index.d.ts +42 -5
- package/build/BMCoreUI.css +80 -42
- package/build/BMView/BMDragSession.js +35 -5
- package/build/BMView/BMDragSessionPreview.js +24 -7
- package/build/BMView/BMMenu.js +47 -19
- package/lib/@types/BMCoreUI.min.d.ts +42 -5
- package/lib/BMCoreUI.min.js +1 -1
- package/package.json +1 -1
package/build/@types/index.d.ts
CHANGED
|
@@ -5846,6 +5846,14 @@ export class BMDragSession implements EventHandlerObject {
|
|
|
5846
5846
|
private _beginDrag(): void;
|
|
5847
5847
|
|
|
5848
5848
|
|
|
5849
|
+
/**
|
|
5850
|
+
* Invoked when a key is pressed while this drag session is in progress.
|
|
5851
|
+
* @param event The event.
|
|
5852
|
+
*
|
|
5853
|
+
*/
|
|
5854
|
+
private _keyPressedWithEvent(event: KeyboardEvent): void;
|
|
5855
|
+
|
|
5856
|
+
|
|
5849
5857
|
/**
|
|
5850
5858
|
* Invoked whenever the pointer moves while this drag session is in progress.
|
|
5851
5859
|
* @param event The event.
|
|
@@ -5856,11 +5864,11 @@ export class BMDragSession implements EventHandlerObject {
|
|
|
5856
5864
|
|
|
5857
5865
|
/**
|
|
5858
5866
|
* Invoked when the pointer is released or cancelled while this drag session is in progress.
|
|
5859
|
-
* @param event
|
|
5860
|
-
* @return
|
|
5867
|
+
* @param event The event.
|
|
5868
|
+
* @return A promise that resolves when all associated animations finish.
|
|
5861
5869
|
*
|
|
5862
5870
|
*/
|
|
5863
|
-
private _dragDidFinishWithEvent(event: MouseEvent | TouchEvent): Promise<void>;
|
|
5871
|
+
private _dragDidFinishWithEvent(event: MouseEvent | TouchEvent | KeyboardEvent): Promise<void>;
|
|
5864
5872
|
|
|
5865
5873
|
|
|
5866
5874
|
/**
|
|
@@ -7036,6 +7044,13 @@ export class _BMDragIndicator {
|
|
|
7036
7044
|
*/
|
|
7037
7045
|
export class _BMDragPreviewSet {
|
|
7038
7046
|
|
|
7047
|
+
/**
|
|
7048
|
+
* The offset between the drag pointer and the center the from of the view from which the drag session
|
|
7049
|
+
* started, expressed in percentages relative to the view's frame.
|
|
7050
|
+
*
|
|
7051
|
+
*/
|
|
7052
|
+
private _offsetPercent: BMPoint;
|
|
7053
|
+
|
|
7039
7054
|
/**
|
|
7040
7055
|
* The offset between the drag pointer and the center of the frames of the preview elements.
|
|
7041
7056
|
*
|
|
@@ -7082,7 +7097,8 @@ export class _BMDragPreviewSet {
|
|
|
7082
7097
|
* Initializes this drag preview set with the specified item previews and offset position.
|
|
7083
7098
|
* @param previews The previews for items in the drag session.
|
|
7084
7099
|
* @param pointerOffset The offset between the drag pointer and the
|
|
7085
|
-
* center of the frames of the
|
|
7100
|
+
* center of the frames of the view from which the
|
|
7101
|
+
* drag session started.
|
|
7086
7102
|
* @return This preview set.
|
|
7087
7103
|
*
|
|
7088
7104
|
*/
|
|
@@ -9975,6 +9991,13 @@ export class BMMenu {
|
|
|
9975
9991
|
*/
|
|
9976
9992
|
_delaysClosing: boolean;
|
|
9977
9993
|
|
|
9994
|
+
/**
|
|
9995
|
+
* When set to `YES`, the menu item actions and item selection delegate callbacks will be invoked
|
|
9996
|
+
* with a slight delay to allow time for the menu closing animation to play.
|
|
9997
|
+
*
|
|
9998
|
+
*/
|
|
9999
|
+
delaysActions: boolean;
|
|
10000
|
+
|
|
9978
10001
|
/**
|
|
9979
10002
|
* Initializes this menu with the specified items.
|
|
9980
10003
|
* The menu will be hidden by default; the method showAtPoint(_) should be used to make the menu visible.
|
|
@@ -10011,6 +10034,20 @@ export class BMMenu {
|
|
|
10011
10034
|
private _renderMenuItems(): void;
|
|
10012
10035
|
|
|
10013
10036
|
|
|
10037
|
+
/**
|
|
10038
|
+
* Temporarily set to the menu item that was selected until its action is performed.
|
|
10039
|
+
*
|
|
10040
|
+
*/
|
|
10041
|
+
private _selectedMenuItem?: BMMenuItem | null | undefined;
|
|
10042
|
+
|
|
10043
|
+
/**
|
|
10044
|
+
* Performs the action for the specified menu item and invokes the delegate selection callback for it.
|
|
10045
|
+
* @param item The menu item whose action should be performed.
|
|
10046
|
+
*
|
|
10047
|
+
*/
|
|
10048
|
+
private _performActionForMenuItem(item: BMMenuItem): void;
|
|
10049
|
+
|
|
10050
|
+
|
|
10014
10051
|
/**
|
|
10015
10052
|
* The kind of menu currently displayed.
|
|
10016
10053
|
*
|
|
@@ -10133,7 +10170,7 @@ export class BMMenu {
|
|
|
10133
10170
|
* @param forKeyboardShortcut The keyboard shortcut that was triggered.
|
|
10134
10171
|
*
|
|
10135
10172
|
*/
|
|
10136
|
-
|
|
10173
|
+
protected _selectMenuItemWithEvent(event: KeyboardEvent, {forKeyboardShortcut}: {forKeyboardShortcut: BMKeyboardShortcut}): void;
|
|
10137
10174
|
|
|
10138
10175
|
|
|
10139
10176
|
/**
|
package/build/BMCoreUI.css
CHANGED
|
@@ -1524,21 +1524,8 @@ input:not(:checked) + .BMWindowSwitchGutter > .BMWindowSwitchKnob, .BMWindowSwit
|
|
|
1524
1524
|
}
|
|
1525
1525
|
|
|
1526
1526
|
.BMMenuTouch > .BMMenuItemsContainer > .BMMenuItem {
|
|
1527
|
-
height:
|
|
1528
|
-
line-height:
|
|
1529
|
-
border-top: 1px solid rgba(0, 0, 0, .1);
|
|
1530
|
-
}
|
|
1531
|
-
|
|
1532
|
-
.BMMenuTouch > .BMMenuItemsContainer > .BMMenuItem:first-child {
|
|
1533
|
-
border-top-width: 0px;
|
|
1534
|
-
}
|
|
1535
|
-
|
|
1536
|
-
.BMMenuTouch > .BMMenuItemsContainer > .BMMenuItem.BMMenuItemHighlighted + .BMMenuItem {
|
|
1537
|
-
border-top-color: rgba(0, 0, 0, .2);
|
|
1538
|
-
}
|
|
1539
|
-
|
|
1540
|
-
.BMMenuTouch > .BMMenuItemsContainer > .BMMenuItem.BMMenuItemHighlighted + .BMMenuDivider {
|
|
1541
|
-
box-shadow: 0px 1px 0px 0px rgba(0, 0, 0, .1) inset;
|
|
1527
|
+
height: 38px;
|
|
1528
|
+
line-height: 38px;
|
|
1542
1529
|
}
|
|
1543
1530
|
|
|
1544
1531
|
.BMMenuIcon {
|
|
@@ -1596,48 +1583,104 @@ input:not(:checked) + .BMWindowSwitchGutter > .BMWindowSwitchKnob, .BMWindowSwit
|
|
|
1596
1583
|
|
|
1597
1584
|
@keyframes BMMenuItemActiveAnimation {
|
|
1598
1585
|
from {
|
|
1599
|
-
background: transparent;
|
|
1600
1586
|
color: rgba(0, 0, 0, .8);
|
|
1601
1587
|
}
|
|
1602
1588
|
|
|
1603
1589
|
49% {
|
|
1604
|
-
background: transparent;
|
|
1605
1590
|
color: rgba(0, 0, 0, .8);
|
|
1606
1591
|
}
|
|
1607
1592
|
|
|
1608
1593
|
50% {
|
|
1609
|
-
background: rgb(0, 128, 255);
|
|
1610
1594
|
color: white;
|
|
1611
1595
|
}
|
|
1612
1596
|
|
|
1613
1597
|
to {
|
|
1614
|
-
background: rgb(0, 128, 255);
|
|
1615
1598
|
color: white;
|
|
1616
1599
|
}
|
|
1617
1600
|
}
|
|
1618
1601
|
|
|
1619
|
-
|
|
1620
|
-
|
|
1602
|
+
@keyframes BMMenuItemActiveAnimationBackground {
|
|
1603
|
+
from {
|
|
1604
|
+
background: transparent;
|
|
1605
|
+
}
|
|
1606
|
+
|
|
1607
|
+
49% {
|
|
1608
|
+
background: transparent;
|
|
1609
|
+
}
|
|
1610
|
+
|
|
1611
|
+
50% {
|
|
1612
|
+
background: rgb(0, 128, 255);
|
|
1613
|
+
}
|
|
1614
|
+
|
|
1615
|
+
to {
|
|
1616
|
+
background: rgb(0, 128, 255);
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1619
|
+
|
|
1620
|
+
.BMLayoutEditorConstraintPopupOption::before,
|
|
1621
|
+
.BMMenuTouch > .BMMenuItemsContainer > .BMMenuItem::before,
|
|
1622
|
+
.BMMenuItem::before {
|
|
1623
|
+
content: '';
|
|
1624
|
+
|
|
1625
|
+
position: absolute;
|
|
1626
|
+
|
|
1627
|
+
top: 0;
|
|
1628
|
+
bottom: 0;
|
|
1629
|
+
|
|
1630
|
+
left: 4px;
|
|
1631
|
+
right: 4px;
|
|
1632
|
+
|
|
1633
|
+
border-radius: 5px;
|
|
1634
|
+
|
|
1635
|
+
z-index: -1;
|
|
1636
|
+
}
|
|
1637
|
+
|
|
1638
|
+
.BMLayoutEditorConstraintPopupOption:hover,
|
|
1639
|
+
.BMMenuItem.BMMenuItemHighlighted {
|
|
1621
1640
|
color: white;
|
|
1622
1641
|
}
|
|
1623
1642
|
|
|
1643
|
+
.BMMenuTouch > .BMMenuItemsContainer > .BMMenuItem.BMMenuItemHighlighted,
|
|
1644
|
+
.BMMenuTouch > .BMMenuItemsContainer > .BMMenuItem:not(.BMMenuItemDisabled):active {
|
|
1645
|
+
color: rgba(0, 0, 0, .8);
|
|
1646
|
+
}
|
|
1647
|
+
|
|
1648
|
+
.BMLayoutEditorConstraintPopupOption:hover::before,
|
|
1649
|
+
.BMMenuItem.BMMenuItemHighlighted::before {
|
|
1650
|
+
background: rgb(0, 128, 255);
|
|
1651
|
+
}
|
|
1652
|
+
|
|
1624
1653
|
.BMMenuSourceNodeShadow.BMMenuItem.BMMenuItemHighlighted {
|
|
1625
1654
|
background: white;
|
|
1626
1655
|
color: rgba(0, 0, 0, .8);
|
|
1627
1656
|
}
|
|
1628
1657
|
|
|
1629
|
-
.BMLayoutEditorConstraintPopupOption:active,
|
|
1658
|
+
.BMLayoutEditorConstraintPopupOption:active,
|
|
1659
|
+
.BMMenuTouch > .BMMenuItemsContainer > .BMMenuItem:not(.BMMenuItemDisabled):hover {
|
|
1630
1660
|
background: transparent;
|
|
1631
1661
|
color: rgba(0, 0, 0, .8);
|
|
1632
1662
|
}
|
|
1633
1663
|
|
|
1664
|
+
.BMLayoutEditorConstraintPopupOption:active::before,
|
|
1665
|
+
.BMMenuTouch > .BMMenuItemsContainer > .BMMenuItem.BMMenuItemHighlighted::before,
|
|
1666
|
+
.BMMenuTouch > .BMMenuItemsContainer > .BMMenuItem:not(.BMMenuItemDisabled):hover::before,
|
|
1667
|
+
.BMMenuTouch > .BMMenuItemsContainer > .BMMenuItem:not(.BMMenuItemDisabled):active::before {
|
|
1668
|
+
background: transparent;
|
|
1669
|
+
}
|
|
1670
|
+
|
|
1671
|
+
|
|
1634
1672
|
.BMMenuItem.BMMenuItemActive {
|
|
1635
1673
|
animation: .15s linear BMMenuItemActiveAnimation;
|
|
1636
1674
|
animation-fill-mode: both;
|
|
1637
1675
|
}
|
|
1638
1676
|
|
|
1639
|
-
.
|
|
1640
|
-
|
|
1677
|
+
.BMMenuItem.BMMenuItemActive::before {
|
|
1678
|
+
animation: .15s linear BMMenuItemActiveAnimationBackground;
|
|
1679
|
+
animation-fill-mode: both;
|
|
1680
|
+
}
|
|
1681
|
+
|
|
1682
|
+
.BMMenuTouch > .BMMenuItemsContainer > .BMMenuItem.BMMenuItemActive::before,
|
|
1683
|
+
.BMMenuTouch > .BMMenuItemsContainer > .BMMenuItem.BMMenuItemHighlighted::before {
|
|
1641
1684
|
animation: none;
|
|
1642
1685
|
background: transparent;
|
|
1643
1686
|
color: rgba(0, 0, 0, .8);
|
|
@@ -1646,7 +1689,8 @@ input:not(:checked) + .BMWindowSwitchGutter > .BMWindowSwitchKnob, .BMWindowSwit
|
|
|
1646
1689
|
-webkit-backdrop-filter: brightness(80%);
|
|
1647
1690
|
}
|
|
1648
1691
|
|
|
1649
|
-
.BMLayoutEditorConstraintPopupOptionHighlighted,
|
|
1692
|
+
.BMLayoutEditorConstraintPopupOptionHighlighted::before,
|
|
1693
|
+
.BMMenuItemHighlighted::before {
|
|
1650
1694
|
background: rgba(0, 128, 255, .5);
|
|
1651
1695
|
}
|
|
1652
1696
|
|
|
@@ -1659,46 +1703,46 @@ input:not(:checked) + .BMWindowSwitchGutter > .BMWindowSwitchKnob, .BMWindowSwit
|
|
|
1659
1703
|
color: rgba(255, 255, 255, .45);
|
|
1660
1704
|
}
|
|
1661
1705
|
|
|
1662
|
-
.BMLayoutEditorConstraintPopupOption:active,
|
|
1706
|
+
.BMLayoutEditorConstraintPopupOption:active,
|
|
1707
|
+
.BMMenuTouch > .BMMenuItemsContainer > .BMMenuItem:not(.BMMenuItemDisabled):hover,
|
|
1708
|
+
.BMMenuTouch > .BMMenuItemsContainer > .BMMenuItem:not(.BMMenuItemDisabled):active {
|
|
1663
1709
|
background: transparent;
|
|
1664
1710
|
color: white;
|
|
1665
1711
|
}
|
|
1666
1712
|
|
|
1667
|
-
.BMMenuTouch > .BMMenuItemsContainer > .BMMenuItem {
|
|
1668
|
-
border-bottom-color: rgba(255, 255, 255, .1);
|
|
1669
|
-
}
|
|
1670
|
-
|
|
1671
1713
|
.BMMenuTouch > .BMMenuItemsContainer > .BMMenuItem.BMMenuItemActive,
|
|
1672
1714
|
.BMMenuTouch > .BMMenuItemsContainer > .BMMenuItem.BMMenuItemHighlighted {
|
|
1673
1715
|
color: rgba(255, 255, 255, 1);
|
|
1674
|
-
|
|
1716
|
+
}
|
|
1717
|
+
|
|
1718
|
+
.BMMenuTouch > .BMMenuItemsContainer > .BMMenuItem.BMMenuItemActive::before,
|
|
1719
|
+
.BMMenuTouch > .BMMenuItemsContainer > .BMMenuItem.BMMenuItemHighlighted::before {
|
|
1675
1720
|
backdrop-filter: brightness(110%);
|
|
1676
1721
|
-webkit-backdrop-filter: brightness(110%);
|
|
1677
1722
|
}
|
|
1678
1723
|
|
|
1679
1724
|
.BMMenuSourceNodeShadow.BMMenuItem.BMMenuItemHighlighted {
|
|
1680
|
-
background: rgba(33, 33, 33, 1);
|
|
1681
1725
|
color: rgba(255, 255, 255, .9);
|
|
1682
1726
|
}
|
|
1683
1727
|
|
|
1728
|
+
.BMMenuSourceNodeShadow.BMMenuItem.BMMenuItemHighlighted::before {
|
|
1729
|
+
background: rgba(33, 33, 33, 1);
|
|
1730
|
+
}
|
|
1731
|
+
|
|
1684
1732
|
@keyframes BMMenuItemActiveAnimation {
|
|
1685
1733
|
from {
|
|
1686
|
-
background: transparent;
|
|
1687
1734
|
color: rgba(255, 255, 255, .9);
|
|
1688
1735
|
}
|
|
1689
1736
|
|
|
1690
1737
|
49% {
|
|
1691
|
-
background: transparent;
|
|
1692
1738
|
color: rgba(255, 255, 255, .9);
|
|
1693
1739
|
}
|
|
1694
1740
|
|
|
1695
1741
|
50% {
|
|
1696
|
-
background: rgb(0, 128, 255);
|
|
1697
1742
|
color: white;
|
|
1698
1743
|
}
|
|
1699
1744
|
|
|
1700
1745
|
to {
|
|
1701
|
-
background: rgb(0, 128, 255);
|
|
1702
1746
|
color: white;
|
|
1703
1747
|
}
|
|
1704
1748
|
}
|
|
@@ -1834,12 +1878,6 @@ input:not(:checked) + .BMWindowSwitchGutter > .BMWindowSwitchKnob, .BMWindowSwit
|
|
|
1834
1878
|
flex-shrink: 0;
|
|
1835
1879
|
}
|
|
1836
1880
|
|
|
1837
|
-
.BMMenuTouch > .BMMenuItemsContainer > .BMMenuDivider {
|
|
1838
|
-
margin: 0;
|
|
1839
|
-
height: 3px;
|
|
1840
|
-
background: rgba(0, 0, 0, .1);
|
|
1841
|
-
}
|
|
1842
|
-
|
|
1843
1881
|
.BMLayoutEditorDetailsDividerCell {
|
|
1844
1882
|
background: rgba(0, 0, 0, .05);
|
|
1845
1883
|
}
|
|
@@ -435,7 +435,10 @@ BMDragSession.prototype = {
|
|
|
435
435
|
if (firstItemPreview._sourceNode) {
|
|
436
436
|
const sourceNodeFrame = BMRectMakeWithNodeFrame(firstItemPreview._sourceNode);
|
|
437
437
|
const center = sourceNodeFrame.center;
|
|
438
|
-
pointerOffset = BMPointMake(
|
|
438
|
+
pointerOffset = BMPointMake(
|
|
439
|
+
(center.x - this._position.x) / sourceNodeFrame.size.width,
|
|
440
|
+
(center.y - this._position.y) / sourceNodeFrame.size.height,
|
|
441
|
+
);
|
|
439
442
|
}
|
|
440
443
|
|
|
441
444
|
// Obtain the drag previews for the remaining items
|
|
@@ -468,10 +471,16 @@ BMDragSession.prototype = {
|
|
|
468
471
|
if (this._touchIdentifier !== undefined) {
|
|
469
472
|
window.addEventListener('touchcancel', this, {capture: YES, passive: NO});
|
|
470
473
|
}
|
|
474
|
+
|
|
475
|
+
// Register a key press event that will cancel the drag when escape is pressed
|
|
476
|
+
window.addEventListener('keydown', this, {capture: YES, passive: NO});
|
|
471
477
|
},
|
|
472
478
|
|
|
473
|
-
handleEvent(/** @type {MouseEvent | TouchEvent} */ event) {
|
|
474
|
-
if (event.type == '
|
|
479
|
+
handleEvent(/** @type {MouseEvent | TouchEvent | KeyboardEvent} */ event) {
|
|
480
|
+
if (event.type == 'keydown') {
|
|
481
|
+
this._keyPressedWithEvent(event);
|
|
482
|
+
}
|
|
483
|
+
else if (event.type == 'mousemove' || event.type == 'touchmove') {
|
|
475
484
|
this._dragDidMoveWithEvent(event);
|
|
476
485
|
}
|
|
477
486
|
else {
|
|
@@ -479,6 +488,26 @@ BMDragSession.prototype = {
|
|
|
479
488
|
}
|
|
480
489
|
},
|
|
481
490
|
|
|
491
|
+
/**
|
|
492
|
+
* Invoked when a key is pressed while this drag session is in progress.
|
|
493
|
+
* @param event <KeyboardEvent> The event.
|
|
494
|
+
*/
|
|
495
|
+
_keyPressedWithEvent(event) {
|
|
496
|
+
// Cancel the drag session when pressing escape or command + .
|
|
497
|
+
if (event.code != 'Escape' && (event.code != 'Period' || !event.metaKey)) {
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
// Clear any drop target, set the drop action to ignore and immediately finish the session
|
|
502
|
+
event.stopPropagation();
|
|
503
|
+
event.preventDefault();
|
|
504
|
+
this._setDropTarget(undefined);
|
|
505
|
+
this._sourceDropAction = BMDragSessionAction.actionWithKind(BMDragSessionActionKind.Ignore);
|
|
506
|
+
this._updateDropAction();
|
|
507
|
+
|
|
508
|
+
this._dragDidFinishWithEvent();
|
|
509
|
+
},
|
|
510
|
+
|
|
482
511
|
/**
|
|
483
512
|
* Invoked whenever the pointer moves while this drag session is in progress.
|
|
484
513
|
* @param event <MouseEvent or TouchEvent> The event.
|
|
@@ -551,8 +580,8 @@ BMDragSession.prototype = {
|
|
|
551
580
|
|
|
552
581
|
/**
|
|
553
582
|
* Invoked when the pointer is released or cancelled while this drag session is in progress.
|
|
554
|
-
* @param event <MouseEvent or TouchEvent>
|
|
555
|
-
* @return <Promise<void>>
|
|
583
|
+
* @param event <MouseEvent or TouchEvent or KeyboardEvent> The event.
|
|
584
|
+
* @return <Promise<void>> A promise that resolves when all associated animations finish.
|
|
556
585
|
*/
|
|
557
586
|
async _dragDidFinishWithEvent(event) {
|
|
558
587
|
event.preventDefault();
|
|
@@ -575,6 +604,7 @@ BMDragSession.prototype = {
|
|
|
575
604
|
if (this._touchIdentifier !== undefined) {
|
|
576
605
|
window.removeEventListener('touchcancel', this, {capture: YES, passive: NO});
|
|
577
606
|
}
|
|
607
|
+
window.removeEventListener('keydown', this, {capture: YES, passive: NO});
|
|
578
608
|
this._releaseDropTargetHandlers();
|
|
579
609
|
|
|
580
610
|
// If there is a drop target and its action is not ignore, instruct the delegate to perform the action
|
|
@@ -1199,6 +1199,12 @@ export function _BMDragPreviewSet() {} // <constructor>
|
|
|
1199
1199
|
|
|
1200
1200
|
_BMDragPreviewSet.prototype = {
|
|
1201
1201
|
|
|
1202
|
+
/**
|
|
1203
|
+
* The offset between the drag pointer and the center the from of the view from which the drag session
|
|
1204
|
+
* started, expressed in percentages relative to the view's frame.
|
|
1205
|
+
*/
|
|
1206
|
+
_offsetPercent: BMPointMake(), // <BMPoint>
|
|
1207
|
+
|
|
1202
1208
|
/**
|
|
1203
1209
|
* The offset between the drag pointer and the center of the frames of the preview elements.
|
|
1204
1210
|
*/
|
|
@@ -1239,7 +1245,8 @@ _BMDragPreviewSet.prototype = {
|
|
|
1239
1245
|
* @param previews <[BMDragPreview]> The previews for items in the drag session.
|
|
1240
1246
|
* {
|
|
1241
1247
|
* @param pointerOffset <BMPoint> The offset between the drag pointer and the
|
|
1242
|
-
* center of the frames of the
|
|
1248
|
+
* center of the frames of the view from which the
|
|
1249
|
+
* drag session started.
|
|
1243
1250
|
* }
|
|
1244
1251
|
* @return <_BMDragPreviewSet> This preview set.
|
|
1245
1252
|
*/
|
|
@@ -1254,7 +1261,7 @@ _BMDragPreviewSet.prototype = {
|
|
|
1254
1261
|
this._baseDragPreviews.set(preview._dragItem, preview);
|
|
1255
1262
|
}
|
|
1256
1263
|
|
|
1257
|
-
this.
|
|
1264
|
+
this._offsetPercent = pointerOffset.copy();
|
|
1258
1265
|
|
|
1259
1266
|
this._dragIndicator = new _BMDragIndicator().init();
|
|
1260
1267
|
|
|
@@ -1365,6 +1372,21 @@ _BMDragPreviewSet.prototype = {
|
|
|
1365
1372
|
* @param position <BMPoint> The position of the drag session.
|
|
1366
1373
|
*/
|
|
1367
1374
|
beginLiftAtPosition(position) {
|
|
1375
|
+
const firstPreview = this._dragPreviews.entries().next().value?.[1];
|
|
1376
|
+
const measureIterator = firstPreview?._attachAtPosition(BMPointMake());
|
|
1377
|
+
let measureIteratorResult = measureIterator.next();
|
|
1378
|
+
while (!measureIteratorResult.done) {
|
|
1379
|
+
measureIteratorResult = measureIterator.next();
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
this._offset = BMPointMake(
|
|
1383
|
+
this._offsetPercent.x * (firstPreview?._frame.size.width ?? 0),
|
|
1384
|
+
this._offsetPercent.y * (firstPreview?._frame.size.height ?? 0),
|
|
1385
|
+
);
|
|
1386
|
+
|
|
1387
|
+
firstPreview._detach();
|
|
1388
|
+
firstPreview._measured = NO;
|
|
1389
|
+
|
|
1368
1390
|
this._position = position.copy();
|
|
1369
1391
|
const previewPosition = position.copy();
|
|
1370
1392
|
previewPosition.x += this._offset.x;
|
|
@@ -1373,7 +1395,6 @@ _BMDragPreviewSet.prototype = {
|
|
|
1373
1395
|
// Attach and measure the previews
|
|
1374
1396
|
let attachIterators = [];
|
|
1375
1397
|
let previousPreview;
|
|
1376
|
-
let firstPreview;
|
|
1377
1398
|
for (const [item, preview] of this._dragPreviews.entries()) {
|
|
1378
1399
|
|
|
1379
1400
|
// For each preview other than the first, apply a random rotation between 15 and -15 degrees
|
|
@@ -1381,10 +1402,6 @@ _BMDragPreviewSet.prototype = {
|
|
|
1381
1402
|
preview._transform.rotateZ = Math.random() * _BMDragPreviewMaxRotation * 2 - _BMDragPreviewMaxRotation;
|
|
1382
1403
|
}
|
|
1383
1404
|
|
|
1384
|
-
if (!firstPreview) {
|
|
1385
|
-
firstPreview = preview;
|
|
1386
|
-
}
|
|
1387
|
-
|
|
1388
1405
|
const attachIterator = preview._attachAtPosition(previewPosition, {before: previousPreview?._previewNode});
|
|
1389
1406
|
attachIterators.push(attachIterator);
|
|
1390
1407
|
attachIterator.next();
|
package/build/BMView/BMMenu.js
CHANGED
|
@@ -460,6 +460,12 @@ BMMenu.prototype = {
|
|
|
460
460
|
this.__delaysClosing = delays;
|
|
461
461
|
},
|
|
462
462
|
|
|
463
|
+
/**
|
|
464
|
+
* When set to `YES`, the menu item actions and item selection delegate callbacks will be invoked
|
|
465
|
+
* with a slight delay to allow time for the menu closing animation to play.
|
|
466
|
+
*/
|
|
467
|
+
delaysActions: NO, // <Boolean>
|
|
468
|
+
|
|
463
469
|
/**
|
|
464
470
|
* Initializes this menu with the specified items.
|
|
465
471
|
* The menu will be hidden by default; the method showAtPoint(_) should be used to make the menu visible.
|
|
@@ -701,20 +707,13 @@ BMMenu.prototype = {
|
|
|
701
707
|
// animation to play out
|
|
702
708
|
this._delaysClosing = YES;
|
|
703
709
|
|
|
704
|
-
|
|
705
|
-
// Invoke the menu's action if configured
|
|
706
|
-
item.action(item);
|
|
707
|
-
}
|
|
710
|
+
this._selectedMenuItem = item;
|
|
708
711
|
|
|
709
712
|
itemNode.classList.add('BMMenuItemActive');
|
|
710
|
-
|
|
711
|
-
if (this.delegate && this.delegate.menuDidSelectItem) {
|
|
712
|
-
this.delegate.menuDidSelectItem(this, item);
|
|
713
|
-
}
|
|
714
713
|
});
|
|
715
714
|
|
|
716
715
|
// When moving the mouse over an item, set the highlight index to it,
|
|
717
|
-
// allowing further keyboard navigation to
|
|
716
|
+
// allowing further keyboard navigation to continue from this item
|
|
718
717
|
itemNode.addEventListener('mouseover', event => {
|
|
719
718
|
// Disabled items can't be highlighted and can't open submenus
|
|
720
719
|
if (!item._enabled) {
|
|
@@ -747,6 +746,21 @@ BMMenu.prototype = {
|
|
|
747
746
|
});
|
|
748
747
|
},
|
|
749
748
|
|
|
749
|
+
/**
|
|
750
|
+
* Temporarily set to the menu item that was selected until its action is performed.
|
|
751
|
+
*/
|
|
752
|
+
_selectedMenuItem: undefined, // <BMMenuItem, nullable>
|
|
753
|
+
|
|
754
|
+
/**
|
|
755
|
+
* Performs the action for the specified menu item and invokes the delegate selection callback for it.
|
|
756
|
+
* @param item <BMMenuItem> The menu item whose action should be performed.
|
|
757
|
+
*/
|
|
758
|
+
_performActionForMenuItem(item) {
|
|
759
|
+
item.action?.(item);
|
|
760
|
+
|
|
761
|
+
this.delegate?.menuDidSelectItem?.(this, item);
|
|
762
|
+
},
|
|
763
|
+
|
|
750
764
|
/**
|
|
751
765
|
* The kind of menu currently displayed.
|
|
752
766
|
*/
|
|
@@ -899,8 +913,8 @@ BMMenu.prototype = {
|
|
|
899
913
|
});
|
|
900
914
|
|
|
901
915
|
if (!this._supermenu) {
|
|
902
|
-
// Make the container visible
|
|
903
|
-
__BMVelocityAnimate(menuContainer, {opacity: 1}, {duration, easing}, BMMENU_USE_WEB_ANIMATIONS);
|
|
916
|
+
// Make the container visible, using a different easing for the opacity so that it doesn't overshoot the 1 limit
|
|
917
|
+
__BMVelocityAnimate(menuContainer, {opacity: 1}, {duration: duration / 2, easing: 'easeOutQuad'}, BMMENU_USE_WEB_ANIMATIONS);
|
|
904
918
|
}
|
|
905
919
|
else {
|
|
906
920
|
this._supermenu._node.classList.add('BMMenuInactive');
|
|
@@ -911,8 +925,9 @@ BMMenu.prototype = {
|
|
|
911
925
|
itemsContainerNode.style.overflow = 'hidden';
|
|
912
926
|
|
|
913
927
|
__BMVelocityAnimate(menuNode, {opacity: 1}, {
|
|
914
|
-
duration,
|
|
915
|
-
easing
|
|
928
|
+
duration: duration / 2,
|
|
929
|
+
// Use a different easing for the opacity so that it doesn't overshoot the 1 limit
|
|
930
|
+
easing: 'easeOutQuad',
|
|
916
931
|
}, BMMENU_USE_WEB_ANIMATIONS);
|
|
917
932
|
|
|
918
933
|
__BMVelocityAnimate(menuNode, {scaleX: 1, scaleY: 1, translateZ: 0, translateY: 0, translateX: 0}, {
|
|
@@ -921,7 +936,7 @@ BMMenu.prototype = {
|
|
|
921
936
|
complete: _ => {
|
|
922
937
|
menuNode.style.pointerEvents = 'all';
|
|
923
938
|
menuContainer.style.pointerEvents = 'all';
|
|
924
|
-
}
|
|
939
|
+
},
|
|
925
940
|
}, BMMENU_USE_WEB_ANIMATIONS);
|
|
926
941
|
|
|
927
942
|
// Animate each child node in
|
|
@@ -1380,11 +1395,27 @@ BMMenu.prototype = {
|
|
|
1380
1395
|
let delay = Math.min(this._itemsContainerNode.childNodes.length * 16, 150);
|
|
1381
1396
|
delay = (delay < 0 ? 0 : delay);
|
|
1382
1397
|
|
|
1398
|
+
let selectedItemCallbackDelay = 0;
|
|
1399
|
+
|
|
1383
1400
|
// If an item was clicked, further delay closing to allow the selection animation to play
|
|
1384
1401
|
const delaysClosing = this._delaysClosing;
|
|
1385
1402
|
this._delaysClosing = NO;
|
|
1386
1403
|
if (delaysClosing && !this._sourceNodeShadow) {
|
|
1387
1404
|
delay += 200;
|
|
1405
|
+
|
|
1406
|
+
selectedItemCallbackDelay = 200;
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
const selectedMenuItem = this._selectedMenuItem;
|
|
1410
|
+
this._selectedMenuItem = undefined;
|
|
1411
|
+
|
|
1412
|
+
if (selectedMenuItem) {
|
|
1413
|
+
if (this.delaysActions && selectedItemCallbackDelay) {
|
|
1414
|
+
setTimeout(() => this._performActionForMenuItem(selectedMenuItem), selectedItemCallbackDelay);
|
|
1415
|
+
}
|
|
1416
|
+
else {
|
|
1417
|
+
this._performActionForMenuItem(selectedMenuItem);
|
|
1418
|
+
}
|
|
1388
1419
|
}
|
|
1389
1420
|
|
|
1390
1421
|
const sourceNodeShadow = this._sourceNodeShadow;
|
|
@@ -1547,6 +1578,7 @@ BMMenu.prototype = {
|
|
|
1547
1578
|
},
|
|
1548
1579
|
|
|
1549
1580
|
/**
|
|
1581
|
+
* @protected
|
|
1550
1582
|
* Invoked when the key sequence for a menu item is pressed.
|
|
1551
1583
|
* @param event <KeyboardEvent> The event that triggered this action.
|
|
1552
1584
|
* {
|
|
@@ -1598,11 +1630,7 @@ BMMenu.prototype = {
|
|
|
1598
1630
|
// animation to play out
|
|
1599
1631
|
this._delaysClosing = YES;
|
|
1600
1632
|
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
if (this.delegate && this.delegate.menuDidSelectItem) {
|
|
1604
|
-
this.delegate.menuDidSelectItem(this, item);
|
|
1605
|
-
}
|
|
1633
|
+
this._selectedMenuItem = item;
|
|
1606
1634
|
|
|
1607
1635
|
const highlightedNode = item._node;
|
|
1608
1636
|
if (highlightedNode) {
|
|
@@ -5846,6 +5846,14 @@ declare class BMDragSession implements EventHandlerObject {
|
|
|
5846
5846
|
private _beginDrag(): void;
|
|
5847
5847
|
|
|
5848
5848
|
|
|
5849
|
+
/**
|
|
5850
|
+
* Invoked when a key is pressed while this drag session is in progress.
|
|
5851
|
+
* @param event The event.
|
|
5852
|
+
*
|
|
5853
|
+
*/
|
|
5854
|
+
private _keyPressedWithEvent(event: KeyboardEvent): void;
|
|
5855
|
+
|
|
5856
|
+
|
|
5849
5857
|
/**
|
|
5850
5858
|
* Invoked whenever the pointer moves while this drag session is in progress.
|
|
5851
5859
|
* @param event The event.
|
|
@@ -5856,11 +5864,11 @@ declare class BMDragSession implements EventHandlerObject {
|
|
|
5856
5864
|
|
|
5857
5865
|
/**
|
|
5858
5866
|
* Invoked when the pointer is released or cancelled while this drag session is in progress.
|
|
5859
|
-
* @param event
|
|
5860
|
-
* @return
|
|
5867
|
+
* @param event The event.
|
|
5868
|
+
* @return A promise that resolves when all associated animations finish.
|
|
5861
5869
|
*
|
|
5862
5870
|
*/
|
|
5863
|
-
private _dragDidFinishWithEvent(event: MouseEvent | TouchEvent): Promise<void>;
|
|
5871
|
+
private _dragDidFinishWithEvent(event: MouseEvent | TouchEvent | KeyboardEvent): Promise<void>;
|
|
5864
5872
|
|
|
5865
5873
|
|
|
5866
5874
|
/**
|
|
@@ -7036,6 +7044,13 @@ declare class _BMDragIndicator {
|
|
|
7036
7044
|
*/
|
|
7037
7045
|
declare class _BMDragPreviewSet {
|
|
7038
7046
|
|
|
7047
|
+
/**
|
|
7048
|
+
* The offset between the drag pointer and the center the from of the view from which the drag session
|
|
7049
|
+
* started, expressed in percentages relative to the view's frame.
|
|
7050
|
+
*
|
|
7051
|
+
*/
|
|
7052
|
+
private _offsetPercent: BMPoint;
|
|
7053
|
+
|
|
7039
7054
|
/**
|
|
7040
7055
|
* The offset between the drag pointer and the center of the frames of the preview elements.
|
|
7041
7056
|
*
|
|
@@ -7082,7 +7097,8 @@ declare class _BMDragPreviewSet {
|
|
|
7082
7097
|
* Initializes this drag preview set with the specified item previews and offset position.
|
|
7083
7098
|
* @param previews The previews for items in the drag session.
|
|
7084
7099
|
* @param pointerOffset The offset between the drag pointer and the
|
|
7085
|
-
* center of the frames of the
|
|
7100
|
+
* center of the frames of the view from which the
|
|
7101
|
+
* drag session started.
|
|
7086
7102
|
* @return This preview set.
|
|
7087
7103
|
*
|
|
7088
7104
|
*/
|
|
@@ -9975,6 +9991,13 @@ declare class BMMenu {
|
|
|
9975
9991
|
*/
|
|
9976
9992
|
_delaysClosing: boolean;
|
|
9977
9993
|
|
|
9994
|
+
/**
|
|
9995
|
+
* When set to `YES`, the menu item actions and item selection delegate callbacks will be invoked
|
|
9996
|
+
* with a slight delay to allow time for the menu closing animation to play.
|
|
9997
|
+
*
|
|
9998
|
+
*/
|
|
9999
|
+
delaysActions: boolean;
|
|
10000
|
+
|
|
9978
10001
|
/**
|
|
9979
10002
|
* Initializes this menu with the specified items.
|
|
9980
10003
|
* The menu will be hidden by default; the method showAtPoint(_) should be used to make the menu visible.
|
|
@@ -10011,6 +10034,20 @@ declare class BMMenu {
|
|
|
10011
10034
|
private _renderMenuItems(): void;
|
|
10012
10035
|
|
|
10013
10036
|
|
|
10037
|
+
/**
|
|
10038
|
+
* Temporarily set to the menu item that was selected until its action is performed.
|
|
10039
|
+
*
|
|
10040
|
+
*/
|
|
10041
|
+
private _selectedMenuItem?: BMMenuItem | null | undefined;
|
|
10042
|
+
|
|
10043
|
+
/**
|
|
10044
|
+
* Performs the action for the specified menu item and invokes the delegate selection callback for it.
|
|
10045
|
+
* @param item The menu item whose action should be performed.
|
|
10046
|
+
*
|
|
10047
|
+
*/
|
|
10048
|
+
private _performActionForMenuItem(item: BMMenuItem): void;
|
|
10049
|
+
|
|
10050
|
+
|
|
10014
10051
|
/**
|
|
10015
10052
|
* The kind of menu currently displayed.
|
|
10016
10053
|
*
|
|
@@ -10133,7 +10170,7 @@ declare class BMMenu {
|
|
|
10133
10170
|
* @param forKeyboardShortcut The keyboard shortcut that was triggered.
|
|
10134
10171
|
*
|
|
10135
10172
|
*/
|
|
10136
|
-
|
|
10173
|
+
protected _selectMenuItemWithEvent(event: KeyboardEvent, {forKeyboardShortcut}: {forKeyboardShortcut: BMKeyboardShortcut}): void;
|
|
10137
10174
|
|
|
10138
10175
|
|
|
10139
10176
|
/**
|