att / rcloud

Collaborative data analysis and visualization
http://rcloud.social
MIT License
432 stars 142 forks source link

On (one specific) retina macbook pro, typing on the interactive prompt 'bounces' the prompt up and down #634

Closed cscheid closed 10 years ago

cscheid commented 10 years ago

It's horrendously annoying when it happens.

gordonwoodhull commented 10 years ago

we are doing height calculation with every change.

cscheid commented 10 years ago

In this case, the height calculation for some reason is happening at least twice, then.

One that slightly increases (1 or 2 pixels, if that much) the size of the prompt, and another that brings it back.

The end result is that it feels like the user is pounding on the keyboard and the screen is shaking.

gordonwoodhull commented 10 years ago

Is it two changes per keystroke or one? I.e. does it return to the same state after each keystroke or is it alternating once per key?

cscheid commented 10 years ago

It returns. The feeling is of "bouncing", one pixel up, then down.

gordonwoodhull commented 10 years ago

That sounds very annoying indeed. I wonder if rounding on a half-pixel could account for this somehow.

Or, we could avoid the problem. I have always thought it would be better to calculate the line height once and cache it, rather than calculating every time. That would save one resize per iteration.

Wish we knew how to repro though.

gordonwoodhull commented 10 years ago

Looked at this more closely. (Use the Source.) The prompt does not do the two-resize dance; only the cells do that. So my last comment is irrelevant.

It looks like this is really because we scroll to make sure the prompt is completely showing, after we size it. That calculation is a little too complicated.

I think this should work better (in shell_tab.js):

    function scroll_to_end(duration) {
        if(duration===0) {
            var div = $("#rcloud-cellarea");
            div.scrollTop(div[0].scrollHeight);
        }
        else {
            window.setTimeout(function() {
                ui_utils.scroll_to_after($("#prompt-div"));
            }, 100);
        }
    }

It still does the fancy animated scroll when executing a new cell, but it just keeps fully scrolled when typing on the prompt.

If you still have access to that machine, you could edit shell_tab.js directly in the debugger to see if this replacement function fixes the problem.

cscheid commented 10 years ago

Hey, this worked! I'll add the fix.