Line number view is offset, when scrolling above the first line (rubber banding scroll) #14

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants
Contributor

DrummerB commented Dec 5, 2012

With the rubber band scrolling inherited from iOS, it is possible to scroll slightly above the top or below the bottom of the content view (using a Magic Mouse or Trackpad). When scrolling above the top, the line number view is not scrolling correctly.

screenshot

Owner

mugginsoft commented Dec 5, 2012

In the short term, rather then delving into the line number code, you can set the enclosing NSScrollView's verticalScrollElasticity to NSScrollElasticityNone.

Contributor

DrummerB commented Dec 5, 2012

I considered that, but I'd rather have a proper fix. That line generation code could definitely use some comments :-)

Owner

mugginsoft commented Dec 5, 2012

It sure could! I have rationalised the code in parts as I have refactored it but there is plenty of room for improvement.

Contributor

DrummerB commented Dec 5, 2012

If I set the scrollPoint to the offset, when the offset is negative (rubber banding) it almost works. The math at least seems to be correct.

CGFloat y = ((NSInteger)visibleRect.origin.y % currentLineHeight) + addToScrollPoint;
if (visibleRect.origin.y < 0.0f)
    y = visibleRect.origin.y;
[[gutterScrollView contentView] scrollToPoint:NSMakePoint(0, y)];

However I get random flickers (the scroll view jumps to the top), unless I add a couple of 100 in the while loop:

while (indexNonWrap <= maxRangeVisibleRange + 500) {

Do you have any idea why that is? It doesn't make any sense to me.

Owner

mugginsoft commented Dec 5, 2012

Sorry I don't.

Regards

Jonathan Mitchell
Mugginsoft LLP

KosmicTask - the Integrated Scripting Environment for OS X.

http://www.mugginsoft.com/KosmicTask

On 5 Dec 2012, at 15:03, DrummerB notifications@github.com wrote:

If I set the scrollPoint to the offset, when the offset is negative (rubber banding) it almost works. The math at least seems to be correct.

CGFloat y = ((NSInteger)visibleRect.origin.y % currentLineHeight) + addToScrollPoint;
if (visibleRect.origin.y < 0.0f)
y = visibleRect.origin.y;
[[gutterScrollView contentView] scrollToPoint:NSMakePoint(0, y)];
However I get random flickers (the scroll view jumps to the top), unless I add a couple of 100 in the while loop:

while (indexNonWrap <= maxRangeVisibleRange + 500) {
Do you have any idea why that is? It doesn't make any sense to me.


Reply to this email directly or view it on GitHub.

Contributor

DrummerB commented Dec 5, 2012

The reason for the flickering turned out to be, that the line number string was updated. Since the line number string doesn't actually have to change, when rubber banding, I added a check to disable it.

Contributor

DrummerB commented Dec 5, 2012

Bye the way, thanks for releasing this open sourced!

Owner

mugginsoft commented Dec 5, 2012

No problem.

The original Smultron project was FOSS.

Regards

Jonathan Mitchell
Mugginsoft LLP

KosmicTask - the Integrated Scripting Environment for OS X.

http://www.mugginsoft.com/KosmicTask

On 5 Dec 2012, at 15:57, DrummerB notifications@github.com wrote:

Bye the way, thanks for releasing this open sourced!


Reply to this email directly or view it on GitHub.

@DrummerB DrummerB added a commit to DrummerB/Fragaria that referenced this pull request Dec 5, 2012

@DrummerB DrummerB Merge branch '#14' 96b7573

mugginsoft closed this in c1a2c00 Dec 5, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment