@@ -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