summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorrsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-30 21:57:41 +0000
committerrsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-30 21:57:41 +0000
commit8f9e9a45e0a78ca7338d71f3fb1d9e5f3c690575 (patch)
tree4099d3614e3654e8ce0ec8a721839a563782093e /ui
parentd55ed410b0bfe0f6d5edb0e47d3911f4fa9bf1bf (diff)
downloadchromium_src-8f9e9a45e0a78ca7338d71f3fb1d9e5f3c690575.zip
chromium_src-8f9e9a45e0a78ca7338d71f3fb1d9e5f3c690575.tar.gz
chromium_src-8f9e9a45e0a78ca7338d71f3fb1d9e5f3c690575.tar.bz2
[Mac][MC] Fix some issues with the swipe gesture.
* Do not animate out if the notification has been swiped away. * Lock the direction so that if you start swiping one way, you can swipe quickly back the other to abort the gesture. * Use the device swipe direction, tracking the direction of the fingers, rather than the interpreted (natural/traditional) scroll direction. BUG=238252 Review URL: https://chromiumcodereview.appspot.com/15764008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203237 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/message_center/cocoa/popup_controller.mm24
1 files changed, 19 insertions, 5 deletions
diff --git a/ui/message_center/cocoa/popup_controller.mm b/ui/message_center/cocoa/popup_controller.mm
index 694d860..e807ce7 100644
--- a/ui/message_center/cocoa/popup_controller.mm
+++ b/ui/message_center/cocoa/popup_controller.mm
@@ -61,9 +61,15 @@ enum {
if (shouldTrackSwipe) {
MCPopupController* controller =
base::mac::ObjCCastStrict<MCPopupController>([self windowController]);
+ BOOL directionInverted = [event isDirectionInvertedFromDevice];
auto handler = ^(CGFloat gestureAmount, NSEventPhase phase,
BOOL isComplete, BOOL* stop) {
+ // The swipe direction should match the direction the user's fingers
+ // are moving, not the interpreted scroll direction.
+ if (directionInverted)
+ gestureAmount *= -1;
+
if (phase == NSEventPhaseBegan) {
[controller notificationSwipeStarted];
return;
@@ -75,7 +81,7 @@ enum {
if (ended || isComplete)
[controller notificationSwipeEnded:ended complete:isComplete];
};
- [event trackSwipeEventWithOptions:0
+ [event trackSwipeEventWithOptions:NSEventSwipeTrackingLockDirection
dampenAmountThresholdMin:-1
max:1
usingHandler:handler];
@@ -188,11 +194,19 @@ enum {
- (void)closeWithAnimation {
if (isClosing_)
return;
+
isClosing_ = YES;
+ // If the notification was swiped closed, do not animate it as the
+ // notification has already faded out.
+ if (swipeGestureEnded_) {
+ [self close];
+ return;
+ }
+
NSDictionary* animationDict = @{
- NSViewAnimationTargetKey: [self window],
- NSViewAnimationEffectKey: NSViewAnimationFadeOutEffect
+ NSViewAnimationTargetKey : [self window],
+ NSViewAnimationEffectKey : NSViewAnimationFadeOutEffect
};
boundsAnimation_.reset([[NSViewAnimation alloc]
initWithViewAnimations:[NSArray arrayWithObject:animationDict]]);
@@ -215,8 +229,8 @@ enum {
bounds_ = newBounds;
NSDictionary* animationDict = @{
- NSViewAnimationTargetKey: [self window],
- NSViewAnimationEndFrameKey: [NSValue valueWithRect:newBounds]
+ NSViewAnimationTargetKey : [self window],
+ NSViewAnimationEndFrameKey : [NSValue valueWithRect:newBounds]
};
boundsAnimation_.reset([[NSViewAnimation alloc]
initWithViewAnimations:[NSArray arrayWithObject:animationDict]]);