Skip to content

Commit 9b192b1

Browse files
Hannes KruseHannes Kruse
authored andcommitted
Merge branch 'release/v1.0.2'
2 parents 44118e4 + 28536f0 commit 9b192b1

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tasty.js",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"description": "A Pie- and Marking-Menu Framework written in TypeScript.",
55
"scripts": {
66
"type-check": "tsc --noEmit",

src/lib/menu/menu.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ export default class Menu implements MenuData {
149149
this.inputActivation$ = new Subject<Input>();
150150
this.inputDeactivation$ = new Subject<Input>();
151151
this.inputPosition$ = new Subject<Point>();
152-
153152
this._dragging$ = new Subject<DragDefinition>();
154153
this._click$ = new Subject<ClickState>();
155154
}
@@ -270,10 +269,11 @@ export default class Menu implements MenuData {
270269
/**
271270
* Displays the menu on the last input position
272271
*
272+
* @param {Point} position Optional menu display position in px
273273
* @throws {Error} If menu hast not been initialized
274274
* @see {init}
275275
*/
276-
public display(): void {
276+
public display(position:Point = null): void {
277277
if (this._rootItem === undefined) {
278278
throw new Error(`Menu not initialized.`);
279279
}
@@ -287,7 +287,23 @@ export default class Menu implements MenuData {
287287
this._fadeAnimation.start();
288288
this._rootItem.state = ItemState.ACTIVE;
289289
this._rootItem.redraw();
290-
this._rootItem.position = this.inputPosition;
290+
if (position === null) {
291+
this._rootItem.position = this.inputPosition;
292+
} else {
293+
this._rootItem.position = position;
294+
}
295+
}
296+
}
297+
298+
public hide(): void {
299+
if (this._rootItem === undefined) {
300+
throw new Error(`Menu not initialized.`);
301+
}
302+
303+
if (this._rootItem.state !== ItemState.HIDDEN) {
304+
this._rootItem.visible = false;
305+
this._rootItem.state = ItemState.HIDDEN;
306+
this._rootItem.redraw();
291307
}
292308
}
293309

0 commit comments

Comments
 (0)