From 66408eeec84e7139416592dea08b26386be24531 Mon Sep 17 00:00:00 2001 From: Shivam Dave Date: Tue, 4 Aug 2015 13:41:48 -0700 Subject: [PATCH] [Mobile] Gestures Now to dismiss bubble, touch anywhere the touch will not fire other gestures (such as the pressing of another object). --- .../inspect/src/gestures/InfoButtonGesture.js | 27 ++++++++++++------- .../inspect/src/services/InfoService.js | 11 ++++---- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/platform/commonUI/inspect/src/gestures/InfoButtonGesture.js b/platform/commonUI/inspect/src/gestures/InfoButtonGesture.js index 679daabd51..d128392534 100644 --- a/platform/commonUI/inspect/src/gestures/InfoButtonGesture.js +++ b/platform/commonUI/inspect/src/gestures/InfoButtonGesture.js @@ -39,7 +39,6 @@ define( */ function InfoGestureButton($document, agentService, infoService, element, domainObject) { var dismissBubble, - pendingBubble, touchPosition, scopeOff, body = $document.find('body'); @@ -59,6 +58,7 @@ define( dismissBubble(); dismissBubble = undefined; } + // Detaches body touch listener body.off('touchstart', hideBubble); } @@ -68,17 +68,24 @@ define( // and then on any body touch the bubble is dismissed function showBubble(event) { trackPosition(event); - + // Show the bubble, but on any touchstart on the // body (anywhere) call hidebubble - pendingBubble = - dismissBubble = infoService.display( - "info-table", - domainObject.getModel().name, - domainObject.useCapability('metadata'), - touchPosition - ); - body.on('touchstart', hideBubble); + dismissBubble = infoService.display( + "info-table", + domainObject.getModel().name, + domainObject.useCapability('metadata'), + touchPosition + ); + + // On any touch on the body, default body touches/events + // are prevented, the bubble is dismissed, and the touchstart + // body event is unbound, reallowing gestures + body.on('touchstart', function (event) { + event.preventDefault(); + hideBubble(); + body.unbind('touchstart'); + }); } // Checks if you are on a mobile device, if the device is diff --git a/platform/commonUI/inspect/src/services/InfoService.js b/platform/commonUI/inspect/src/services/InfoService.js index 50d03cb38c..ab1a6a5d15 100644 --- a/platform/commonUI/inspect/src/services/InfoService.js +++ b/platform/commonUI/inspect/src/services/InfoService.js @@ -61,10 +61,11 @@ define( // info bubble positioned as normal (with triangle pointing // to where clicked or pressed) bubble.css('position', 'absolute'); - if(agentService.isPhone(navigator.userAgent)) { - bubble.css('right', 5 + 'px'); - bubble.css('left', 5 + 'px'); - bubble.css('top', 40 + 'px'); + if (agentService.isPhone(navigator.userAgent)) { + bubble.css('right', 0 + 'px'); + bubble.css('left', 0 + 'px'); + bubble.css('top', 'auto'); + bubble.css('bottom', 25 + 'px'); } else { if (goLeft) { bubble.css('right', (winDim[0] - position[0] + OFFSET[0]) + 'px'); @@ -79,7 +80,7 @@ define( } // Add the menu to the body body.append(bubble); - + // Return a function to dismiss the bubble return function () { bubble.remove(); }; }