Re: Autoscrolling when dragging?
Re: Autoscrolling when dragging?
- Subject: Re: Autoscrolling when dragging?
- From: Graham Cox <email@hidden>
- Date: Fri, 26 Aug 2011 10:42:59 +1000
On 19/08/2011, at 8:49 AM, Rick Mann wrote:
> If the user enters the auto-sroll area, start a timer
> If they leave the area, invalidate the timer
> If the timer fires, then start another, repeating timer that just adjusts the contentOffset of the scroll view in the appropriate direction
> If they let go, or leave the auto-scroll area, invalidate the second timer
>
> Am I missing anything?
You don't need two timers. (You never need two timers for one job, which applies to another similar idea I saw here recently, though I forget the context).
The first timer is fine - set its rate to something like 0.1 second. In its callback, decide whether and by how much to scroll. If you want to have a delay before the scrolling starts, just measure out the required delay and do nothing until it expires.
This is no more complicated than having two timers, and will likely be easier to manage - I've found that adding too many timers to a run loop can end up hitting performance, but even if it doesn't, it just seems wrong when one will do.
--Graham
_______________________________________________
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