Skip to content

Commit 7865a40

Browse files
committed
- disabling animations on the minimap content offset changes while dragging (#42)
- forcing background and non-contiguous layout
1 parent 83fcc83 commit 7865a40

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

SCXcodeMinimap/SCXcodeMinimapView.m

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,9 @@ - (void)setVisible:(BOOL)visible
239239

240240
[self updateSize];
241241

242-
[self.textView.layoutManager setDelegate:(self.hidden ? nil : self)];
242+
[self.textView.layoutManager setDelegate:(self.hidden ? nil : self)];
243+
[self.textView.layoutManager setBackgroundLayoutEnabled:YES];
244+
[self.textView.layoutManager setAllowsNonContiguousLayout:YES];
243245

244246
BOOL editorHighlightingEnabled = [[[NSUserDefaults standardUserDefaults] objectForKey:SCXcodeMinimapShouldHighlightEditorKey] boolValue];
245247
if(editorHighlightingEnabled) {
@@ -444,11 +446,17 @@ - (void)handleMouseEvent:(NSEvent *)theEvent
444446
NSRect neededRect = [self.editorTextView.layoutManager boundingRectForGlyphRange:activeRange inTextContainer:self.editorTextView.textContainer];
445447
neededRect.origin.y = MAX(0, neededRect.origin.y - CGRectGetHeight(self.editor.containerView.bounds) / 2);
446448

447-
[NSAnimationContext beginGrouping];
448-
[[NSAnimationContext currentContext] setDuration:0.25f];
449-
[self.editor.scrollView.contentView.animator setBoundsOrigin:CGPointMake(0, neededRect.origin.y)];
450-
[self.editor.scrollView reflectScrolledClipView:self.editor.scrollView.contentView];
451-
[NSAnimationContext endGrouping];
449+
BOOL shouldAnimateContentOffset = (theEvent.type != NSLeftMouseDragged);
450+
451+
if(shouldAnimateContentOffset) {
452+
[NSAnimationContext beginGrouping];
453+
[[NSAnimationContext currentContext] setDuration:0.25f];
454+
[self.editor.scrollView.contentView.animator setBoundsOrigin:CGPointMake(0, neededRect.origin.y)];
455+
[self.editor.scrollView reflectScrolledClipView:self.editor.scrollView.contentView];
456+
[NSAnimationContext endGrouping];
457+
} else {
458+
[self.editor.scrollView.contentView setBoundsOrigin:CGPointMake(0, neededRect.origin.y)];
459+
}
452460
}
453461

454462
#pragma mark - Theme

0 commit comments

Comments
 (0)