- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
- 114
- 115
- 116
- 117
- 118
- 119
- 120
- 121
- 122
- 123
- 124
- 125
- 126
- 127
- 128
- 129
- 130
- 131
- 132
- 133
- 134
- 135
- 136
- 137
- 138
- 139
- 140
- 141
- 142
- 143
- 144
- 145
- 146
- 147
- 148
- 149
- 150
- 151
- 152
- 153
- 154
- 155
- 156
- 157
- 158
- 159
- 160
- 161
- 162
- 163
- 164
- 165
- 166
- 167
- 168
- 169
- 170
- 171
- 172
- 173
- 174
- 175
- 176
- 177
- 178
- 179
- 180
- 181
- 182
- 183
- 184
- 185
- 186
- 187
- 188
- 189
- 190
- 191
- 192
- 193
- 194
- 195
- 196
- 197
- 198
- 199
- 200
- 201
- 202
- 203
- 204
- 205
- 206
- 207
- 208
- 209
- 210
- 211
- 212
- 213
- 214
- 215
- 216
- 217
- 218
- 219
- 220
- 221
- 222
- 223
- 224
- 225
- 226
- 227
- 228
- 229
- 230
- 231
- 232
- 233
- 234
- 235
- 236
- 237
- 238
- 239
- 240
- 241
- 242
- 243
- 244
- 245
- 246
- 247
- 248
- 249
- 250
- 251
- 252
- 253
- 254
- 255
- 256
- 257
- 258
- 259
- 260
- 261
- 262
- 263
- 264
- 265
- 266
- 267
- 268
- 269
- 270
- 271
- 272
- 273
- 274
- 275
- 276
- 277
- 278
- 279
- 280
- 281
- 282
- 283
- 284
- 285
- 286
- 287
- 288
- 289
- 290
- 291
- 292
- 293
- 294
- 295
- 296
- 297
- 298
- 299
- 300
- 301
- 302
- 303
- 304
- 305
- 306
- 307
- 308
- 309
- 310
- 311
- 312
- 313
- 314
- 315
- 316
- 317
- 318
- 319
- 320
- 321
- 322
- 323
- 324
- 325
- 326
- 327
- 328
- 329
- 330
- 331
- 332
- 333
- 334
- 335
- 336
- 337
- 338
- 339
- 340
- 341
- 342
- 343
- 344
- 345
- 346
- 347
- 348
- 349
- 350
- 351
- 352
- 353
- 354
- 355
- 356
- 357
- 358
- 359
- 360
- 361
- 362
- 363
- 364
- 365
- 366
- 367
- 368
- 369
- 370
- 371
- 372
- 373
- 374
- 375
- 376
- 377
- 378
- 379
- 380
- 381
- 382
- 383
- 384
- 385
- 386
- 387
- 388
- 389
- 390
- 391
- 392
- 393
- 394
- 395
- 396
- 397
- 398
- 399
- 400
- 401
- 402
- 403
- 404
- 405
- 406
- 407
- 408
- 409
- 410
- 411
- 412
- 413
- 414
- 415
- 416
- 417
- 418
- 419
- 420
- 421
- 422
- 423
- 424
- 425
- 426
- 427
- 428
- 429
- 430
- 431
- 432
- 433
- 434
- 435
- 436
- 437
- 438
- 439
- 440
- 441
- 442
- 443
- 444
- 445
- 446
- 447
- 448
- 449
- 450
- 451
- 452
- 453
- 454
- 455
- 456
- 457
- 458
- 459
- 460
- 461
- 462
- 463
- 464
- 465
- 466
- 467
- 468
- 469
- 470
- 471
- 472
- 473
- 474
- 475
- 476
- 477
- 478
- 479
- 480
- 481
- 482
- 483
- 484
- 485
- 486
- 487
- 488
- 489
- 490
- 491
- 492
- 493
- 494
- 495
- 496
- 497
- 498
- 499
- 500
- 501
- 502
- 503
- 504
- 505
- 506
- 507
- 508
- 509
- 510
- 511
- 512
- 513
- 514
- 515
- 516
- 517
- 518
- 519
- 520
- 521
- 522
- 523
- 524
- 525
- 526
- 527
- 528
- 529
- 530
- 531
- 532
- 533
- 534
- 535
- 536
- 537
- 538
- 539
- 540
- 541
- 542
- 543
- 544
- 545
- 546
- 547
- 548
- 549
- 550
- 551
- 552
- 553
- 554
- 555
- 556
- 557
- 558
- 559
- 560
- 561
- 562
- 563
- 564
- 565
- 566
- 567
- 568
- 569
- 570
- 571
- 572
- 573
- 574
- 575
- 576
- 577
- 578
- 579
- 580
- 581
- 582
- 583
- 584
- 585
- 586
- 587
- 588
- 589
- 590
- 591
- 592
- 593
- 594
- 595
- 596
- 597
- 598
- 599
- 600
- 601
- 602
- 603
- 604
- 605
- 606
- 607
- 608
- 609
- 610
- 611
- 612
- 613
- 614
- 615
- 616
- 617
- 618
- 619
- 620
- 621
- 622
- 623
- 624
- 625
- 626
- 627
- 628
- 629
- 630
- 631
- 632
- 633
- 634
- 635
- 636
- 637
- 638
- 639
- 640
- 641
- 642
- 643
- 644
- 645
- 646
- 647
- 648
- 649
- 650
- 651
- 652
- 653
- 654
- 655
- 656
- 657
- 658
- 659
- 660
- 661
- 662
- 663
- 664
- 665
- 666
- 667
- 668
- 669
- 670
- 671
- 672
- 673
- 674
- 675
- 676
- 677
- 678
- 679
- 680
- 681
- 682
- 683
- 684
- 685
- 686
- 687
- 688
- 689
- 690
- 691
- 692
- 693
- 694
- 695
- 696
- 697
- 698
- 699
- 700
- 701
- 702
- 703
- 704
- 705
- 706
- 707
- 708
- 709
- 710
- 711
- 712
- 713
- 714
- 715
- 716
- 717
- 718
- 719
- 720
- 721
- 722
- 723
- 724
- 725
- 726
- 727
- 728
- 729
- 730
- 731
- 732
- 733
- 734
- 735
- 736
- 737
- 738
- 739
- 740
- 741
- 742
- 743
- 744
- 745
- 746
- 747
- 748
- 749
- 750
- 751
- 752
- 753
- 754
- 755
- 756
- 757
- 758
- 759
- 760
- 761
- 762
- 763
- 764
- 765
- 766
- 767
- 768
- 769
- 770
- 771
- 772
- 773
- 774
- 775
- 776
- 777
- 778
- 779
- 780
- 781
- 782
- 783
- 784
- 785
- 786
- 787
- 788
- 789
- 790
- 791
- 792
- 793
- 794
- 795
- 796
- 797
- 798
- 799
- 800
- 801
- 802
- 803
- 804
- 805
- 806
- 807
- 808
- 809
- 810
- 811
- 812
- 813
- 814
- 815
- 816
- 817
- 818
- 819
- 820
- 821
- 822
- 823
- 824
- 825
- 826
- 827
- 828
- 829
- 830
- 831
- 832
- 833
- 834
- 835
- 836
- 837
- 838
- 839
- 840
- 841
- 842
- 843
- 844
- 845
- 846
- 847
- 848
- 849
- 850
- 851
- 852
- 853
- 854
- 855
- 856
- 857
- 858
- 859
- 860
- 861
- 862
- 863
- 864
- 865
- 866
- 867
- 868
- 869
- 870
- 871
- 872
- 873
- 874
- 875
- 876
- 877
- 878
- 879
- 880
- 881
- 882
- 883
- 884
- 885
- 886
- 887
- 888
- 889
- 890
- 891
- 892
- 893
- 894
- 895
- 896
- 897
- 898
- 899
- 900
- 901
- 902
- 903
- 904
- 905
- 906
- 907
- 908
- 909
- 910
- 911
- 912
- 913
- 914
- 915
- 916
- 917
- 918
- 919
- 920
- 921
- 922
- 923
- 924
- 925
- 926
- 927
- 928
- 929
- 930
- 931
- 932
- 933
- 934
- 935
- 936
- 937
- 938
- 939
- 940
- 941
- 942
- 943
- 944
- 945
- 946
- 947
- 948
- 949
- 950
- 951
- 952
- 953
- 954
- 955
- 956
- 957
- 958
- 959
- 960
- 961
- 962
- 963
- 964
- 965
- 966
- 967
- 968
- 969
- 970
- 971
- 972
- 973
- 974
- 975
- 976
- 977
- 978
- 979
- 980
- 981
- 982
- 983
- 984
- 985
- 986
- 987
- 988
- 989
- 990
- 991
- 992
- 993
- 994
- 995
- 996
- 997
- 998
- 999
- 1000
- 1001
- 1002
- 1003
- 1004
- 1005
- 1006
- 1007
- 1008
- 1009
- 1010
- 1011
- 1012
- 1013
- 1014
- 1015
- 1016
- 1017
- 1018
- 1019
- 1020
- 1021
- 1022
- 1023
- 1024
- 1025
- 1026
- 1027
- 1028
- 1029
- 1030
- 1031
- 1032
- 1033
- 1034
- 1035
- 1036
- 1037
- 1038
- 1039
- 1040
- 1041
- 1042
- 1043
- 1044
- 1045
- 1046
- 1047
- 1048
- 1049
- 1050
- 1051
- 1052
- 1053
- 1054
- 1055
- 1056
- 1057
- 1058
- 1059
- 1060
- 1061
- 1062
- 1063
- 1064
- 1065
- 1066
- 1067
- 1068
- 1069
- 1070
- 1071
- 1072
- 1073
- 1074
- 1075
- 1076
- 1077
- 1078
- 1079
- 1080
- 1081
- 1082
- 1083
- 1084
- 1085
- 1086
- 1087
- 1088
- 1089
- 1090
- 1091
- 1092
- 1093
- 1094
- 1095
- 1096
- 1097
- 1098
- 1099
- 1100
- 1101
- 1102
- 1103
- 1104
- 1105
- 1106
- 1107
- 1108
- 1109
- 1110
- 1111
- 1112
- 1113
- 1114
- 1115
- 1116
- 1117
- 1118
- 1119
- 1120
- 1121
- 1122
- 1123
- 1124
- 1125
- 1126
- 1127
- 1128
- 1129
- 1130
- 1131
- 1132
- 1133
- 1134
- 1135
- 1136
- 1137
- 1138
- 1139
- 1140
- 1141
- 1142
- 1143
- 1144
- 1145
- 1146
- 1147
- 1148
- 1149
- 1150
- 1151
- 1152
- 1153
- 1154
- 1155
- 1156
- 1157
- 1158
- 1159
- 1160
- 1161
- 1162
- 1163
- 1164
- 1165
- 1166
- 1167
- 1168
- 1169
- 1170
- 1171
- 1172
- 1173
- 1174
- 1175
- 1176
- 1177
- 1178
- 1179
- 1180
- 1181
- 1182
- 1183
- 1184
- 1185
- 1186
- 1187
- 1188
- 1189
- 1190
- 1191
- 1192
- 1193
- 1194
- 1195
- 1196
- 1197
- 1198
- 1199
- 1200
- 1201
- 1202
- 1203
- 1204
- 1205
- 1206
- 1207
- 1208
- 1209
- 1210
- 1211
- 1212
- 1213
- 1214
- 1215
- 1216
- 1217
- 1218
- 1219
- 1220
- 1221
- 1222
- 1223
- 1224
- 1225
- 1226
- 1227
- 1228
- 1229
- 1230
- 1231
- 1232
- 1233
- 1234
- 1235
- 1236
- 1237
- 1238
- 1239
- 1240
- 1241
- 1242
- 1243
- 1244
- 1245
- 1246
- 1247
- 1248
- 1249
- 1250
- 1251
- 1252
- 1253
- 1254
- 1255
- 1256
- 1257
- 1258
- 1259
- 1260
- 1261
- 1262
- 1263
- 1264
- 1265
- 1266
- 1267
- 1268
- 1269
- 1270
- 1271
- 1272
- 1273
- 1274
- 1275
- 1276
- 1277
- 1278
- 1279
- 1280
- 1281
- 1282
- 1283
- 1284
- 1285
- 1286
- 1287
- 1288
- 1289
- 1290
- 1291
- 1292
- 1293
- 1294
- 1295
- 1296
- 1297
- 1298
- 1299
- 1300
- 1301
- 1302
- 1303
- 1304
- 1305
- 1306
- 1307
- 1308
- 1309
- 1310
- 1311
- 1312
- 1313
- 1314
- 1315
- 1316
- 1317
- 1318
- 1319
- 1320
- 1321
- 1322
- 1323
- 1324
- 1325
- 1326
- 1327
- 1328
- 1329
- 1330
- 1331
- 1332
- 1333
- 1334
- 1335
- 1336
- 1337
- 1338
- 1339
- 1340
- 1341
- 1342
- 1343
- 1344
- 1345
- 1346
- 1347
- 1348
- 1349
- 1350
- 1351
- 1352
- 1353
- 1354
- 1355
- 1356
- 1357
- 1358
- 1359
- 1360
- 1361
- 1362
- 1363
- 1364
- 1365
- 1366
- 1367
- 1368
- 1369
- 1370
- 1371
- 1372
- 1373
- 1374
- 1375
- 1376
- 1377
- 1378
- 1379
- 1380
- 1381
- 1382
- 1383
- 1384
- 1385
- 1386
- 1387
- 1388
- 1389
- 1390
- 1391
- 1392
- 1393
- 1394
- 1395
- 1396
- 1397
- 1398
- 1399
- 1400
- 1401
- 1402
- 1403
- 1404
- 1405
- 1406
- 1407
- 1408
- 1409
- 1410
- 1411
- 1412
- 1413
- 1414
- 1415
- 1416
- 1417
- 1418
- 1419
- 1420
- 1421
- 1422
- 1423
- 1424
- 1425
- 1426
- 1427
- 1428
- 1429
- 1430
- 1431
- 1432
- 1433
- 1434
- 1435
- 1436
- 1437
- 1438
- 1439
- 1440
- 1441
- 1442
- 1443
- 1444
- 1445
- 1446
- 1447
- 1448
- 1449
- 1450
- 1451
- 1452
- 1453
- 1454
- 1455
- 1456
- 1457
- 1458
- 1459
- 1460
- 1461
- 1462
- 1463
- 1464
- 1465
- 1466
- 1467
- 1468
- 1469
- 1470
- 1471
- 1472
- 1473
- 1474
- 1475
- 1476
- 1477
- 1478
- 1479
- 1480
- 1481
- 1482
- 1483
- 1484
- 1485
- 1486
- 1487
- 1488
- 1489
- 1490
- 1491
- 1492
- 1493
- 1494
- 1495
- 1496
- 1497
- 1498
- 1499
- 1500
- 1501
- 1502
- 1503
- 1504
- 1505
- 1506
- 1507
- 1508
- 1509
- 1510
- 1511
- 1512
- 1513
- 1514
- 1515
- 1516
- 1517
- 1518
- 1519
- 1520
- 1521
- 1522
- 1523
- 1524
- 1525
- 1526
- 1527
- 1528
- 1529
- 1530
- 1531
- 1532
- 1533
- 1534
- 1535
- 1536
- 1537
- 1538
- 1539
- 1540
- 1541
- 1542
- 1543
- 1544
- 1545
- 1546
- 1547
- 1548
- 1549
- 1550
- 1551
- 1552
- 1553
- 1554
- 1555
- 1556
- 1557
- 1558
- 1559
- 1560
- 1561
- 1562
- 1563
- 1564
- 1565
- 1566
- 1567
- 1568
- 1569
- 1570
- 1571
- 1572
- 1573
- 1574
- 1575
- 1576
- 1577
- 1578
- 1579
- 1580
- 1581
- 1582
- 1583
- 1584
- 1585
- 1586
- 1587
- 1588
- 1589
- 1590
- 1591
- 1592
- 1593
- 1594
- 1595
- 1596
- 1597
- 1598
- 1599
- 1600
- 1601
- 1602
- 1603
- 1604
- 1605
- 1606
- 1607
- 1608
- 1609
- 1610
- 1611
- 1612
- 1613
- 1614
- 1615
- 1616
- 1617
- 1618
- 1619
- 1620
- 1621
- 1622
- 1623
- 1624
- 1625
- 1626
- 1627
- 1628
- 1629
- 1630
- 1631
- 1632
- 1633
- 1634
- 1635
- 1636
- 1637
- 1638
- 1639
- 1640
- 1641
- 1642
- 1643
- 1644
- 1645
- 1646
- 1647
- 1648
- 1649
- 1650
- 1651
- 1652
- 1653
- 1654
- 1655
- 1656
- 1657
- 1658
- 1659
- 1660
- 1661
- 1662
- 1663
- 1664
- 1665
- 1666
- 1667
- 1668
- 1669
- 1670
- 1671
- 1672
- 1673
- 1674
- 1675
- 1676
- 1677
- 1678
- 1679
- 1680
- 1681
- 1682
- 1683
- 1684
- 1685
- 1686
- 1687
- 1688
- 1689
- 1690
- 1691
- 1692
- 1693
- 1694
- 1695
- 1696
- 1697
- 1698
- 1699
- 1700
- 1701
- 1702
- 1703
- 1704
- 1705
- 1706
- 1707
- 1708
- 1709
- 1710
- 1711
- 1712
- 1713
- 1714
- 1715
- 1716
- 1717
- 1718
- 1719
- 1720
- 1721
- 1722
- 1723
- 1724
- 1725
- 1726
- 1727
- 1728
- 1729
- 1730
- 1731
- 1732
- 1733
- 1734
- 1735
- 1736
- 1737
- 1738
- 1739
- 1740
- 1741
- 1742
- 1743
- 1744
- 1745
- 1746
- 1747
- 1748
- 1749
- 1750
- 1751
- 1752
- 1753
- 1754
- 1755
- 1756
- 1757
- 1758
- 1759
- 1760
- 1761
- 1762
- 1763
- 1764
- 1765
- 1766
- 1767
- 1768
- 1769
- 1770
- 1771
- 1772
- 1773
- 1774
- 1775
- 1776
- 1777
- 1778
- 1779
- 1780
- 1781
- 1782
- 1783
- 1784
- 1785
- 1786
- 1787
- 1788
- 1789
- 1790
- 1791
- 1792
- 1793
- 1794
- 1795
- 1796
- 1797
- 1798
- 1799
- 1800
- 1801
- 1802
- 1803
- 1804
- 1805
- 1806
- 1807
- 1808
- 1809
- 1810
- 1811
- 1812
- 1813
- 1814
- 1815
- 1816
- 1817
- 1818
- 1819
- 1820
- 1821
- 1822
- 1823
- 1824
- 1825
- 1826
- 1827
- 1828
- 1829
- 1830
- 1831
- 1832
- 1833
- 1834
- 1835
- 1836
- 1837
- 1838
- 1839
- 1840
- 1841
- 1842
- 1843
- 1844
- 1845
- 1846
- 1847
- 1848
- 1849
- 1850
- 1851
- 1852
- 1853
- 1854
- 1855
- 1856
- 1857
- 1858
- 1859
- 1860
- 1861
import { EventEmitter } from '@pixi/utils';
import { FederatedMouseEvent } from './FederatedMouseEvent';
import { FederatedPointerEvent } from './FederatedPointerEvent';
import { FederatedWheelEvent } from './FederatedWheelEvent';
import { Point } from '@pixi/math';
import type { Cursor, FederatedEventTarget } from './FederatedEventTarget';
import type { DisplayObject } from '@pixi/display';
import type { FederatedEvent } from './FederatedEvent';
// The maximum iterations used in propagation. This prevent infinite loops.
const PROPAGATION_LIMIT = 2048;
const tempHitLocation = new Point();
const tempLocalMapping = new Point();
/**
* The tracking data for each pointer held in the state of an {@link PIXI.EventBoundary}.
*
* ```ts
* pressTargetsByButton: {
* [id: number]: FederatedEventTarget[];
* };
* clicksByButton: {
* [id: number]: {
* clickCount: number;
* target: FederatedEventTarget;
* timeStamp: number;
* }
* };
* overTargets: FederatedEventTarget[];
* ```
* @typedef {object} TrackingData
* @property {Record.<number, PIXI.FederatedEventTarget>} pressTargetsByButton - The pressed display objects'
* propagation paths by each button of the pointer.
* @property {Record.<number, object>} clicksByButton - Holds clicking data for each button of the pointer.
* @property {PIXI.DisplayObject[]} overTargets - The DisplayObject propagation path over which the pointer is hovering.
* @memberof PIXI
*/
type TrackingData = {
pressTargetsByButton: {
[id: number]: FederatedEventTarget[];
};
clicksByButton: {
[id: number]: {
clickCount: number;
target: FederatedEventTarget;
timeStamp: number;
}
};
overTargets: FederatedEventTarget[];
};
/**
* Internal storage of event listeners in EventEmitter.
* @ignore
*/
type EmitterListeners = Record<string,
| Array<{ fn(...args: any[]): any, context: any }>
| { fn(...args: any[]): any, context: any }
>;
/**
* Event boundaries are "barriers" where events coming from an upstream scene are modified before downstream propagation.
*
* ## Root event boundary
*
* The {@link PIXI.EventSystem#rootBoundary rootBoundary} handles events coming from the <canvas />.
* {@link PIXI.EventSystem} handles the normalization from native {@link https://dom.spec.whatwg.org/#event Events}
* into {@link PIXI.FederatedEvent FederatedEvents}. The rootBoundary then does the hit-testing and event dispatch
* for the upstream normalized event.
*
* ## Additional event boundaries
*
* An additional event boundary may be desired within an application's scene graph. For example, if a portion of the scene is
* is flat with many children at one level - a spatial hash maybe needed to accelerate hit testing. In this scenario, the
* container can be detached from the scene and glued using a custom event boundary.
*
* ```ts
* import { Container } from '@pixi/display';
* import { EventBoundary } from '@pixi/events';
* import { SpatialHash } from 'pixi-spatial-hash';
*
* class HashedHitTestingEventBoundary
* {
* private spatialHash: SpatialHash;
*
* constructor(scene: Container, spatialHash: SpatialHash)
* {
* super(scene);
* this.spatialHash = spatialHash;
* }
*
* hitTestRecursive(...)
* {
* // TODO: If target === this.rootTarget, then use spatial hash to get a
* // list of possible children that match the given (x,y) coordinates.
* }
* }
*
* class VastScene extends DisplayObject
* {
* protected eventBoundary: EventBoundary;
* protected scene: Container;
* protected spatialHash: SpatialHash;
*
* constructor()
* {
* this.scene = new Container();
* this.spatialHash = new SpatialHash();
* this.eventBoundary = new HashedHitTestingEventBoundary(this.scene, this.spatialHash);
*
* // Populate this.scene with a ton of children, while updating this.spatialHash
* }
* }
* ```
* @memberof PIXI
*/
export class EventBoundary
{
/**
* The root event-target residing below the event boundary.
*
* All events are dispatched trickling down and bubbling up to this `rootTarget`.
*/
public rootTarget: DisplayObject;
/**
* Emits events after they were dispatched into the scene graph.
*
* This can be used for global events listening, regardless of the scene graph being used. It should
* not be used by interactive libraries for normal use.
*
* Special events that do not bubble all the way to the root target are not emitted from here,
* e.g. pointerenter, pointerleave, click.
*/
public dispatch: EventEmitter = new EventEmitter();
/** The cursor preferred by the event targets underneath this boundary. */
public cursor: Cursor | string;
/**
* This flag would emit `pointermove`, `touchmove`, and `mousemove` events on all DisplayObjects.
*
* The `moveOnAll` semantics mirror those of earlier versions of PixiJS. This was disabled in favor of
* the Pointer Event API's approach.
*/
public moveOnAll = false;
/**
* Maps event types to forwarding handles for them.
*
* {@link PIXI.EventBoundary EventBoundary} provides mapping for "pointerdown", "pointermove",
* "pointerout", "pointerleave", "pointerover", "pointerup", and "pointerupoutside" by default.
* @see PIXI.EventBoundary#addEventMapping
*/
protected mappingTable: Record<string, Array<{
fn: (e: FederatedEvent) => void,
priority: number
}>>;
/**
* State object for mapping methods.
* @see PIXI.EventBoundary#trackingData
*/
protected mappingState: Record<string, any> = {
trackingData: {}
};
/**
* The event pool maps event constructors to an free pool of instances of those specific events.
* @see PIXI.EventBoundary#allocateEvent
* @see PIXI.EventBoundary#freeEvent
*/
protected eventPool: Map<typeof FederatedEvent, FederatedEvent[]> = new Map();
/**
* @param rootTarget - The holder of the event boundary.
*/
constructor(rootTarget?: DisplayObject)
{
this.rootTarget = rootTarget;
this.hitPruneFn = this.hitPruneFn.bind(this);
this.hitTestFn = this.hitTestFn.bind(this);
this.mapPointerDown = this.mapPointerDown.bind(this);
this.mapPointerMove = this.mapPointerMove.bind(this);
this.mapPointerOut = this.mapPointerOut.bind(this);
this.mapPointerOver = this.mapPointerOver.bind(this);
this.mapPointerUp = this.mapPointerUp.bind(this);
this.mapPointerUpOutside = this.mapPointerUpOutside.bind(this);
this.mapWheel = this.mapWheel.bind(this);
this.mappingTable = {};
this.addEventMapping('pointerdown', this.mapPointerDown);
this.addEventMapping('pointermove', this.mapPointerMove);
this.addEventMapping('pointerout', this.mapPointerOut);
this.addEventMapping('pointerleave', this.mapPointerOut);
this.addEventMapping('pointerover', this.mapPointerOver);
this.addEventMapping('pointerup', this.mapPointerUp);
this.addEventMapping('pointerupoutside', this.mapPointerUpOutside);
this.addEventMapping('wheel', this.mapWheel);
}
/**
* Adds an event mapping for the event `type` handled by `fn`.
*
* Event mappings can be used to implement additional or custom events. They take an event
* coming from the upstream scene (or directly from the {@link PIXI.EventSystem}) and dispatch new downstream events
* generally trickling down and bubbling up to {@link PIXI.EventBoundary.rootTarget this.rootTarget}.
*
* To modify the semantics of existing events, the built-in mapping methods of EventBoundary should be overridden
* instead.
* @param type - The type of upstream event to map.
* @param fn - The mapping method. The context of this function must be bound manually, if desired.
*/
public addEventMapping(type: string, fn: (e: FederatedEvent) => void): void
{
if (!this.mappingTable[type])
{
this.mappingTable[type] = [];
}
this.mappingTable[type].push({
fn,
priority: 0,
});
this.mappingTable[type].sort((a, b) => a.priority - b.priority);
}
/**
* Dispatches the given event
* @param e
* @param type
*/
public dispatchEvent(e: FederatedEvent, type?: string): void
{
e.propagationStopped = false;
e.propagationImmediatelyStopped = false;
this.propagate(e, type);
this.dispatch.emit(type || e.type, e);
}
/**
* Maps the given upstream event through the event boundary and propagates it downstream.
* @param e
*/
public mapEvent(e: FederatedEvent): void
{
if (!this.rootTarget)
{
return;
}
const mappers = this.mappingTable[e.type];
if (mappers)
{
for (let i = 0, j = mappers.length; i < j; i++)
{
mappers[i].fn(e);
}
}
else
{
console.warn(`[EventBoundary]: Event mapping not defined for ${e.type}`);
}
}
/**
* Finds the DisplayObject that is the target of a event at the given coordinates.
*
* The passed (x,y) coordinates are in the world space above this event boundary.
* @param x
* @param y
*/
public hitTest(
x: number,
y: number,
): DisplayObject
{
const invertedPath = this.hitTestRecursive(
this.rootTarget,
this.rootTarget.interactive,
tempHitLocation.set(x, y),
this.hitTestFn,
this.hitPruneFn,
);
return invertedPath && invertedPath[0];
}
/**
* Propagate the passed event from from {@link EventBoundary.rootTarget this.rootTarget} to its
* target {@code e.target}.
* @param e - The event to propagate.
* @param type
*/
public propagate(e: FederatedEvent, type?: string): void
{
if (!e.target)
{
// This usually occurs when the scene graph is not interactive.
return;
}
const composedPath = e.composedPath();
// Capturing phase
e.eventPhase = e.CAPTURING_PHASE;
for (let i = 0, j = composedPath.length - 1; i < j; i++)
{
e.currentTarget = composedPath[i];
this.notifyTarget(e, type);
if (e.propagationStopped || e.propagationImmediatelyStopped) return;
}
// At target phase
e.eventPhase = e.AT_TARGET;
e.currentTarget = e.target;
this.notifyTarget(e, type);
if (e.propagationStopped || e.propagationImmediatelyStopped) return;
// Bubbling phase
e.eventPhase = e.BUBBLING_PHASE;
for (let i = composedPath.length - 2; i >= 0; i--)
{
e.currentTarget = composedPath[i];
this.notifyTarget(e, type);
if (e.propagationStopped || e.propagationImmediatelyStopped) return;
}
}
/**
* Emits the event {@link e} to all display objects. The event is propagated in the bubbling phase always.
*
* This is used in the `pointermove` legacy mode.
* @param e - The emitted event.
* @param type - The listeners to notify.
* @param target
*/
public all(e: FederatedEvent, type?: string, target: FederatedEventTarget = this.rootTarget): void
{
e.eventPhase = e.BUBBLING_PHASE;
const children = target.children;
if (children)
{
for (let i = 0; i < children.length; i++)
{
this.all(e, type, children[i]);
}
}
e.currentTarget = target;
this.notifyTarget(e, type);
}
/**
* Finds the propagation path from {@link PIXI.EventBoundary.rootTarget rootTarget} to the passed
* {@code target}. The last element in the path is {@code target}.
* @param target
*/
public propagationPath(target: FederatedEventTarget): FederatedEventTarget[]
{
const propagationPath = [target];
for (let i = 0; i < PROPAGATION_LIMIT && target !== this.rootTarget; i++)
{
if (!target.parent)
{
throw new Error('Cannot find propagation path to disconnected target');
}
propagationPath.push(target.parent);
target = target.parent;
}
propagationPath.reverse();
return propagationPath;
}
/**
* Recursive implementation for {@link EventBoundary.hitTest hitTest}.
* @param currentTarget - The DisplayObject that is to be hit tested.
* @param interactive - Flags whether `currentTarget` or one of its parents are interactive.
* @param location - The location that is being tested for overlap.
* @param testFn - Callback that determines whether the target passes hit testing. This callback
* can assume that `pruneFn` failed to prune the display object.
* @param pruneFn - Callback that determiness whether the target and all of its children
* cannot pass the hit test. It is used as a preliminary optimization to prune entire subtrees
* of the scene graph.
* @returns An array holding the hit testing target and all its ancestors in order. The first element
* is the target itself and the last is {@link EventBoundary.rootTarget rootTarget}. This is the opposite
* order w.r.t. the propagation path. If no hit testing target is found, null is returned.
*/
protected hitTestRecursive(
currentTarget: DisplayObject,
interactive: boolean,
location: Point,
testFn: (object: DisplayObject, pt: Point) => boolean,
pruneFn?: (object: DisplayObject, pt: Point) => boolean,
): DisplayObject[]
{
if (!currentTarget || !currentTarget.visible)
{
return null;
}
// Attempt to prune this DisplayObject and its subtree as an optimization.
if (pruneFn(currentTarget, location))
{
return null;
}
// Find a child that passes the hit testing and return one, if any.
if (currentTarget.interactiveChildren && currentTarget.children)
{
const children = currentTarget.children;
for (let i = children.length - 1; i >= 0; i--)
{
const child = children[i] as DisplayObject;
const nestedHit = this.hitTestRecursive(
child,
interactive || child.interactive,
location,
testFn,
pruneFn,
);
if (nestedHit)
{
// Its a good idea to check if a child has lost its parent.
// this means it has been removed whilst looping so its best
if (nestedHit.length > 0 && !nestedHit[nestedHit.length - 1].parent)
{
continue;
}
// Only add the current hit-test target to the hit-test chain if the chain
// has already started (i.e. the event target has been found) or if the current
// target is interactive (i.e. it becomes the event target).
if (nestedHit.length > 0 || currentTarget.interactive)
{
nestedHit.push(currentTarget);
}
return nestedHit;
}
}
}
// Finally, hit test this DisplayObject itself.
if (interactive && testFn(currentTarget, location))
{
// The current hit-test target is the event's target only if it is interactive. Otherwise,
// the first interactive ancestor will be the event's target.
return currentTarget.interactive ? [currentTarget] : [];
}
return null;
}
/**
* Checks whether the display object or any of its children cannot pass the hit test at all.
*
* {@link EventBoundary}'s implementation uses the {@link PIXI.DisplayObject.hitArea hitArea}
* and {@link PIXI.DisplayObject._mask} for pruning.
* @param displayObject
* @param location
*/
protected hitPruneFn(displayObject: DisplayObject, location: Point): boolean
{
if (displayObject.hitArea)
{
displayObject.worldTransform.applyInverse(location, tempLocalMapping);
if (!displayObject.hitArea.contains(tempLocalMapping.x, tempLocalMapping.y))
{
return true;
}
}
if (displayObject._mask)
{
const maskObject = ((displayObject._mask as any).isMaskData
? (displayObject._mask as any).maskObject : displayObject._mask);
if (maskObject && !maskObject.containsPoint?.(location))
{
return true;
}
}
return false;
}
/**
* Checks whether the display object passes hit testing for the given location.
* @param displayObject
* @param location
* @returns - Whether `displayObject` passes hit testing for `location`.
*/
protected hitTestFn(displayObject: DisplayObject, location: Point): boolean
{
// If the display object failed pruning with a hitArea, then it must pass it.
if (displayObject.hitArea)
{
return true;
}
if ((displayObject as any).containsPoint)
{
return (displayObject as any).containsPoint(location) as boolean;
}
// TODO: Should we hit test based on bounds?
return false;
}
/**
* Notify all the listeners to the event's `currentTarget`.
* @param e - The event passed to the target.
* @param type
*/
protected notifyTarget(e: FederatedEvent, type?: string): void
{
type = type ?? e.type;
const key = e.eventPhase === e.CAPTURING_PHASE || e.eventPhase === e.AT_TARGET ? `${type}capture` : type;
this.notifyListeners(e, key);
if (e.eventPhase === e.AT_TARGET)
{
this.notifyListeners(e, type);
}
}
/**
* Maps the upstream `pointerdown` events to a downstream `pointerdown` event.
*
* `touchstart`, `rightdown`, `mousedown` events are also dispatched for specific pointer types.
* @param from
*/
protected mapPointerDown(from: FederatedEvent): void
{
if (!(from instanceof FederatedPointerEvent))
{
console.warn('EventBoundary cannot map a non-pointer event as a pointer event');
return;
}
const e = this.createPointerEvent(from);
this.dispatchEvent(e, 'pointerdown');
if (e.pointerType === 'touch')
{
this.dispatchEvent(e, 'touchstart');
}
else if (e.pointerType === 'mouse' || e.pointerType === 'pen')
{
const isRightButton = e.button === 2;
this.dispatchEvent(e, isRightButton ? 'rightdown' : 'mousedown');
}
const trackingData = this.trackingData(from.pointerId);
trackingData.pressTargetsByButton[from.button] = e.composedPath();
this.freeEvent(e);
}
/**
* Maps the upstream `pointermove` to downstream `pointerout`, `pointerover`, and `pointermove` events, in that order.
*
* The tracking data for the specific pointer has an updated `overTarget`. `mouseout`, `mouseover`,
* `mousemove`, and `touchmove` events are fired as well for specific pointer types.
* @param from - The upstream `pointermove` event.
*/
protected mapPointerMove(from: FederatedEvent): void
{
if (!(from instanceof FederatedPointerEvent))
{
console.warn('EventBoundary cannot map a non-pointer event as a pointer event');
return;
}
const e = this.createPointerEvent(from);
const isMouse = e.pointerType === 'mouse' || e.pointerType === 'pen';
const trackingData = this.trackingData(from.pointerId);
const outTarget = this.findMountedTarget(trackingData.overTargets);
// First pointerout/pointerleave
if (trackingData.overTargets && outTarget !== e.target)
{
// pointerout always occurs on the overTarget when the pointer hovers over another element.
const outType = from.type === 'mousemove' ? 'mouseout' : 'pointerout';
const outEvent = this.createPointerEvent(from, outType, outTarget);
this.dispatchEvent(outEvent, 'pointerout');
if (isMouse) this.dispatchEvent(outEvent, 'mouseout');
// If the pointer exits overTarget and its descendants, then a pointerleave event is also fired. This event
// is dispatched to all ancestors that no longer capture the pointer.
if (!e.composedPath().includes(outTarget))
{
const leaveEvent = this.createPointerEvent(from, 'pointerleave', outTarget);
leaveEvent.eventPhase = leaveEvent.AT_TARGET;
while (leaveEvent.target && !e.composedPath().includes(leaveEvent.target))
{
leaveEvent.currentTarget = leaveEvent.target;
this.notifyTarget(leaveEvent);
if (isMouse) this.notifyTarget(leaveEvent, 'mouseleave');
leaveEvent.target = leaveEvent.target.parent;
}
this.freeEvent(leaveEvent);
}
this.freeEvent(outEvent);
}
// Then pointerover
if (outTarget !== e.target)
{
// pointerover always occurs on the new overTarget
const overType = from.type === 'mousemove' ? 'mouseover' : 'pointerover';
const overEvent = this.clonePointerEvent(e, overType);// clone faster
this.dispatchEvent(overEvent, 'pointerover');
if (isMouse) this.dispatchEvent(overEvent, 'mouseover');
// Probe whether the newly hovered DisplayObject is an ancestor of the original overTarget.
let overTargetAncestor = outTarget?.parent;
while (overTargetAncestor && overTargetAncestor !== this.rootTarget.parent)
{
if (overTargetAncestor === e.target) break;
overTargetAncestor = overTargetAncestor.parent;
}
// The pointer has entered a non-ancestor of the original overTarget. This means we need a pointerentered
// event.
const didPointerEnter = !overTargetAncestor || overTargetAncestor === this.rootTarget.parent;
if (didPointerEnter)
{
const enterEvent = this.clonePointerEvent(e, 'pointerenter');
enterEvent.eventPhase = enterEvent.AT_TARGET;
while (enterEvent.target
&& enterEvent.target !== outTarget
&& enterEvent.target !== this.rootTarget.parent)
{
enterEvent.currentTarget = enterEvent.target;
this.notifyTarget(enterEvent);
if (isMouse) this.notifyTarget(enterEvent, 'mouseenter');
enterEvent.target = enterEvent.target.parent;
}
this.freeEvent(enterEvent);
}
this.freeEvent(overEvent);
}
const propagationMethod = this.moveOnAll ? 'all' : 'dispatchEvent';
// Then pointermove
this[propagationMethod](e, 'pointermove');
if (e.pointerType === 'touch') this[propagationMethod](e, 'touchmove');
if (isMouse)
{
this[propagationMethod](e, 'mousemove');
this.cursor = e.target?.cursor;
}
trackingData.overTargets = e.composedPath();
this.freeEvent(e);
}
/**
* Maps the upstream `pointerover` to downstream `pointerover` and `pointerenter` events, in that order.
*
* The tracking data for the specific pointer gets a new `overTarget`.
* @param from - The upstream `pointerover` event.
*/
protected mapPointerOver(from: FederatedEvent): void
{
if (!(from instanceof FederatedPointerEvent))
{
console.warn('EventBoundary cannot map a non-pointer event as a pointer event');
return;
}
const trackingData = this.trackingData(from.pointerId);
const e = this.createPointerEvent(from);
const isMouse = e.pointerType === 'mouse' || e.pointerType === 'pen';
this.dispatchEvent(e, 'pointerover');
if (isMouse) this.dispatchEvent(e, 'mouseover');
if (e.pointerType === 'mouse') this.cursor = e.target?.cursor;
// pointerenter events must be fired since the pointer entered from upstream.
const enterEvent = this.clonePointerEvent(e, 'pointerenter');
enterEvent.eventPhase = enterEvent.AT_TARGET;
while (enterEvent.target && enterEvent.target !== this.rootTarget.parent)
{
enterEvent.currentTarget = enterEvent.target;
this.notifyTarget(enterEvent);
if (isMouse) this.notifyTarget(enterEvent, 'mouseenter');
enterEvent.target = enterEvent.target.parent;
}
trackingData.overTargets = e.composedPath();
this.freeEvent(e);
this.freeEvent(enterEvent);
}
/**
* Maps the upstream `pointerout` to downstream `pointerout`, `pointerleave` events, in that order.
*
* The tracking data for the specific pointer is cleared of a `overTarget`.
* @param from - The upstream `pointerout` event.
*/
protected mapPointerOut(from: FederatedEvent): void
{
if (!(from instanceof FederatedPointerEvent))
{
console.warn('EventBoundary cannot map a non-pointer event as a pointer event');
return;
}
const trackingData = this.trackingData(from.pointerId);
if (trackingData.overTargets)
{
const isMouse = from.pointerType === 'mouse' || from.pointerType === 'pen';
const outTarget = this.findMountedTarget(trackingData.overTargets);
// pointerout first
const outEvent = this.createPointerEvent(from, 'pointerout', outTarget);
this.dispatchEvent(outEvent);
if (isMouse) this.dispatchEvent(outEvent, 'mouseout');
// pointerleave(s) are also dispatched b/c the pointer must've left rootTarget and its descendants to
// get an upstream pointerout event (upstream events do not know rootTarget has descendants).
const leaveEvent = this.createPointerEvent(from, 'pointerleave', outTarget);
leaveEvent.eventPhase = leaveEvent.AT_TARGET;
while (leaveEvent.target && leaveEvent.target !== this.rootTarget.parent)
{
leaveEvent.currentTarget = leaveEvent.target;
this.notifyTarget(leaveEvent);
if (isMouse) this.notifyTarget(leaveEvent, 'mouseleave');
leaveEvent.target = leaveEvent.target.parent;
}
trackingData.overTargets = null;
this.freeEvent(outEvent);
this.freeEvent(leaveEvent);
}
this.cursor = null;
}
/**
* Maps the upstream `pointerup` event to downstream `pointerup`, `pointerupoutside`, and `click`/`pointertap` events,
* in that order.
*
* The `pointerupoutside` event bubbles from the original `pointerdown` target to the most specific
* ancestor of the `pointerdown` and `pointerup` targets, which is also the `click` event's target. `touchend`,
* `rightup`, `mouseup`, `touchendoutside`, `rightupoutside`, `mouseupoutside`, and `tap` are fired as well for
* specific pointer types.
* @param from - The upstream `pointerup` event.
*/
protected mapPointerUp(from: FederatedEvent): void
{
if (!(from instanceof FederatedPointerEvent))
{
console.warn('EventBoundary cannot map a non-pointer event as a pointer event');
return;
}
const now = performance.now();
const e = this.createPointerEvent(from);
this.dispatchEvent(e, 'pointerup');
if (e.pointerType === 'touch')
{
this.dispatchEvent(e, 'touchend');
}
else if (e.pointerType === 'mouse' || e.pointerType === 'pen')
{
const isRightButton = e.button === 2;
this.dispatchEvent(e, isRightButton ? 'rightup' : 'mouseup');
}
const trackingData = this.trackingData(from.pointerId);
const pressTarget = this.findMountedTarget(trackingData.pressTargetsByButton[from.button]);
let clickTarget = pressTarget;
// pointerupoutside only bubbles. It only bubbles upto the parent that doesn't contain
// the pointerup location.
if (pressTarget && !e.composedPath().includes(pressTarget))
{
let currentTarget = pressTarget;
while (currentTarget && !e.composedPath().includes(currentTarget))
{
e.currentTarget = currentTarget;
this.notifyTarget(e, 'pointerupoutside');
if (e.pointerType === 'touch')
{
this.notifyTarget(e, 'touchendoutside');
}
else if (e.pointerType === 'mouse' || e.pointerType === 'pen')
{
const isRightButton = e.button === 2;
this.notifyTarget(e, isRightButton ? 'rightupoutside' : 'mouseupoutside');
}
currentTarget = currentTarget.parent;
}
delete trackingData.pressTargetsByButton[from.button];
// currentTarget is the most specific ancestor holding both the pointerdown and pointerup
// targets. That is - it's our click target!
clickTarget = currentTarget;
}
// click!
if (clickTarget)
{
const clickEvent = this.clonePointerEvent(e, 'click');
clickEvent.target = clickTarget;
clickEvent.path = null;
if (!trackingData.clicksByButton[from.button])
{
trackingData.clicksByButton[from.button] = {
clickCount: 0,
target: clickEvent.target,
timeStamp: now,
};
}
const clickHistory = trackingData.clicksByButton[from.button];
if (clickHistory.target === clickEvent.target
&& now - clickHistory.timeStamp < 200)
{
++clickHistory.clickCount;
}
else
{
clickHistory.clickCount = 1;
}
clickHistory.target = clickEvent.target;
clickHistory.timeStamp = now;
clickEvent.detail = clickHistory.clickCount;
if (clickEvent.pointerType === 'mouse')
{
this.dispatchEvent(clickEvent, 'click');
}
else if (clickEvent.pointerType === 'touch')
{
this.dispatchEvent(clickEvent, 'tap');
}
this.dispatchEvent(clickEvent, 'pointertap');
this.freeEvent(clickEvent);
}
this.freeEvent(e);
}
/**
* Maps the upstream `pointerupoutside` event to a downstream `pointerupoutside` event, bubbling from the original
* `pointerdown` target to `rootTarget`.
*
* (The most specific ancestor of the `pointerdown` event and the `pointerup` event must the {@code EventBoundary}'s
* root because the `pointerup` event occurred outside of the boundary.)
*
* `touchendoutside`, `mouseupoutside`, and `rightupoutside` events are fired as well for specific pointer
* types. The tracking data for the specific pointer is cleared of a `pressTarget`.
* @param from - The upstream `pointerupoutside` event.
*/
protected mapPointerUpOutside(from: FederatedEvent): void
{
if (!(from instanceof FederatedPointerEvent))
{
console.warn('EventBoundary cannot map a non-pointer event as a pointer event');
return;
}
const trackingData = this.trackingData(from.pointerId);
const pressTarget = this.findMountedTarget(trackingData.pressTargetsByButton[from.button]);
const e = this.createPointerEvent(from);
if (pressTarget)
{
let currentTarget = pressTarget;
while (currentTarget)
{
e.currentTarget = currentTarget;
this.notifyTarget(e, 'pointerupoutside');
if (e.pointerType === 'touch')
{
this.notifyTarget(e, 'touchendoutside');
}
else if (e.pointerType === 'mouse' || e.pointerType === 'pen')
{
this.notifyTarget(e, e.button === 2 ? 'rightupoutside' : 'mouseupoutside');
}
currentTarget = currentTarget.parent;
}
delete trackingData.pressTargetsByButton[from.button];
}
this.freeEvent(e);
}
/**
* Maps the upstream `wheel` event to a downstream `wheel` event.
* @param from - The upstream `wheel` event.
*/
protected mapWheel(from: FederatedEvent): void
{
if (!(from instanceof FederatedWheelEvent))
{
console.warn('EventBoundary cannot map a non-wheel event as a wheel event');
return;
}
const wheelEvent = this.createWheelEvent(from);
this.dispatchEvent(wheelEvent);
this.freeEvent(wheelEvent);
}
/**
* Finds the most specific event-target in the given propagation path that is still mounted in the scene graph.
*
* This is used to find the correct `pointerup` and `pointerout` target in the case that the original `pointerdown`
* or `pointerover` target was unmounted from the scene graph.
* @param propagationPath - The propagation path was valid in the past.
* @returns - The most specific event-target still mounted at the same location in the scene graph.
*/
protected findMountedTarget(propagationPath: FederatedEventTarget[]): FederatedEventTarget
{
if (!propagationPath)
{
return null;
}
let currentTarget = propagationPath[0];
for (let i = 1; i < propagationPath.length; i++)
{
// Set currentTarget to the next target in the path only if it is still attached to the
// scene graph (i.e. parent still points to the expected ancestor).
if (propagationPath[i].parent === currentTarget)
{
currentTarget = propagationPath[i];
}
else
{
break;
}
}
return currentTarget;
}
/**
* Creates an event whose {@code originalEvent} is {@code from}, with an optional `type` and `target` override.
*
* The event is allocated using {@link PIXI.EventBoundary#allocateEvent this.allocateEvent}.
* @param from - The {@code originalEvent} for the returned event.
* @param [type=from.type] - The type of the returned event.
* @param target - The target of the returned event.
*/
protected createPointerEvent(
from: FederatedPointerEvent,
type?: string,
target?: FederatedEventTarget
): FederatedPointerEvent
{
const event = this.allocateEvent(FederatedPointerEvent);
this.copyPointerData(from, event);
this.copyMouseData(from, event);
this.copyData(from, event);
event.nativeEvent = from.nativeEvent;
event.originalEvent = from;
event.target = target ?? this.hitTest(event.global.x, event.global.y) as FederatedEventTarget;
if (typeof type === 'string')
{
event.type = type;
}
return event;
}
/**
* Creates a wheel event whose {@code originalEvent} is {@code from}.
*
* The event is allocated using {@link PIXI.EventBoundary#allocateEvent this.allocateEvent}.
* @param from - The upstream wheel event.
*/
protected createWheelEvent(from: FederatedWheelEvent): FederatedWheelEvent
{
const event = this.allocateEvent(FederatedWheelEvent);
this.copyWheelData(from, event);
this.copyMouseData(from, event);
this.copyData(from, event);
event.nativeEvent = from.nativeEvent;
event.originalEvent = from;
event.target = this.hitTest(event.global.x, event.global.y);
return event;
}
/**
* Clones the event {@code from}, with an optional {@code type} override.
*
* The event is allocated using {@link PIXI.EventBoundary#allocateEvent this.allocateEvent}.
* @param from - The event to clone.
* @param [type=from.type] - The type of the returned event.
*/
protected clonePointerEvent(from: FederatedPointerEvent, type?: string): FederatedPointerEvent
{
const event = this.allocateEvent(FederatedPointerEvent);
event.nativeEvent = from.nativeEvent;
event.originalEvent = from.originalEvent;
this.copyPointerData(from, event);
this.copyMouseData(from, event);
this.copyData(from, event);
// copy propagation path for perf
event.target = from.target;
event.path = from.composedPath().slice();
event.type = type ?? event.type;
return event;
}
/**
* Copies wheel {@link PIXI.FederatedWheelEvent} data from {@code from} into {@code to}.
*
* The following properties are copied:
* + deltaMode
* + deltaX
* + deltaY
* + deltaZ
* @param from
* @param to
*/
protected copyWheelData(from: FederatedWheelEvent, to: FederatedWheelEvent): void
{
to.deltaMode = from.deltaMode;
to.deltaX = from.deltaX;
to.deltaY = from.deltaY;
to.deltaZ = from.deltaZ;
}
/**
* Copies pointer {@link PIXI.FederatedPointerEvent} data from {@code from} into {@code to}.
*
* The following properties are copied:
* + pointerId
* + width
* + height
* + isPrimary
* + pointerType
* + pressure
* + tangentialPressure
* + tiltX
* + tiltY
* @param from
* @param to
*/
protected copyPointerData(from: FederatedEvent, to: FederatedEvent): void
{
if (!(from instanceof FederatedPointerEvent && to instanceof FederatedPointerEvent)) return;
to.pointerId = from.pointerId;
to.width = from.width;
to.height = from.height;
to.isPrimary = from.isPrimary;
to.pointerType = from.pointerType;
to.pressure = from.pressure;
to.tangentialPressure = from.tangentialPressure;
to.tiltX = from.tiltX;
to.tiltY = from.tiltY;
to.twist = from.twist;
}
/**
* Copies mouse {@link PIXI.FederatedMouseEvent} data from {@code from} to {@code to}.
*
* The following properties are copied:
* + altKey
* + button
* + buttons
* + clientX
* + clientY
* + metaKey
* + movementX
* + movementY
* + pageX
* + pageY
* + x
* + y
* + screen
* + global
* @param from
* @param to
*/
protected copyMouseData(from: FederatedEvent, to: FederatedEvent): void
{
if (!(from instanceof FederatedMouseEvent && to instanceof FederatedMouseEvent)) return;
to.altKey = from.altKey;
to.button = from.button;
to.buttons = from.buttons;
to.client.copyFrom(from.client);
to.ctrlKey = from.ctrlKey;
to.metaKey = from.metaKey;
to.movement.copyFrom(from.movement);
to.screen.copyFrom(from.screen);
to.global.copyFrom(from.global);
}
/**
* Copies base {@link PIXI.FederatedEvent} data from {@code from} into {@code to}.
*
* The following properties are copied:
* + isTrusted
* + srcElement
* + timeStamp
* + type
* @param from - The event to copy data from.
* @param to - The event to copy data into.
*/
protected copyData(from: FederatedEvent, to: FederatedEvent): void
{
to.isTrusted = from.isTrusted;
to.srcElement = from.srcElement;
to.timeStamp = performance.now();
to.type = from.type;
to.detail = from.detail;
to.view = from.view;
to.which = from.which;
to.layer.copyFrom(from.layer);
to.page.copyFrom(from.page);
}
/**
* @param id - The pointer ID.
* @returns The tracking data stored for the given pointer. If no data exists, a blank
* state will be created.
*/
protected trackingData(id: number): TrackingData
{
if (!this.mappingState.trackingData[id])
{
this.mappingState.trackingData[id] = {
pressTargetsByButton: {},
clicksByButton: {},
overTarget: null
};
}
return this.mappingState.trackingData[id];
}
/**
* Allocate a specific type of event from {@link PIXI.EventBoundary#eventPool this.eventPool}.
*
* This allocation is constructor-agnostic, as long as it only takes one argument - this event
* boundary.
* @param constructor - The event's constructor.
*/
protected allocateEvent<T extends FederatedEvent>(
constructor: { new(boundary: EventBoundary): T }
): T
{
if (!this.eventPool.has(constructor as any))
{
this.eventPool.set(constructor as any, []);
}
const event = this.eventPool.get(constructor as any).pop() as T
|| new constructor(this);
event.eventPhase = event.NONE;
event.currentTarget = null;
event.path = null;
event.target = null;
return event;
}
/**
* Frees the event and puts it back into the event pool.
*
* It is illegal to reuse the event until it is allocated again, using `this.allocateEvent`.
*
* It is also advised that events not allocated from {@link PIXI.EventBoundary#allocateEvent this.allocateEvent}
* not be freed. This is because of the possibility that the same event is freed twice, which can cause
* it to be allocated twice & result in overwriting.
* @param event - The event to be freed.
* @throws Error if the event is managed by another event boundary.
*/
protected freeEvent<T extends FederatedEvent>(event: T): void
{
if (event.manager !== this) throw new Error('It is illegal to free an event not managed by this EventBoundary!');
const constructor = event.constructor;
if (!this.eventPool.has(constructor as any))
{
this.eventPool.set(constructor as any, []);
}
this.eventPool.get(constructor as any).push(event);
}
/**
* Similar to {@link EventEmitter.emit}, except it stops if the `propagationImmediatelyStopped` flag
* is set on the event.
* @param e - The event to call each listener with.
* @param type - The event key.
*/
private notifyListeners(e: FederatedEvent, type: string): void
{
const listeners = ((e.currentTarget as any)._events as EmitterListeners)[type];
if (!listeners) return;
if ('fn' in listeners)
{
listeners.fn.call(listeners.context, e);
}
else
{
for (
let i = 0, j = listeners.length;
i < j && !e.propagationImmediatelyStopped;
i++)
{
listeners[i].fn.call(listeners[i].context, e);
}
}
}
}
/**
* Fired when a mouse button (usually a mouse left-button) is pressed on the display.
* object. DisplayObject's `interactive` property must be set to `true` to fire event.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#mousedown
* @param {PIXI.FederatedPointerEvent} event - The mousedown event.
*/
/**
* Capture phase equivalent of {@code mousedown}.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#mousedowncapture
* @param {PIXI.FederatedPointerEvent} event - The capture phase mousedown.
*/
/**
* Fired when a pointer device secondary button (usually a mouse right-button) is pressed
* on the display object. DisplayObject's `interactive` property must be set to `true` to fire event.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#rightdown
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Capture phase equivalent of {@code rightdown}.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#rightdowncapture
* @param {PIXI.FederatedPointerEvent} event - The rightdowncapture event.
*/
/**
* Fired when a pointer device button (usually a mouse left-button) is released over the display
* object. DisplayObject's `interactive` property must be set to `true` to fire event.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#mouseup
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Capture phase equivalent of {@code mouseup}.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#mouseupcature
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Fired when a pointer device secondary button (usually a mouse right-button) is released
* over the display object. DisplayObject's `interactive` property must be set to `true` to fire event.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#rightup
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Capture phase equivalent of {@code rightup}.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#rightupcapture
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Fired when a pointer device button (usually a mouse left-button) is pressed and released on
* the display object. DisplayObject's `interactive` property must be set to `true` to fire event.
*
* A {@code click} event fires after the {@code pointerdown} and {@code pointerup} events, in that
* order. If the mouse is moved over another DisplayObject after the {@code pointerdown} event, the
* {@code click} event is fired on the most specific common ancestor of the two target DisplayObjects.
*
* The {@code detail} property of the event is the number of clicks that occurred within a 200ms
* window of each other upto the current click. For example, it will be {@code 2} for a double click.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#click
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Capture phase equivalent of {@code click}.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#clickcapture
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Fired when a pointer device secondary button (usually a mouse right-button) is pressed
* and released on the display object. DisplayObject's `interactive` property must be set to `true` to fire event.
*
* This event follows the semantics of {@code click}.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#rightclick
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Capture phase equivalent of {@code rightclick}.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#rightclickcapture
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Fired when a pointer device button (usually a mouse left-button) is released outside the
* display object that initially registered a
* [mousedown]{@link PIXI.DisplayObject#event:mousedown}.
* DisplayObject's `interactive` property must be set to `true` to fire event.
*
* This event is specific to the Federated Events API. It does not have a capture phase, unlike most of the
* other events. It only bubbles to the most specific ancestor of the targets of the corresponding {@code pointerdown}
* and {@code pointerup} events, i.e. the target of the {@code click} event.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#mouseupoutside
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Capture phase equivalent of {@code mouseupoutside}.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#mouseupoutsidecapture
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Fired when a pointer device secondary button (usually a mouse right-button) is released
* outside the display object that initially registered a
* [rightdown]{@link PIXI.DisplayObject#event:rightdown}.
* DisplayObject's `interactive` property must be set to `true` to fire event.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#rightupoutside
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Capture phase equivalent of {@code rightupoutside}.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#rightupoutsidecapture
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Fired when a pointer device (usually a mouse) is moved while over the display object.
* DisplayObject's `interactive` property must be set to `true` to fire event.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#mousemove
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Capture phase equivalent of {@code mousemove}.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#mousemovecature
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Fired when a pointer device (usually a mouse) is moved onto the display object.
* DisplayObject's `interactive` property must be set to `true` to fire event.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#mouseover
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Capture phase equivalent of {@code mouseover}.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#mouseovercapture
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Fired when the mouse pointer is moved over a DisplayObject and its descendant's hit testing boundaries.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#mouseenter
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Capture phase equivalent of {@code mouseenter}
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#mouseentercapture
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Fired when a pointer device (usually a mouse) is moved off the display object.
* DisplayObject's `interactive` property must be set to `true` to fire event.
*
* This may be fired on a DisplayObject that was removed from the scene graph immediately after
* a {@code mouseover} event.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#mouseout
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Capture phase equivalent of {@code mouseout}.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#mouseoutcapture
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Fired when the mouse pointer exits a DisplayObject and its descendants.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#mouseleave
* @param {PIXI.FederatedPointerEvent} event
*/
/**
* Capture phase equivalent of {@code mouseleave}.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#mouseleavecapture
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Fired when a pointer device button is pressed on the display object.
* DisplayObject's `interactive` property must be set to `true` to fire event.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#pointerdown
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Capture phase equivalent of {@code pointerdown}.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#pointerdowncapture
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Fired when a pointer device button is released over the display object.
* DisplayObject's `interactive` property must be set to `true` to fire event.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#pointerup
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Capture phase equivalent of {@code pointerup}.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#pointerupcapture
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Fired when the operating system cancels a pointer event.
* DisplayObject's `interactive` property must be set to `true` to fire event.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#pointercancel
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Capture phase equivalent of {@code pointercancel}.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#pointercancelcapture
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Fired when a pointer device button is pressed and released on the display object.
* DisplayObject's `interactive` property must be set to `true` to fire event.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#pointertap
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Capture phase equivalent of {@code pointertap}.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#pointertapcapture
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Fired when a pointer device button is released outside the display object that initially
* registered a [pointerdown]{@link PIXI.DisplayObject#event:pointerdown}.
* DisplayObject's `interactive` property must be set to `true` to fire event.
*
* This event is specific to the Federated Events API. It does not have a capture phase, unlike most of the
* other events. It only bubbles to the most specific ancestor of the targets of the corresponding {@code pointerdown}
* and {@code pointerup} events, i.e. the target of the {@code click} event.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#pointerupoutside
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Capture phase equivalent of {@code pointerupoutside}.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#pointerupoutsidecapture
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Fired when a pointer device is moved while over the display object.
* DisplayObject's `interactive` property must be set to `true` to fire event.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#pointermove
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Capture phase equivalent of {@code pointermove}.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#pointermovecapture
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Fired when a pointer device is moved onto the display object.
* DisplayObject's `interactive` property must be set to `true` to fire event.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#pointerover
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Capture phase equivalent of {@code pointerover}.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#pointerovercapture
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Fired when the pointer is moved over a DisplayObject and its descendant's hit testing boundaries.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#pointerenter
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Capture phase equivalent of {@code pointerenter}
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#pointerentercapture
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Fired when a pointer device is moved off the display object.
* DisplayObject's `interactive` property must be set to `true` to fire event.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#pointerout
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Capture phase equivalent of {@code pointerout}.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#pointeroutcapture
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Fired when the pointer leaves the hit testing boundaries of a DisplayObject and its descendants.
*
* This event notifies only the target and does not bubble.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#pointerleave
* @param {PIXI.FederatedPointerEvent} event - The `pointerleave` event.
*/
/**
* Capture phase equivalent of {@code pointerleave}.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#pointerleavecapture
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Fired when a touch point is placed on the display object.
* DisplayObject's `interactive` property must be set to `true` to fire event.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#touchstart
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Capture phase equivalent of {@code touchstart}.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#touchstartcapture
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Fired when a touch point is removed from the display object.
* DisplayObject's `interactive` property must be set to `true` to fire event.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#touchend
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Capture phase equivalent of {@code touchend}.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#touchendcapture
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Fired when the operating system cancels a touch.
* DisplayObject's `interactive` property must be set to `true` to fire event.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#touchcancel
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Capture phase equivalent of {@code touchcancel}.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#touchcancelcapture
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Fired when a touch point is placed and removed from the display object.
* DisplayObject's `interactive` property must be set to `true` to fire event.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#tap
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Capture phase equivalent of {@code tap}.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#tapcapture
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Fired when a touch point is removed outside of the display object that initially
* registered a [touchstart]{@link PIXI.DisplayObject#event:touchstart}.
* DisplayObject's `interactive` property must be set to `true` to fire event.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#touchendoutside
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Capture phase equivalent of {@code touchendoutside}.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#touchendoutsidecapture
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Fired when a touch point is moved along the display object.
* DisplayObject's `interactive` property must be set to `true` to fire event.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#touchmove
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Capture phase equivalent of {@code touchmove}.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#touchmovecapture
* @param {PIXI.FederatedPointerEvent} event - Event
*/
/**
* Fired when a the user scrolls with the mouse cursor over a DisplayObject.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#wheel
* @type {PIXI.FederatedWheelEvent}
*/
/**
* Capture phase equivalent of {@code wheel}.
*
* These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events.
* @event PIXI.DisplayObject#wheelcapture
* @type {PIXI.FederatedWheelEvent}
*/