custom-electron-titlebar 3.2.6 → 3.2.10
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/.github/FUNDING.yml +1 -0
- package/README.md +15 -24
- package/_config.yml +1 -0
- package/{lib → build}/browser/browser.d.ts +0 -0
- package/{lib → build}/browser/browser.js +0 -0
- package/{lib → build}/browser/browser.js.map +0 -0
- package/{lib → build}/browser/event.d.ts +0 -0
- package/{lib → build}/browser/event.js +2 -1
- package/{lib → build}/browser/event.js.map +1 -1
- package/{lib → build}/browser/iframe.d.ts +0 -0
- package/{lib → build}/browser/iframe.js +0 -0
- package/{lib → build}/browser/iframe.js.map +0 -0
- package/{lib → build}/browser/keyboardEvent.d.ts +0 -0
- package/{lib → build}/browser/keyboardEvent.js +0 -0
- package/{lib → build}/browser/keyboardEvent.js.map +0 -0
- package/{lib → build}/browser/mouseEvent.d.ts +0 -0
- package/{lib → build}/browser/mouseEvent.js +0 -0
- package/{lib → build}/browser/mouseEvent.js.map +0 -0
- package/{lib → build}/common/arrays.d.ts +0 -0
- package/{lib → build}/common/arrays.js +0 -0
- package/{lib → build}/common/arrays.js.map +0 -0
- package/{lib → build}/common/async.d.ts +0 -0
- package/{lib → build}/common/async.js +0 -0
- package/{lib → build}/common/async.js.map +0 -0
- package/{lib → build}/common/charCode.d.ts +0 -0
- package/{lib → build}/common/charCode.js +0 -0
- package/{lib → build}/common/charCode.js.map +0 -0
- package/{lib → build}/common/color.d.ts +0 -0
- package/{lib → build}/common/color.js +0 -0
- package/{lib → build}/common/color.js.map +0 -0
- package/{lib → build}/common/dom.d.ts +0 -0
- package/{lib → build}/common/dom.js +16 -14
- package/build/common/dom.js.map +1 -0
- package/{lib → build}/common/event.d.ts +0 -0
- package/{lib → build}/common/event.js +1 -1
- package/build/common/event.js.map +1 -0
- package/{lib → build}/common/iterator.d.ts +0 -0
- package/{lib → build}/common/iterator.js +0 -0
- package/{lib → build}/common/iterator.js.map +0 -0
- package/{lib → build}/common/keyCodes.d.ts +0 -0
- package/{lib → build}/common/keyCodes.js +0 -0
- package/{lib → build}/common/keyCodes.js.map +0 -0
- package/{lib → build}/common/lifecycle.d.ts +0 -0
- package/{lib → build}/common/lifecycle.js +0 -0
- package/{lib → build}/common/lifecycle.js.map +0 -0
- package/{lib → build}/common/linkedList.d.ts +0 -0
- package/{lib → build}/common/linkedList.js +0 -0
- package/{lib → build}/common/linkedList.js.map +0 -0
- package/{lib → build}/common/platform.d.ts +0 -0
- package/{lib → build}/common/platform.js +0 -0
- package/{lib → build}/common/platform.js.map +0 -0
- package/{lib → build}/index.d.ts +0 -0
- package/{lib → build}/index.js +0 -0
- package/{lib → build}/index.js.map +0 -0
- package/{lib → build}/menu/menu.d.ts +0 -0
- package/{lib → build}/menu/menu.js +38 -38
- package/build/menu/menu.js.map +1 -0
- package/{lib → build}/menu/menuitem.d.ts +10 -2
- package/{lib → build}/menu/menuitem.js +70 -34
- package/build/menu/menuitem.js.map +1 -0
- package/{lib → build}/menubar.d.ts +0 -0
- package/{lib → build}/menubar.js +29 -30
- package/build/menubar.js.map +1 -0
- package/{lib → build}/themebar.d.ts +0 -0
- package/{lib → build}/themebar.js +2 -2
- package/build/themebar.js.map +1 -0
- package/{lib → build}/titlebar.d.ts +0 -0
- package/{lib → build}/titlebar.js +61 -58
- package/build/titlebar.js.map +1 -0
- package/package.json +13 -7
- package/lib/common/dom.js.map +0 -1
- package/lib/common/enableNativeMenuCommands.d.ts +0 -1
- package/lib/common/enableNativeMenuCommands.js +0 -32
- package/lib/common/enableNativeMenuCommands.js.map +0 -1
- package/lib/common/event.js.map +0 -1
- package/lib/main.d.ts +0 -1
- package/lib/main.js +0 -14
- package/lib/main.js.map +0 -1
- package/lib/menu/menu.js.map +0 -1
- package/lib/menu/menuitem.js.map +0 -1
- package/lib/menubar.js.map +0 -1
- package/lib/themebar.js.map +0 -1
- package/lib/titlebar.js.map +0 -1
- package/lib/vs/base/browser/browser.js +0 -150
- package/lib/vs/base/browser/canIUse.js +0 -58
- package/lib/vs/base/browser/codicons.js +0 -37
- package/lib/vs/base/browser/contextmenu.js +0 -9
- package/lib/vs/base/browser/dnd.js +0 -113
- package/lib/vs/base/browser/dom.js +0 -1417
- package/lib/vs/base/browser/event.js +0 -36
- package/lib/vs/base/browser/fastDomNode.js +0 -265
- package/lib/vs/base/browser/formattedTextRenderer.js +0 -248
- package/lib/vs/base/browser/globalMouseMoveMonitor.js +0 -137
- package/lib/vs/base/browser/history.js +0 -9
- package/lib/vs/base/browser/iframe.js +0 -126
- package/lib/vs/base/browser/keyboardEvent.js +0 -599
- package/lib/vs/base/browser/mouseEvent.js +0 -155
- package/lib/vs/base/browser/touch.js +0 -315
- package/lib/vs/base/browser/ui/actionbar/actionViewItems.js +0 -397
- package/lib/vs/base/browser/ui/actionbar/actionbar.js +0 -583
- package/lib/vs/base/browser/ui/checkbox/checkbox.js +0 -251
- package/lib/vs/base/browser/ui/codicons/codiconLabel.js +0 -31
- package/lib/vs/base/browser/ui/codicons/codiconStyles.js +0 -47
- package/lib/vs/base/browser/ui/contextview/contextview.js +0 -367
- package/lib/vs/base/browser/ui/dropdown/dropdown.js +0 -256
- package/lib/vs/base/browser/ui/dropdown/dropdownActionViewItem.js +0 -120
- package/lib/vs/base/browser/ui/keybindingLabel/keybindingLabel.js +0 -118
- package/lib/vs/base/browser/ui/list/list.js +0 -54
- package/lib/vs/base/browser/ui/list/listPaging.js +0 -322
- package/lib/vs/base/browser/ui/list/listView.js +0 -1388
- package/lib/vs/base/browser/ui/list/listWidget.js +0 -1709
- package/lib/vs/base/browser/ui/list/rangeMap.js +0 -223
- package/lib/vs/base/browser/ui/list/rowCache.js +0 -113
- package/lib/vs/base/browser/ui/list/splice.js +0 -23
- package/lib/vs/base/browser/ui/menu/menu.js +0 -1371
- package/lib/vs/base/browser/ui/menu/menubar.js +0 -1139
- package/lib/vs/base/browser/ui/scrollbar/abstractScrollbar.js +0 -278
- package/lib/vs/base/browser/ui/scrollbar/horizontalScrollbar.js +0 -115
- package/lib/vs/base/browser/ui/scrollbar/scrollableElement.js +0 -646
- package/lib/vs/base/browser/ui/scrollbar/scrollableElementOptions.js +0 -9
- package/lib/vs/base/browser/ui/scrollbar/scrollbarArrow.js +0 -106
- package/lib/vs/base/browser/ui/scrollbar/scrollbarState.js +0 -184
- package/lib/vs/base/browser/ui/scrollbar/scrollbarVisibilityController.js +0 -116
- package/lib/vs/base/browser/ui/scrollbar/verticalScrollbar.js +0 -114
- package/lib/vs/base/browser/ui/selectBox/selectBox.js +0 -85
- package/lib/vs/base/browser/ui/selectBox/selectBoxCustom.js +0 -985
- package/lib/vs/base/browser/ui/selectBox/selectBoxNative.js +0 -188
- package/lib/vs/base/browser/ui/toolbar/toolbar.js +0 -206
- package/lib/vs/base/browser/ui/widget.js +0 -69
- package/lib/vs/base/common/actions.js +0 -224
- package/lib/vs/base/common/amd.js +0 -31
- package/lib/vs/base/common/arrays.js +0 -641
- package/lib/vs/base/common/assert.js +0 -21
- package/lib/vs/base/common/async.js +0 -966
- package/lib/vs/base/common/buffer.js +0 -250
- package/lib/vs/base/common/cache.js +0 -40
- package/lib/vs/base/common/cancellation.js +0 -146
- package/lib/vs/base/common/charCode.js +0 -9
- package/lib/vs/base/common/codicon.js +0 -136
- package/lib/vs/base/common/codicons.js +0 -1378
- package/lib/vs/base/common/collections.js +0 -133
- package/lib/vs/base/common/color.js +0 -716
- package/lib/vs/base/common/comparers.js +0 -280
- package/lib/vs/base/common/console.js +0 -142
- package/lib/vs/base/common/date.js +0 -113
- package/lib/vs/base/common/decorators.js +0 -169
- package/lib/vs/base/common/errorMessage.js +0 -93
- package/lib/vs/base/common/errors.js +0 -213
- package/lib/vs/base/common/errorsWithActions.js +0 -28
- package/lib/vs/base/common/event.js +0 -873
- package/lib/vs/base/common/extpath.js +0 -401
- package/lib/vs/base/common/filters.js +0 -948
- package/lib/vs/base/common/functional.js +0 -28
- package/lib/vs/base/common/fuzzyScorer.js +0 -811
- package/lib/vs/base/common/glob.js +0 -696
- package/lib/vs/base/common/hash.js +0 -359
- package/lib/vs/base/common/history.js +0 -116
- package/lib/vs/base/common/htmlContent.js +0 -162
- package/lib/vs/base/common/idGenerator.js +0 -25
- package/lib/vs/base/common/iterator.js +0 -118
- package/lib/vs/base/common/json.js +0 -1624
- package/lib/vs/base/common/jsonEdit.js +0 -272
- package/lib/vs/base/common/jsonErrorMessages.js +0 -69
- package/lib/vs/base/common/jsonFormatter.js +0 -316
- package/lib/vs/base/common/jsonSchema.js +0 -9
- package/lib/vs/base/common/keyCodes.js +0 -591
- package/lib/vs/base/common/keybindingLabels.js +0 -231
- package/lib/vs/base/common/keybindingParser.js +0 -142
- package/lib/vs/base/common/labels.js +0 -430
- package/lib/vs/base/common/lazy.js +0 -71
- package/lib/vs/base/common/lifecycle.js +0 -308
- package/lib/vs/base/common/linkedList.js +0 -152
- package/lib/vs/base/common/linkedText.js +0 -73
- package/lib/vs/base/common/map.js +0 -1108
- package/lib/vs/base/common/marshalling.js +0 -80
- package/lib/vs/base/common/mime.js +0 -321
- package/lib/vs/base/common/navigator.js +0 -50
- package/lib/vs/base/common/network.js +0 -160
- package/lib/vs/base/common/normalization.js +0 -78
- package/lib/vs/base/common/numbers.js +0 -55
- package/lib/vs/base/common/objects.js +0 -268
- package/lib/vs/base/common/paging.js +0 -190
- package/lib/vs/base/common/parsers.js +0 -78
- package/lib/vs/base/common/path.js +0 -1550
- package/lib/vs/base/common/platform.js +0 -245
- package/lib/vs/base/common/process.js +0 -52
- package/lib/vs/base/common/processes.js +0 -32
- package/lib/vs/base/common/range.js +0 -79
- package/lib/vs/base/common/resourceTree.js +0 -185
- package/lib/vs/base/common/resources.js +0 -421
- package/lib/vs/base/common/scanCode.js +0 -1472
- package/lib/vs/base/common/scrollable.js +0 -397
- package/lib/vs/base/common/search.js +0 -55
- package/lib/vs/base/common/sequence.js +0 -64
- package/lib/vs/base/common/severity.js +0 -55
- package/lib/vs/base/common/skipList.js +0 -234
- package/lib/vs/base/common/stopwatch.js +0 -45
- package/lib/vs/base/common/stream.js +0 -418
- package/lib/vs/base/common/strings.js +0 -1283
- package/lib/vs/base/common/styler.js +0 -9
- package/lib/vs/base/common/types.js +0 -296
- package/lib/vs/base/common/uint.js +0 -46
- package/lib/vs/base/common/uri.js +0 -756
- package/lib/vs/base/common/uriIpc.js +0 -154
- package/lib/vs/base/common/uuid.js +0 -70
- package/lib/vs/nls.mock.js +0 -31
- package/lib/vs/platform/actions/browser/menuEntryActionViewItem.js +0 -342
- package/lib/vs/platform/actions/common/actions.js +0 -456
- package/lib/vs/platform/actions/common/menuService.js +0 -194
- package/lib/vs/platform/clipboard/browser/clipboardService.js +0 -99
- package/lib/vs/platform/clipboard/common/clipboardService.js +0 -14
- package/lib/vs/platform/contextkey/common/contextkey.js +0 -1210
- package/lib/vs/platform/contextkey/common/contextkeys.js +0 -23
- package/lib/vs/platform/contextview/browser/contextView.js +0 -15
- package/lib/vs/platform/contextview/browser/contextViewService.js +0 -96
- package/lib/vs/platform/environment/common/argv.js +0 -9
- package/lib/vs/platform/environment/common/environment.js +0 -15
- package/lib/vs/platform/instantiation/common/descriptors.js +0 -25
- package/lib/vs/platform/instantiation/common/extensions.js +0 -26
- package/lib/vs/platform/instantiation/common/graph.js +0 -93
- package/lib/vs/platform/instantiation/common/instantiation.js +0 -84
- package/lib/vs/platform/instantiation/common/instantiationService.js +0 -361
- package/lib/vs/platform/instantiation/common/serviceCollection.js +0 -39
- package/lib/vs/platform/keybinding/common/baseResolvedKeybinding.js +0 -73
- package/lib/vs/platform/keybinding/common/keybinding.js +0 -14
- package/lib/vs/platform/keybinding/common/keybindingResolver.js +0 -391
- package/lib/vs/platform/keybinding/common/keybindingsRegistry.js +0 -229
- package/lib/vs/platform/keybinding/common/resolvedKeybindingItem.js +0 -47
- package/lib/vs/platform/keybinding/common/usLayoutResolvedKeybinding.js +0 -160
- package/lib/vs/platform/layout/browser/layoutService.js +0 -14
- package/lib/vs/platform/menubar/common/menubar.js +0 -34
- package/lib/vs/platform/registry/common/platform.js +0 -38
- package/lib/vs/platform/theme/browser/checkbox.js +0 -32
- package/lib/vs/platform/theme/common/colorRegistry.js +0 -1154
- package/lib/vs/platform/theme/common/styler.js +0 -290
- package/lib/vs/platform/theme/common/theme.js +0 -21
- package/lib/vs/platform/theme/common/themeService.js +0 -176
- package/lib/vs/platform/theme/common/tokenClassificationRegistry.js +0 -540
- package/lib/vs/platform/theme/test/common/testThemeService.js +0 -98
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, "__esModule", {
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
exports.StandardWheelEvent = exports.DragMouseEvent = exports.StandardMouseEvent = void 0;
|
|
11
|
-
|
|
12
|
-
const browser = require("./browser");
|
|
13
|
-
|
|
14
|
-
const iframe_1 = require("./iframe");
|
|
15
|
-
|
|
16
|
-
const platform = require("../common/platform");
|
|
17
|
-
|
|
18
|
-
class StandardMouseEvent {
|
|
19
|
-
constructor(e) {
|
|
20
|
-
this.timestamp = Date.now();
|
|
21
|
-
this.browserEvent = e;
|
|
22
|
-
this.leftButton = e.button === 0;
|
|
23
|
-
this.middleButton = e.button === 1;
|
|
24
|
-
this.rightButton = e.button === 2;
|
|
25
|
-
this.buttons = e.buttons;
|
|
26
|
-
this.target = e.target;
|
|
27
|
-
this.detail = e.detail || 1;
|
|
28
|
-
|
|
29
|
-
if (e.type === 'dblclick') {
|
|
30
|
-
this.detail = 2;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
this.ctrlKey = e.ctrlKey;
|
|
34
|
-
this.shiftKey = e.shiftKey;
|
|
35
|
-
this.altKey = e.altKey;
|
|
36
|
-
this.metaKey = e.metaKey;
|
|
37
|
-
|
|
38
|
-
if (typeof e.pageX === 'number') {
|
|
39
|
-
this.posx = e.pageX;
|
|
40
|
-
this.posy = e.pageY;
|
|
41
|
-
} else {
|
|
42
|
-
// Probably hit by MSGestureEvent
|
|
43
|
-
this.posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
|
|
44
|
-
this.posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
|
|
45
|
-
} // Find the position of the iframe this code is executing in relative to the iframe where the event was captured.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
let iframeOffsets = iframe_1.IframeUtils.getPositionOfChildWindowRelativeToAncestorWindow(self, e.view);
|
|
49
|
-
this.posx -= iframeOffsets.left;
|
|
50
|
-
this.posy -= iframeOffsets.top;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
preventDefault() {
|
|
54
|
-
this.browserEvent.preventDefault();
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
stopPropagation() {
|
|
58
|
-
this.browserEvent.stopPropagation();
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
exports.StandardMouseEvent = StandardMouseEvent;
|
|
64
|
-
|
|
65
|
-
class DragMouseEvent extends StandardMouseEvent {
|
|
66
|
-
constructor(e) {
|
|
67
|
-
super(e);
|
|
68
|
-
this.dataTransfer = e.dataTransfer;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
exports.DragMouseEvent = DragMouseEvent;
|
|
74
|
-
|
|
75
|
-
class StandardWheelEvent {
|
|
76
|
-
constructor(e, deltaX = 0, deltaY = 0) {
|
|
77
|
-
this.browserEvent = e || null;
|
|
78
|
-
this.target = e ? e.target || e.targetNode || e.srcElement : null;
|
|
79
|
-
this.deltaY = deltaY;
|
|
80
|
-
this.deltaX = deltaX;
|
|
81
|
-
|
|
82
|
-
if (e) {
|
|
83
|
-
// Old (deprecated) wheel events
|
|
84
|
-
let e1 = e;
|
|
85
|
-
let e2 = e; // vertical delta scroll
|
|
86
|
-
|
|
87
|
-
if (typeof e1.wheelDeltaY !== 'undefined') {
|
|
88
|
-
this.deltaY = e1.wheelDeltaY / 120;
|
|
89
|
-
} else if (typeof e2.VERTICAL_AXIS !== 'undefined' && e2.axis === e2.VERTICAL_AXIS) {
|
|
90
|
-
this.deltaY = -e2.detail / 3;
|
|
91
|
-
} else if (e.type === 'wheel') {
|
|
92
|
-
// Modern wheel event
|
|
93
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent
|
|
94
|
-
const ev = e;
|
|
95
|
-
|
|
96
|
-
if (ev.deltaMode === ev.DOM_DELTA_LINE) {
|
|
97
|
-
// the deltas are expressed in lines
|
|
98
|
-
if (browser.isFirefox && !platform.isMacintosh) {
|
|
99
|
-
this.deltaY = -e.deltaY / 3;
|
|
100
|
-
} else {
|
|
101
|
-
this.deltaY = -e.deltaY;
|
|
102
|
-
}
|
|
103
|
-
} else {
|
|
104
|
-
this.deltaY = -e.deltaY / 40;
|
|
105
|
-
}
|
|
106
|
-
} // horizontal delta scroll
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
if (typeof e1.wheelDeltaX !== 'undefined') {
|
|
110
|
-
if (browser.isSafari && platform.isWindows) {
|
|
111
|
-
this.deltaX = -(e1.wheelDeltaX / 120);
|
|
112
|
-
} else {
|
|
113
|
-
this.deltaX = e1.wheelDeltaX / 120;
|
|
114
|
-
}
|
|
115
|
-
} else if (typeof e2.HORIZONTAL_AXIS !== 'undefined' && e2.axis === e2.HORIZONTAL_AXIS) {
|
|
116
|
-
this.deltaX = -e.detail / 3;
|
|
117
|
-
} else if (e.type === 'wheel') {
|
|
118
|
-
// Modern wheel event
|
|
119
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent
|
|
120
|
-
const ev = e;
|
|
121
|
-
|
|
122
|
-
if (ev.deltaMode === ev.DOM_DELTA_LINE) {
|
|
123
|
-
// the deltas are expressed in lines
|
|
124
|
-
if (browser.isFirefox && !platform.isMacintosh) {
|
|
125
|
-
this.deltaX = -e.deltaX / 3;
|
|
126
|
-
} else {
|
|
127
|
-
this.deltaX = -e.deltaX;
|
|
128
|
-
}
|
|
129
|
-
} else {
|
|
130
|
-
this.deltaX = -e.deltaX / 40;
|
|
131
|
-
}
|
|
132
|
-
} // Assume a vertical scroll if nothing else worked
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
if (this.deltaY === 0 && this.deltaX === 0 && e.wheelDelta) {
|
|
136
|
-
this.deltaY = e.wheelDelta / 120;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
preventDefault() {
|
|
142
|
-
if (this.browserEvent) {
|
|
143
|
-
this.browserEvent.preventDefault();
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
stopPropagation() {
|
|
148
|
-
if (this.browserEvent) {
|
|
149
|
-
this.browserEvent.stopPropagation();
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
exports.StandardWheelEvent = StandardWheelEvent;
|
|
@@ -1,315 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
|
|
7
|
-
var __decorate = this && this.__decorate || function (decorators, target, key, desc) {
|
|
8
|
-
var c = arguments.length,
|
|
9
|
-
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
10
|
-
d;
|
|
11
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
12
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
Object.defineProperty(exports, "__esModule", {
|
|
16
|
-
value: true
|
|
17
|
-
});
|
|
18
|
-
exports.Gesture = exports.EventType = void 0;
|
|
19
|
-
|
|
20
|
-
const arrays = require("../common/arrays");
|
|
21
|
-
|
|
22
|
-
const lifecycle_1 = require("../common/lifecycle");
|
|
23
|
-
|
|
24
|
-
const DomUtils = require("./dom");
|
|
25
|
-
|
|
26
|
-
const decorators_1 = require("../common/decorators");
|
|
27
|
-
|
|
28
|
-
var EventType;
|
|
29
|
-
|
|
30
|
-
(function (EventType) {
|
|
31
|
-
EventType.Tap = '-monaco-gesturetap';
|
|
32
|
-
EventType.Change = '-monaco-gesturechange';
|
|
33
|
-
EventType.Start = '-monaco-gesturestart';
|
|
34
|
-
EventType.End = '-monaco-gesturesend';
|
|
35
|
-
EventType.Contextmenu = '-monaco-gesturecontextmenu';
|
|
36
|
-
})(EventType = exports.EventType || (exports.EventType = {}));
|
|
37
|
-
|
|
38
|
-
class Gesture extends lifecycle_1.Disposable {
|
|
39
|
-
constructor() {
|
|
40
|
-
super();
|
|
41
|
-
this.dispatched = false;
|
|
42
|
-
this.activeTouches = {};
|
|
43
|
-
this.handle = null;
|
|
44
|
-
this.targets = [];
|
|
45
|
-
this.ignoreTargets = [];
|
|
46
|
-
this._lastSetTapCountTime = 0;
|
|
47
|
-
|
|
48
|
-
this._register(DomUtils.addDisposableListener(document, 'touchstart', e => this.onTouchStart(e), {
|
|
49
|
-
passive: false
|
|
50
|
-
}));
|
|
51
|
-
|
|
52
|
-
this._register(DomUtils.addDisposableListener(document, 'touchend', e => this.onTouchEnd(e)));
|
|
53
|
-
|
|
54
|
-
this._register(DomUtils.addDisposableListener(document, 'touchmove', e => this.onTouchMove(e), {
|
|
55
|
-
passive: false
|
|
56
|
-
}));
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
static addTarget(element) {
|
|
60
|
-
if (!Gesture.isTouchDevice()) {
|
|
61
|
-
return lifecycle_1.Disposable.None;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (!Gesture.INSTANCE) {
|
|
65
|
-
Gesture.INSTANCE = new Gesture();
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
Gesture.INSTANCE.targets.push(element);
|
|
69
|
-
return {
|
|
70
|
-
dispose: () => {
|
|
71
|
-
Gesture.INSTANCE.targets = Gesture.INSTANCE.targets.filter(t => t !== element);
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
static ignoreTarget(element) {
|
|
77
|
-
if (!Gesture.isTouchDevice()) {
|
|
78
|
-
return lifecycle_1.Disposable.None;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (!Gesture.INSTANCE) {
|
|
82
|
-
Gesture.INSTANCE = new Gesture();
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
Gesture.INSTANCE.ignoreTargets.push(element);
|
|
86
|
-
return {
|
|
87
|
-
dispose: () => {
|
|
88
|
-
Gesture.INSTANCE.ignoreTargets = Gesture.INSTANCE.ignoreTargets.filter(t => t !== element);
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
static isTouchDevice() {
|
|
94
|
-
// `'ontouchstart' in window` always evaluates to true with typescript's modern typings. This causes `window` to be
|
|
95
|
-
// `never` later in `window.navigator`. That's why we need the explicit `window as Window` cast
|
|
96
|
-
return 'ontouchstart' in window || navigator.maxTouchPoints > 0 || window.navigator.msMaxTouchPoints > 0;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
dispose() {
|
|
100
|
-
if (this.handle) {
|
|
101
|
-
this.handle.dispose();
|
|
102
|
-
this.handle = null;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
super.dispose();
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
onTouchStart(e) {
|
|
109
|
-
let timestamp = Date.now(); // use Date.now() because on FF e.timeStamp is not epoch based.
|
|
110
|
-
|
|
111
|
-
if (this.handle) {
|
|
112
|
-
this.handle.dispose();
|
|
113
|
-
this.handle = null;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
for (let i = 0, len = e.targetTouches.length; i < len; i++) {
|
|
117
|
-
let touch = e.targetTouches.item(i);
|
|
118
|
-
this.activeTouches[touch.identifier] = {
|
|
119
|
-
id: touch.identifier,
|
|
120
|
-
initialTarget: touch.target,
|
|
121
|
-
initialTimeStamp: timestamp,
|
|
122
|
-
initialPageX: touch.pageX,
|
|
123
|
-
initialPageY: touch.pageY,
|
|
124
|
-
rollingTimestamps: [timestamp],
|
|
125
|
-
rollingPageX: [touch.pageX],
|
|
126
|
-
rollingPageY: [touch.pageY]
|
|
127
|
-
};
|
|
128
|
-
let evt = this.newGestureEvent(EventType.Start, touch.target);
|
|
129
|
-
evt.pageX = touch.pageX;
|
|
130
|
-
evt.pageY = touch.pageY;
|
|
131
|
-
this.dispatchEvent(evt);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
if (this.dispatched) {
|
|
135
|
-
e.preventDefault();
|
|
136
|
-
e.stopPropagation();
|
|
137
|
-
this.dispatched = false;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
onTouchEnd(e) {
|
|
142
|
-
let timestamp = Date.now(); // use Date.now() because on FF e.timeStamp is not epoch based.
|
|
143
|
-
|
|
144
|
-
let activeTouchCount = Object.keys(this.activeTouches).length;
|
|
145
|
-
|
|
146
|
-
for (let i = 0, len = e.changedTouches.length; i < len; i++) {
|
|
147
|
-
let touch = e.changedTouches.item(i);
|
|
148
|
-
|
|
149
|
-
if (!this.activeTouches.hasOwnProperty(String(touch.identifier))) {
|
|
150
|
-
console.warn('move of an UNKNOWN touch', touch);
|
|
151
|
-
continue;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
let data = this.activeTouches[touch.identifier],
|
|
155
|
-
holdTime = Date.now() - data.initialTimeStamp;
|
|
156
|
-
|
|
157
|
-
if (holdTime < Gesture.HOLD_DELAY && Math.abs(data.initialPageX - arrays.tail(data.rollingPageX)) < 30 && Math.abs(data.initialPageY - arrays.tail(data.rollingPageY)) < 30) {
|
|
158
|
-
let evt = this.newGestureEvent(EventType.Tap, data.initialTarget);
|
|
159
|
-
evt.pageX = arrays.tail(data.rollingPageX);
|
|
160
|
-
evt.pageY = arrays.tail(data.rollingPageY);
|
|
161
|
-
this.dispatchEvent(evt);
|
|
162
|
-
} else if (holdTime >= Gesture.HOLD_DELAY && Math.abs(data.initialPageX - arrays.tail(data.rollingPageX)) < 30 && Math.abs(data.initialPageY - arrays.tail(data.rollingPageY)) < 30) {
|
|
163
|
-
let evt = this.newGestureEvent(EventType.Contextmenu, data.initialTarget);
|
|
164
|
-
evt.pageX = arrays.tail(data.rollingPageX);
|
|
165
|
-
evt.pageY = arrays.tail(data.rollingPageY);
|
|
166
|
-
this.dispatchEvent(evt);
|
|
167
|
-
} else if (activeTouchCount === 1) {
|
|
168
|
-
let finalX = arrays.tail(data.rollingPageX);
|
|
169
|
-
let finalY = arrays.tail(data.rollingPageY);
|
|
170
|
-
let deltaT = arrays.tail(data.rollingTimestamps) - data.rollingTimestamps[0];
|
|
171
|
-
let deltaX = finalX - data.rollingPageX[0];
|
|
172
|
-
let deltaY = finalY - data.rollingPageY[0]; // We need to get all the dispatch targets on the start of the inertia event
|
|
173
|
-
|
|
174
|
-
const dispatchTo = this.targets.filter(t => data.initialTarget instanceof Node && t.contains(data.initialTarget));
|
|
175
|
-
this.inertia(dispatchTo, timestamp, // time now
|
|
176
|
-
Math.abs(deltaX) / deltaT, // speed
|
|
177
|
-
deltaX > 0 ? 1 : -1, // x direction
|
|
178
|
-
finalX, // x now
|
|
179
|
-
Math.abs(deltaY) / deltaT, // y speed
|
|
180
|
-
deltaY > 0 ? 1 : -1, // y direction
|
|
181
|
-
finalY // y now
|
|
182
|
-
);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
this.dispatchEvent(this.newGestureEvent(EventType.End, data.initialTarget)); // forget about this touch
|
|
186
|
-
|
|
187
|
-
delete this.activeTouches[touch.identifier];
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
if (this.dispatched) {
|
|
191
|
-
e.preventDefault();
|
|
192
|
-
e.stopPropagation();
|
|
193
|
-
this.dispatched = false;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
newGestureEvent(type, initialTarget) {
|
|
198
|
-
let event = document.createEvent('CustomEvent');
|
|
199
|
-
event.initEvent(type, false, true);
|
|
200
|
-
event.initialTarget = initialTarget;
|
|
201
|
-
event.tapCount = 0;
|
|
202
|
-
return event;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
dispatchEvent(event) {
|
|
206
|
-
if (event.type === EventType.Tap) {
|
|
207
|
-
const currentTime = new Date().getTime();
|
|
208
|
-
let setTapCount = 0;
|
|
209
|
-
|
|
210
|
-
if (currentTime - this._lastSetTapCountTime > Gesture.CLEAR_TAP_COUNT_TIME) {
|
|
211
|
-
setTapCount = 1;
|
|
212
|
-
} else {
|
|
213
|
-
setTapCount = 2;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
this._lastSetTapCountTime = currentTime;
|
|
217
|
-
event.tapCount = setTapCount;
|
|
218
|
-
} else if (event.type === EventType.Change || event.type === EventType.Contextmenu) {
|
|
219
|
-
// tap is canceled by scrolling or context menu
|
|
220
|
-
this._lastSetTapCountTime = 0;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
for (let i = 0; i < this.ignoreTargets.length; i++) {
|
|
224
|
-
if (event.initialTarget instanceof Node && this.ignoreTargets[i].contains(event.initialTarget)) {
|
|
225
|
-
return;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
this.targets.forEach(target => {
|
|
230
|
-
if (event.initialTarget instanceof Node && target.contains(event.initialTarget)) {
|
|
231
|
-
target.dispatchEvent(event);
|
|
232
|
-
this.dispatched = true;
|
|
233
|
-
}
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
inertia(dispatchTo, t1, vX, dirX, x, vY, dirY, y) {
|
|
238
|
-
this.handle = DomUtils.scheduleAtNextAnimationFrame(() => {
|
|
239
|
-
let now = Date.now(); // velocity: old speed + accel_over_time
|
|
240
|
-
|
|
241
|
-
let deltaT = now - t1,
|
|
242
|
-
delta_pos_x = 0,
|
|
243
|
-
delta_pos_y = 0,
|
|
244
|
-
stopped = true;
|
|
245
|
-
vX += Gesture.SCROLL_FRICTION * deltaT;
|
|
246
|
-
vY += Gesture.SCROLL_FRICTION * deltaT;
|
|
247
|
-
|
|
248
|
-
if (vX > 0) {
|
|
249
|
-
stopped = false;
|
|
250
|
-
delta_pos_x = dirX * vX * deltaT;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
if (vY > 0) {
|
|
254
|
-
stopped = false;
|
|
255
|
-
delta_pos_y = dirY * vY * deltaT;
|
|
256
|
-
} // dispatch translation event
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
let evt = this.newGestureEvent(EventType.Change);
|
|
260
|
-
evt.translationX = delta_pos_x;
|
|
261
|
-
evt.translationY = delta_pos_y;
|
|
262
|
-
dispatchTo.forEach(d => d.dispatchEvent(evt));
|
|
263
|
-
|
|
264
|
-
if (!stopped) {
|
|
265
|
-
this.inertia(dispatchTo, now, vX, dirX, x + delta_pos_x, vY, dirY, y + delta_pos_y);
|
|
266
|
-
}
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
onTouchMove(e) {
|
|
271
|
-
let timestamp = Date.now(); // use Date.now() because on FF e.timeStamp is not epoch based.
|
|
272
|
-
|
|
273
|
-
for (let i = 0, len = e.changedTouches.length; i < len; i++) {
|
|
274
|
-
let touch = e.changedTouches.item(i);
|
|
275
|
-
|
|
276
|
-
if (!this.activeTouches.hasOwnProperty(String(touch.identifier))) {
|
|
277
|
-
console.warn('end of an UNKNOWN touch', touch);
|
|
278
|
-
continue;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
let data = this.activeTouches[touch.identifier];
|
|
282
|
-
let evt = this.newGestureEvent(EventType.Change, data.initialTarget);
|
|
283
|
-
evt.translationX = touch.pageX - arrays.tail(data.rollingPageX);
|
|
284
|
-
evt.translationY = touch.pageY - arrays.tail(data.rollingPageY);
|
|
285
|
-
evt.pageX = touch.pageX;
|
|
286
|
-
evt.pageY = touch.pageY;
|
|
287
|
-
this.dispatchEvent(evt); // only keep a few data points, to average the final speed
|
|
288
|
-
|
|
289
|
-
if (data.rollingPageX.length > 3) {
|
|
290
|
-
data.rollingPageX.shift();
|
|
291
|
-
data.rollingPageY.shift();
|
|
292
|
-
data.rollingTimestamps.shift();
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
data.rollingPageX.push(touch.pageX);
|
|
296
|
-
data.rollingPageY.push(touch.pageY);
|
|
297
|
-
data.rollingTimestamps.push(timestamp);
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
if (this.dispatched) {
|
|
301
|
-
e.preventDefault();
|
|
302
|
-
e.stopPropagation();
|
|
303
|
-
this.dispatched = false;
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
Gesture.SCROLL_FRICTION = -0.005;
|
|
310
|
-
Gesture.HOLD_DELAY = 700;
|
|
311
|
-
Gesture.CLEAR_TAP_COUNT_TIME = 400; // ms
|
|
312
|
-
|
|
313
|
-
__decorate([decorators_1.memoize], Gesture, "isTouchDevice", null);
|
|
314
|
-
|
|
315
|
-
exports.Gesture = Gesture;
|