• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Smooth scrolling
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Smooth scrolling


  • Subject: Smooth scrolling
  • From: Amar Sagoo <email@hidden>
  • Date: Sun, 24 Oct 2004 19:25:06 +0100

Hi,

I am trying to implement smooth scrolling in a custom NSScrollView, like what you get in text views in Panther if you choose "Use smooth scrolling" in the Appearance preference pane. Or like in the Finder's column view.

I couldn't find a way to make this work automatically, so I implemented my own method. However, it's a little bit choppy on a Dual 867 MHz PowerMac G4. It redraws only 3 times over a 150ms period. No where near as smooth as the OS-provided animation.

So I'm wondering if there is a way to
a) Improve my algorithm
b) Make use of the system-provided animation.

OmniWeb added support for this system setting after Panther came out, but I don't know if they implemented their own animation technique or found a way to use the system's.


Here's the code I use at the moment (my view only ever scrolls horizontally):

- (void)scrollBy:(float)delta animate:(BOOL)animate
{
const double ANIMATION_DURATION = 0.15;


NSPoint oldOrigin = [self documentVisibleRect].origin;
NSPoint newOrigin = [[self contentView] constrainScrollPoint:NSMakePoint(oldOrigin.x + delta, oldOrigin.y)];
float actualDelta = newOrigin.x - oldOrigin.x;


if (animate)
{
NSDate *startTime = [NSDate date];
double secondsPassed = 0;
while (secondsPassed < ANIMATION_DURATION)
{
if (secondsPassed > 0)
{
[[self documentView] scrollPoint:
NSMakePoint(secondsPassed / ANIMATION_DURATION * actualDelta + oldOrigin.x,
newOrigin.y)];
}
[self display];
secondsPassed = -[startTime timeIntervalSinceNow];
}
}
[[self documentView] scrollPoint:newOrigin];
}

Any ideas are welcome!

Thanks
Amar
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
  • Prev by Date: Sound after suspend does not work
  • Next by Date: Menubar inside window
  • Previous by thread: Sound after suspend does not work
  • Next by thread: Menubar inside window
  • Index(es):
    • Date
    • Thread