NSScrollView sometimes ignores NSScrollElasticityNone and rubber bands anyway

I have a scroll view that can only scroll in the horizontal direction. I have:


scrollView.horizontalScrollElasticity = NSScrollElasticityNone;


For the most part, this works. But if the document view becomes quite wide and I scroll left real hard, the scroll view bounces anyway. In the document view I can catch it sometimes in adjustScroll:


-(NSRect)adjustScroll:(NSRect)proposedVisibleRect
{
    if (proposedVisibleRect.origin.x < 0.0)
    {
        NSLog(@"scroll view is going to bounce anyway....");
        proposedVisibleRect.origin.x = 0.0;
    }
   
    return proposedVisibleRect;
}


If I modify the proposed visible rect x origin to 0.0 (as done above) the scroll view "jitters" and it looks bad.

Replies

Did you find the cause of this behavior?


I'm having similar problem. My view monitors NSClipView's bounds changes via boundsDidChange notification, in order to layout subviews accordingly (some views needs to be centered around visible area). If you use scroll bars, everything is working smoothly. But when you try scroll with track pad with two fingers, the same code causes my content view to "jump" and "vibrate" very strange.


As workaround, I've tried to turn elasticy off, but it did't help. It appears that NSScrollView simply ignores it from time-to-time.


For the record: I do not modify any properties of scroll view or it's components, just my subviews. My view's frame remains the same during scrolling.

Nope. Wasn't able to track it down. I was attempting to accomplish something similar as you described, constrain a view to a certain fixed location and to not bounce with other views inside the scroll view's document view. I wanted the view to scroll sometimes though and it seemed a bit complicated trying to figure out how I could get that to work with addFloatingSubview:


I ended up just moving the view to the superview of the scroll view, and managing it as a sibling view relative to the scroll view instead as a workaround.