Fixed: Compared the rects minimum x value with it self instead of the visible minimum x value. Also fixed the test case to catch this.

This commit is contained in:
Martin Carlberg
2015-03-31 17:30:57 +02:00
parent 8e497e2a48
commit b3dfce7b5a
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -2730,7 +2730,7 @@ setBoundsOrigin:
doesItFitForWidth = documentViewVisibleRect.size.width >= rectInDocumentView.size.width;
// One of the following has to be true since our current visible rect didn't contain aRect.
if (rectInDocumentViewMinX < rectInDocumentViewMinX && doesItFitForWidth)
if (rectInDocumentViewMinX < documentViewVisibleRectMinX && doesItFitForWidth)
// Scroll to left edge of aRect as it is to the left of the visible rect and it fit inside
scrollPoint.x = rectInDocumentViewMinX;
else if (CGRectGetMaxX(rectInDocumentView) > CGRectGetMaxX(documentViewVisibleRect) && doesItFitForWidth)
+2 -2
View File
@@ -229,7 +229,7 @@
[scrollView setDocumentView:documentView];
[textField1 setFrameOrigin:CGPointMake(0, 0)];
[textField1 setFrameOrigin:CGPointMake(10, 10)];
[textField2 setFrameOrigin:CGPointMake(500, 500)];
[documentView addSubview:textField1];
@@ -260,7 +260,7 @@
visibleRect = [documentView visibleRect];
// We should now be back at top left corner
[self assertPoint:CGPointMake(0, 0) equals:visibleRect.origin message:@"VisibleRect origin not at top left corner again"];
[self assertPoint:CGPointMake(10, 10) equals:visibleRect.origin message:@"VisibleRect origin not at top left corner again"];
// Try to scroll again and it should not scroll
hasScrolled = [textField1 scrollRectToVisible:[textField1 bounds]];