Why isn't scrollRectToVisible animating?
Why isn't scrollRectToVisible animating?
- Subject: Why isn't scrollRectToVisible animating?
- From: Jens Alfke <email@hidden>
- Date: Thu, 04 Jul 2013 11:09:20 -0700
Most of the time NSScrollView’s animated scrolling Just Works. But I’m running into a frustrating edge case where the exact same scroll code animates in response to one UI event but not another.
Here’s the deal: In my app the left and right arrow keys jump to the previous/next track marker in an audio timeline view. To do this I compute the NSRect of the marker in the view and then call -scrollRectToVisible: to scroll that into view. Works great, and the scrolling is animated, which is what I want.
Now I want the 3-finger “swipe” gesture do the same thing. So I implemented -swipeWithEvent: to check the dx and dy of the event and then call exactly the same code that the arrow-keys call. It scrolls correctly … but it doesn’t animate. It just jumps.
Any idea what’s going on here? I suspect NSScrollView has a bunch of complicated heuristics about when it will animate and when not, and I’m running afoul of those somehow. But I don’t see why — I’m basically just doing:
- (void)swipeWithEvent:(NSEvent *)event {
if (event.deltaY == 0) {
[self moveSelectionBy: event.deltaX];
[self scrollRectToVisible: [self rectForSelection]];
}
}
—Jens
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden