I have two instances of NSScrollView representing a view for the same content. The second scroll view, however, has a smaller version of the document view presented in the first scroll view. Both width and height can be individually scaled, and the original width and height restrictions may be lost, but that does not matter.
My synchronized scrolling works, even taking into account that in the second scroll view you need to align your scrolling behavior based on scaling. There is one small grip that I pull out of my hair:
- Since both views are happily viewing the smaller view, you need to slowly catch up with the larger view so that they both βcomeβ at the end of their document at the same time. This is not happening right now, and the result is that the smaller view is at the "end of the document" before the larger view.
The code for scrolling synchronization is based on an example found in Apple's documentation called Scrolling Sync. I adapted synchronizedViewContentBoundsDidChange: to the following code:
- (void) synchronizedViewContentBoundsDidChange: (NSNotification *) notification {
How do I need to change this code to achieve the desired effect (both scroll bars coming to the end of the document)?
EDIT: some clarification as it was confusing when I read it myself: a smaller view should slow down when scrolling through the first view to the end. That would probably mean re-evaluating this scaling factor ... but how?
EDIT 2: I changed the method based on Alex's assumption:
NSScroller *myScroll = [self horizontalScroller]; NSScroller *otherScroll = [[self synchronizedScrollView] horizontalScroller];
Using this method, a smaller view is βovertakenβ by a larger view when both scrollers reach 0.7, which is not very good. Then the enlarged view scrolls past the end of the document.
Roger source share